-
Notifications
You must be signed in to change notification settings - Fork 2
Goals
There are requirements which are easier to implement (and to calculate) when they are added as goals, and not as constraints. For instance, to maximize minimum of a set one could calculate minimum explicitly (using OperationType.Minimum
) and then add calculated variable as a goal and maximize it. However, it is much easier to maximize minimum using tricks with creating new variable, constraining it to not be less than variables in set, and maximize that variable. This requires no additional variables and much fewer constraints.
Please remember, that these are goals! You need to add them explicitly to goal function and correctly interpret result. For instance, minimizing variable 5 <= x <= 10
will create new variable y
and maximize it, so its value will be -5
. You can't just directly take -5
as a value of x
in final solution, because it is just an implementation detail. You need to obtain value of original variable, which should be 5
.
Currently there are implemented the following goals:
- Minimize
- Maximize
- Maximize minimum
- Minimize maximum
- Maximize maximum
- Minimize minimum
Creates expression for minimizing variable
IMilpManager manager;
IVariable a;
...
IVariable goal = a.MakeGoal(GoalType.Minimize);
manager.AddGoal("goal", goal);
or
IVariable goal = manager.MakeGoal(GoalType.Minimize, a);
manager.AddGoal("goal", goal);
Minimizes variable.
Creates expression for maximizing variable
IMilpManager manager;
IVariable a;
...
IVariable goal = a.MakeGoal(GoalType.Maximize);
manager.AddGoal("goal", goal);
or
IVariable goal = manager.MakeGoal(GoalType.Maximize, a);
manager.AddGoal("goal", goal);
Maximizes variable. Please note that maximization is default mode of library (and as for now cannot be changed), so it is not required to make goal explicitly, one can just pass original variable as a goal.
Creates expression for maximizing minimum of a set
IMilpManager manager;
IVariable a;
IVariable b;
IVariable c;
...
IVariable goal = a.MakeGoal(GoalType.MaximizeMinimum, b, c);
manager.AddGoal("goal", goal);
or
IVariable goal = manager.MakeGoal(GoalType.MaximizeMinimum, a, b, c);
manager.AddGoal("goal", goal);
Maximizes minimum of passed variables.
Creates expression for minimizing maximum of a set
IMilpManager manager;
IVariable a;
IVariable b;
IVariable c;
...
IVariable goal = a.MakeGoal(GoalType.MinimizeMaximum, b, c);
manager.AddGoal("goal", goal);
or
IVariable goal = manager.MakeGoal(GoalType.MinimizeMaximum, a, b, c);
manager.AddGoal("goal", goal);
Minimizes maximum of passed variables.
Creates expression for maximizing maximum of a set
IMilpManager manager;
IVariable a;
IVariable b;
IVariable c;
...
IVariable goal = a.MakeGoal(GoalType.MaximizeMaximum, b, c);
manager.AddGoal("goal", goal);
or
IVariable goal = manager.MakeGoal(GoalType.MaximizeMaximum, a, b, c);
manager.AddGoal("goal", goal);
Maximizes maximum of passed variables.
Creates expression for minimizing minimum of a set
IMilpManager manager;
IVariable a;
IVariable b;
IVariable c;
...
IVariable goal = a.MakeGoal(GoalType.MinimizeMinimum, b, c);
manager.AddGoal("goal", goal);
or
IVariable goal = manager.MakeGoal(GoalType.MinimizeMinimum, a, b, c);
manager.AddGoal("goal", goal);
Minimizes minimum of passed variables.