class Kiwi::Solver
- Kiwi::Solver
- Reference
- Object
Defined in:
edit_info.crsolver.cr
tag.cr
Constructors
Instance Method Summary
-
#add_constraint(constraint : Constraint)
Adds a constraint to the system.
-
#add_edit_variable(variable : Variable, strength : Float64)
TODO What's this for?
-
#has_constraint(constraint : Constraint) : Bool
Checks if the constraint has already been added to the solver.
-
#has_edit_variable(variable : Variable) : Bool
TODO What's this for?
-
#remove_constraint(constraint : Constraint)
Removes a constraint from the system
-
#remove_edit_variable(variable : Variable)
TODO What's this for?
-
#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
Constructor Detail
Instance Method Detail
def 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)
TODO What's this for?
def 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
def 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)
Suggests the value of a variable This raises an exception if the variable has not been defined as an editable variable.
def 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