Two methods (maximize and minimize) were added into the class LinearProgram
def minimize(expression: Expression): Problem
def maximize(expression: Expression): Problem
The two new methods will override the method goal during the instantiation of a Problem object.
When we call Problem.toString, the output of goal will be used instead of the hard coded "maximize"
A check was added to prevent from calling maximize() on a minimization problem
A method solve was implemented in the trait Problem. Il will invoke the corresponding method according to the value of goal
Example
val lp = new LinearProgram()
import lp._
val x0 = Real()
val x1 = Real()
val min = minimize(x0 + x1)
.subjectTo(x0 >= 20)
.subjectTo(x1 >= 30)
println(min.toString)
// minimize x_0 + x_1
// subject to x_0 >= 20.0
// x_1 >= 30.0
min.solve // this equals to minimize(min)
maximize(min) // this will throw an exception
Description
This PR should close #718
A method
goal
was added into the traitProblem
.Two methods (
maximize
andminimize
) were added into the classLinearProgram
The two new methods will override the method
goal
during the instantiation of a Problem object. When we callProblem.toString
, the output ofgoal
will be used instead of the hard coded "maximize"A check was added to prevent from calling
maximize()
on a minimization problemA method
solve
was implemented in the traitProblem
. Il will invoke the corresponding method according to the value ofgoal
Example