Relationship r = convertConstraintType(LLConstraint_llConstraint_ctype(c));
return new LinearConstraint(coeffients, r, constant);
}
public IValue llOptimize(IBool minimize, IBool nonNegative, ISet constraints, IConstructor f) {
SimplexSolver solver = new SimplexSolver();
ArrayList<LinearConstraint> constraintsJ =
new ArrayList<LinearConstraint>(constraints.size());
for(IValue v : constraints ){
constraintsJ.add(convertConstraint((IConstructor)v));
}
LinearObjectiveFunction fJ = convertLinObjFun(f);
GoalType goal = minimize.getValue() ?
GoalType.MINIMIZE : GoalType.MAXIMIZE;
IValueFactory vf = values;
boolean nonNegativeJ = nonNegative.getValue();
try {
RealPointValuePair res =
solver.optimize(fJ, constraintsJ, goal,nonNegativeJ);
return vf.constructor(Maybe.Maybe_just,
vf.constructor(
LLSolution_llSolution, convertToRealList(res.getPoint(), vf),
vf.real(res.getValue()) )
);