Search code examples
ms-solver-foundation

Math.Min for objective function


Given two decision variable d1,d2 that take in only number 0 and 1 if the objective function is the sum of them we can express it by

Term t1=d1 + d2;
 model.AddGoal("goal", GoalKind.Maximize,t1);

Now I wish to take the smaller of them, i.e. Term

I want to write an objective function where

Math.min(d1,d2)

How to express the Math.min here?


Solution

  • The Model class contains a substantial set of relevant mathematical operations in the form of static methods, for example Min.

    You could simply write:

    Term t1 = Model.Min(d1, d2);
    

    and you are good to go :-)