Kiwi::Solver
Inherits Reference < Object
Constructors
new
SourceInstance methods
add_constraint(constraint : Constraint)
Adds a constraint to the system.
##Example
solver = Kiwi::Solver.new
x = Kiwi::Variable.new("x")
solver.add_constraint(x + 2 == 4)
has_constraint(constraint : Constraint) : Bool
Checks if the constraint has already been added to the solver.
Example
solver = Kiwi::Solver.new
x = Kiwi::Variable.new("x")
constraint = x + 2 == 4
solver.add_constraint(constraint)
solver.has_constraint(constraint) # => true
remove_constraint(constraint : Constraint)
Removes a constraint from the system
Example
solver = Kiwi::Solver.new
x = Kiwi::Variable.new("x")
constraint = x + 2 == 4
solver.add_constraint(constraint)
solver.remove_constraint(constraint)
suggest_value(variable : Variable, value : Float64)
Suggests the value of a variable This raises an exception if the variable has not been defined as an editable variable.
update_variables
Updates the values of the external solver variables
Example
solver = Kiwi::Solver.new
x = Kiwi::Variable.new("x")
solver.add_constraint(x + 2 == 4)
solver.update_variables
x.value # => 2