0

I am using Microsoft Solver Foundation version 3.0.2.10889 Express Edition for linear programming. I have no problems when using LP solver. However I am unable to set two interval constraints for one Decision at one time. What I would like is to set "D_1 == 0" when "lowerbound <= D_1 <= upperbound" was not satisfied.

I have done some search and found this: Microsoft Solver Foundation for semi-integer I tried to implement it, please see simplified code below. When I set the lowerbound for all decisions = 1, all decisions are resolved at least with value 1. To test the model more I set the lowerbound for all decisions = 5, hoping that I will get some decisions with result = 0. But the model is now infeasable. It seems that the model does not work as I expected. lowerbound in the model still acts only as minimum value. Not in such a way that when lowerbound is infeasible, return 0. It implies binary does not have an effect on the model.

SolverContext context = SolverContext.GetContext();
context.ClearModel();

Model model = context.CreateModel();

Decision D_1 = new Decision(Domain.RealNonnegative, "D_1");
Decision D_2 = new Decision(Domain.RealNonnegative, "D_2");
model.AddDecisions(D_1, D_2);

Decision binary = new Decision(Domain.IntegerRange(0, 1), "binary");
model.AddDecisions(binary);

Term woodproduction = 0.5 * D_1 + 0.7 * D_2;
model.AddConstraint("constraint_woodproduction", woodproduction == 20.5);

Term lowerbound = 10;
Term upperbound = 100;

Term C_1 = lowerbound * binary <= D_1 <= upperbound * binary;
model.AddConstraint("constraint_1", C_1);

Term C_2 = lowerbound * binary <= D_2 <= upperbound * binary;
model.AddConstraint("constraint_2", C_2);

model.AddGoal("cost", GoalKind.Minimize, lpgoal);

Solution solution = context.Solve(new SimplexDirective
{
          IterationLimit = -1,
          GetInfeasibility = true, //GetSensitivity = true 
});

Thank you for any feedback, Zdenek

Zdenek
  • 3
  • 2
  • Did you try making `D_1` and `D_2` integer (and the constraint `constraint_woodproduction`)? – Magnus Åhlander Mar 08 '19 at 07:06
  • Tried, but it did not help. The reason could be that the integer step of 1 is too high for the model to resolve. However the model started working after I added more **Decisions**. So to me it seems mixing **RealNonnegative** with **IntegerRange** is OK. – Zdenek Mar 08 '19 at 13:46
  • Now I have different problem. When I set the **lowerbound** for all decisions = 1, all decisions are resolved at least with value 1. To test the model more I set the **lowerbound** for all decisions = 5, hoping that I will get some decisions with result = 0. But the model is now infeasable. – Zdenek Mar 08 '19 at 13:46
  • It means that the model does not work as I expected. **lowerbound** in the model still acts only as minimum value. Not in such a way that when **lowerbound** is infeasible, return 0. It implies **binary** does not have an effect on the model. – Zdenek Mar 08 '19 at 13:47

0 Answers0