Attempt to add a single edit Variable to the Solver at the given
priority. No edit variables may be added to the Solver 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 edit variable was successfully added to Solver at the specified priority.Result.duplicateEditVariable
: The edit variable was already present in the Solver.Result.badRequiredStrength
: The edit variable was added at Priority.required. Edit variables are used to suggest values to the solver. Since suggestions can't be mandatory, priorities cannot be Priority.required. If variable values need to be fixed at Priority.required, add that preference as a constraint. This allows the solver to check for satisfiability of the constraint (w.r.t other constraints at Priority.required) and check for duplicates.
Source
Result addEditVariable(Variable variable, double priority) { if (_edits.containsKey(variable)) return Result.duplicateEditVariable; if (!_isValidNonRequiredPriority(priority)) return Result.badRequiredStrength; Constraint constraint = new Constraint( new Expression(<Term>[new Term(variable, 1.0)], 0.0), Relation.equalTo ); constraint.priority = priority; assert(addConstraint(constraint) == Result.success); _EditInfo info = new _EditInfo(); info.tag = _constraints[constraint]; info.constraint = constraint; info.constant = 0.0; _edits[variable] = info; return Result.success; }