Algorithm::SAT::Expression - A class that represent an expression for Algorithm::SAT::Backtracking
# with the default implementation (Algorithm::SAT::Backtracking) use Algorithm::SAT::Expression; my $exp = Algorithm::SAT::Expression->new; $exp->or( 'blue', 'green', '-yellow' ); $exp->or( '-blue', '-green', 'yellow' ); $exp->or( 'pink', 'purple', 'green', 'blue', '-yellow' ); my $model = $exp->solve(); # $model now is { 'yellow' => 1, 'green' => 1 } # using a specific implementation use Algorithm::SAT::Expression; my $exp = Algorithm::SAT::Expression->new->with("Algorithm::SAT::Backtracking::DPLL"); $exp->or( 'blue', 'green', '-yellow' ); $exp->or( '-blue', '-green', 'yellow' ); $exp->or( 'pink', 'purple', 'green', 'blue', '-yellow' ); my $model = $exp->solve(); # $model now is { 'yellow' => 1, 'green' => 1 }
Algorithm::SAT::Expression is a class that helps to build an expression to solve with Algorithm::SAT::Backtracking.
Have a look also at the tests file for an example of usage.
Takes the inputs and build an AND expression for it
Takes the inputs and build an OR expression for it
Takes the inputs and build an XOR expression for it
Uses Algorithm::SAT::Backtracking to return a model that satisfies the expression. The model it's a hash containing in the keys the literal and as the value if their presence represented by a 1 and the absence by a 0.
Note: if you use the Ordered implementation, the result is a Hash::Ordered.
Allow to change the SAT Algorithm used to solve the given expression
my $exp_simple_backtracking = Algorithm::SAT::Expression->new->with("Algorithm::SAT::Backtracking::DPLL");
if you don't request a specific implementation, defaults to Algorithm::SAT::Backtracking.
Copyright (C) mudler.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
mudler <mudler@dark-lab.net>
Algorithm::SAT::Backtracking, Algorithm::SAT::Backtracking::DPLL, Algorithm::SAT::Backtracking::Ordered, Algorithm::SAT::Backtracking::Ordered::DPLL
To install Algorithm::SAT::Backtracking, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Algorithm::SAT::Backtracking
CPAN shell
perl -MCPAN -e shell install Algorithm::SAT::Backtracking
For more information on module installation, please visit the detailed CPAN module installation guide.