0

I am working with Benders Decomposition and for the moment I am using the bendersatsp.py file in order to adapt this code for my own MIP problem. The situation is that in my case the solution of the master takes part in some constraints of the subproblem, unlike this bendersatsp.py file. That's means that for each current solution of the master I have to modify the coeficients of these constraints.

So, what I could/must write in order to use the current solution vector of the master into the subproblem?

For the moment I have write this block of constraints into the separate function but the optimal objective value is not correct. Why this is not a good way?

Thanks in advance!

1 Answers1

2

In BendersLazyConsCallback, the self.get_values method:

Returns the solution values at the current node.

In the case that the node LP is unbounded, this method returns a vector that corresponds to an unbounded direction, scaled so that at least one of its elements has magnitude cplex.infinity. Thus, often the vector can be used directly, for example to separate a lazy constraint. However, due to the presence of large values in the vector care must be taken to avoid potential numerical errors. If in doubt, rescale the vector, and use it as an unbounded ray rather than a primal vector.

The solution vector is passed into workerLP.separate and is used to modify the linear coefficients of the workerLP objective. Instead, it sounds like you would like to modify the constraints of workerLP in some way.

Rather than calling:

cpx.objective.set_linear(zip(thevars, thecoefs))

You would instead call methods in the Cplex.linear_constraints interface.

rkersh
  • 4,447
  • 2
  • 22
  • 31
  • Thanks for your answer @rkersh! Yes, this is what I need. I have to modify some constraints each time that a new master solution is found. I have written these constraints into the `separate` function but it does not work properly. Why this is not a way to modify the constraints? Do you have idea? – Tive Surrender Jul 11 '19 at 17:03
  • Without seeing your code it's had to say what is going wrong. I would try adding adding a `cpx.write("test.lp")` before calling `cpx.solve()`. Look at the LP file and make sure your constraints are being added correctly. Also, make sure to check the status of the sub-problem solve (e.g., `cpx.solution.get_status()`) to make sure it is feasible. – rkersh Jul 11 '19 at 18:39