Skip to main content

Class: Solution

Solution of a Model. When a model is solved, the solution is stored in this object. The solution contains values of all variables in the model (including optional variables) and the value of the objective (if the model specified one).

Evaluation version of OptalCP

Note that in evaluation version of OptalCP the values of variables in the solution are masked and replaced by value absent (null in JavaScript).

Constructors

new Solution()

new Solution(): Solution

Creates an empty solution. That is, all variables are absent and the objective value is undefined.

Use this function to create a an external solution that can be passed to the solver before the solve starts as a warmStart (see solve, Solver) or during the solve using Solver.sendSolution.

Returns

Solution

Methods

getEnd()

getEnd(variable: IntervalVar): null | number

Returns end of the given interval variable in the solution. If the variable is absent in the solution then it returns null.

In evaluation version of OptalCP this function always returns null because real values of variables are masked and replaced by value absent.

Parameters

ParameterType
variableIntervalVar

Returns

null | number


getObjective()

getObjective(): ObjectiveValue

Returns objective value of the solution. If the model did not specify an objective returns undefined. If the objective value is absent (see optional IntExpr) then it returns null.

The correct value is reported even in case of evaluation version of OptalCP.

Returns

ObjectiveValue


getStart()

getStart(variable: IntervalVar): null | number

Returns start of the given interval variable in the solution. If the variable is absent in the solution then it returns null.

In evaluation version of OptalCP this function always returns null because real values of variables are masked and replaced by value absent.

Parameters

ParameterType
variableIntervalVar

Returns

null | number


isAbsent()

isAbsent(variable: IntervalVar): boolean

Returns true if the given variable is absent in the solution, i.e. if its value is absent. See optional IntervalVar.

In evaluation version of OptalCP this function always returns true because real values of variables are masked and replaced by value absent.

Parameters

ParameterType
variableIntervalVar

Returns

boolean


setAbsent()

setAbsent(intervalVar: IntervalVar): void

Sets the given variable to be absent in the solution.

Normally, solution is completely constructed by the solver. This function can be used for construction of an external solution that can be passed to the solver (see solve, Solver and Solver.sendSolution).

Parameters

ParameterType
intervalVarIntervalVar

Returns

void


setObjective()

setObjective(value: ObjectiveValue): void

Sets objective value of the solution.

Normally, solution is completely constructed by the solver. This function can be used for construction of an external solution that can be passed to the solver (see solve, Solver and Solver.sendSolution).

Parameters

ParameterType
valueObjectiveValue

Returns

void


setValue()

setValue(intervalVar: IntervalVar, start: number, end: number): void

Sets start and end of the given interval variable in the solution. I.e. the interval variable will be present in the solution.

Normally, solution is completely constructed by the solver. This function can be used for construction of an external solution that can be passed to the solver (see solve, Solver and Solver.sendSolution).

Parameters

ParameterType
intervalVarIntervalVar
startnumber
endnumber

Returns

void