class Kiwi::Solver

Defined in:

edit_info.cr
solver.cr
tag.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

[View source]

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)

[View source]
def add_edit_variable(variable : Variable, strength : Float64) #

TODO What's this for?


[View source]
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

[View source]
def has_edit_variable(variable : Variable) : Bool #

TODO What's this for?


[View source]
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)

[View source]
def remove_edit_variable(variable : Variable) #

TODO What's this for?


[View source]
def 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.


[View source]
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

[View source]