suggestValueForVariable method

Result suggestValueForVariable(
  1. Variable variable,
  2. double value
)

Suggest an updated value for the edit variable. The edit variable must already be added to the solver.

Suggestions update values of variables within the Solver but take into account all the constraints already present in the Solver. Depending on the constraints, the value of the Variable may not actually be the value specified. The actual value can be read after the next flushUpdates call. Since these updates are merely "suggestions", they cannot be at Priority.required.

Check the Result returned to make sure the operation succeeded. Any errors will be reported via the message property on the Result.

Possible Results:

  • Result.success: The suggestion was successfully applied to the variable within the solver.
  • Result.unknownEditVariable: The edit variable was not already present in the Solver. So the suggestion could not be applied. Add this edit variable to the solver and then apply the value again. If you have already added the variable to the Solver, make sure the Result was Result.success.

Implementation

Result suggestValueForVariable(Variable variable, double value) {
  if (!_edits.containsKey(variable)) {
    return Result.unknownEditVariable;
  }

  _suggestValueForEditInfoWithoutDualOptimization(_edits[variable]!, value);

  return _dualOptimize();
}