Closed davide-f closed 4 years ago
Feel free to open a PR to improve printing.
Did you check is the formulation is correct with the LP printing?
Did you try it for a very small instance? Those are usually easier to debug.
The attached one is the smallest problem that reproduces the problem and makes sense. Most of the listing makes sense, but I had to check it deeper and also the dualization process, to check whether there might be a sign or something in the wrong place. Unlikely I don't have a solution yet, I posted as soon as I had a short code able to reproduce the problem so to start a preliminary discussion so that maybe with 2N eyes we can find the solution faster.
Sure thing, I will also look at the example.
In order to argument the finding, I am providing the following attached files: test_bug is the code (basically the same as the previous comment), prova_lp.txt is the "prova1.lp" file calculated by the test_bug code, and bug_check.pdf is the document that describes the calculation of the dual for the proposed example and details where the bug is.
If the calculations are correct, the bug should be in the sign of the c vector used in the dual reformulation and the inequality constraint. Probably the reference Max/Min may be reversed.
After I mentioned the comment in dualization package, they clarified that the convention used is different from the textbook one, and the dual reformulation is consistent with the goal; however that doesn't solve this bug... unlikely... Any ideas?
Hi @davide-f , I am taking a deeper look into this after a busy month. My previous comment was wrong, but I am taking a look anyway.
Ok, got it. The issue is a bit subtle. Everything is related to the constraint of the UPPER level:
@constraint(Upper(m), con_a, sum(m_P[i] - m_N[i] for i in 1:2) == 0)
I will take an extreme example. Take p = 0.0
and let's look at the solution second level problem.
max sum( -p_N[i]*0.1 -m_N[i]*0.01 + m_P[i]*0.003 for i in 1:2)
s.t.
-p_N[i] + m_P[i] - m_N[i] == - 3*i for i=1:2
0 <= p/m_N/P[i] <= 10
The actual optimal solution for this problem is:
m_P[i] = 0
m_N[1] = 3
m_N[2] = 6
p_N[i] = 0
Because m_N
is cheaper than p_N
. This is the only KKT point for p = 0
all other solutions are invalid.
However, this optimal solution is invalidated by the constraint:
sum(m_P[i] - m_N[i] for i in 1:2) == 0
Hence, the upper level has to find a different value of p
so that the lower level can be solved to optimality.
Consider now p = 0.089
max sum( - p_N[i]*0.1 - m_N[i]*0.099 + m_P[i]*0.086 for i in 1:2)
s.t.
-p_N[i] + m_P[i] - m_N[i] == - 3*i for i=1:2
0 <= p/m_N/P[i] <= 10
Again, the optimal solution for this problem is:
m_P[i] = 0
m_N[1] = 3
m_N[2] = 6
p_N[i] = 0
Because m_N
is cheaper than p_N
. This is the only KKT point for p = 0
all other solutions are invalid.
Hence, there is no p
in [0, 0.09)
for which the optimal solutions of the second level are accepted.
Therefore, the bilevel program is indeed infeasible whenever p
is constrained to be in a closed subset of [0, 0.09)
.
Thank you very much!
Dear developer,
In the past period I have significant problems in finding a result for my application and developed the following short piece of code that reproduce my issue. The problem described above represent the case of two people needing fruits (i.e. 3 fruit the first and 6 the second one) that cost 10 cents to the global market. However, they could also buy and sell fruits between them at price p. m_P/N represent the fruits exchanged between the users and p_N are the fruits bought from the external market by each user. Since no user produce fruits, the only solution of this problem is that each user buys the requested fruits from the market. Therefore: the only possible solution is m_P/N = 0, p_N = [3, 6]. That holds at any price p since users do not produce fruits.
The problem can be represented as
The proposed code is aimed to represent the problembelow works and find the solution m_P/N = 0, p_N = [3, 6] correctly. However, the solution comes with the value of p = about 0.09. Theoretically, this problem should be working for every value of p, as explained above, however, when I change the bounds of p, infeasibilities occur.
For example, if after the previous code, these lines are added:
The new problem becomes infeasible, which is very weird.
To confirm that the situation is weird, if also the bounds of variables m_P/N are set to 0, then the optimization works. However, as stated in the beginning, m_P/N==0 was a result of the first optimization, so the fact that by imposing these additional constraints, the problem works suggest that there might be a bug.
I am trying to investigate the issue, because I believe that this hidden bug may have significant silent effects in the optimality of the proposed problems.
P.S. I found it more useful to have the lp format. To do so, I changed the function print_lp as follows
File containing all code test_bug.txt