title: Microsoft Solver Foundation code for intervals "lowerbound <= D_1 <= upperbound" OR "D_1 == 0" in C#
body: <p>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 &lt;= D_1 &lt;= upperbound" was not satisfied.</p>
  
  <p>I have done some search and found this:
  <a href="https://stackoverflow.com/questions/2081049/microsoft-solver-foundation-for-semi-integer">Microsoft Solver Foundation for semi-integer</a>
  I tried to implement it, please see simplified code below. When I set the <strong>lowerbound</strong> for all decisions = 1, all decisions are resolved at least with value 1. To test the model more I set the <strong>lowerbound</strong> 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. <strong>lowerbound</strong> in the model still acts only as minimum value. Not in such a way that when <strong>lowerbound</strong> is infeasible, return 0. It implies <strong>binary</strong> does not have an effect on the model.</p>
  
  <pre><code>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 &lt;= D_1 &lt;= upperbound * binary;
  model.AddConstraint("constraint_1", C_1);
  
  Term C_2 = lowerbound * binary &lt;= D_2 &lt;= 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 
  });
  </code></pre>
  
  <p>Thank you for any feedback,
  Zdenek</p>