class

Kiwi::Solver

Inherits Reference < Object

Constructors

Instance 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)
Source
add_edit_variable(variable : Variable, strength : Float64)

TODO: What's this for?

Source
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
Source
has_edit_variable(variable : Variable) : Bool

TODO: What's this for?

Source
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)
Source
remove_edit_variable(variable : Variable)

TODO: What's this for?

Source
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.

Source
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
Source