++ed by:
FUKAI

1 PAUSE user
1 non-PAUSE user.

Ettore Di Giacinto
and 1 contributors

NAME

Algorithm::SAT::Expression - A class that represent an expression for Algorithm::SAT::Backtracking

SYNOPSIS

    # 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 }

DESCRIPTION

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.

METHODS

and()

Takes the inputs and build an AND expression for it

or()

Takes the inputs and build an OR expression for it

xor()

Takes the inputs and build an XOR expression for it

solve()

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.

with()

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.

LICENSE

Copyright (C) mudler.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

mudler <mudler@dark-lab.net>

SEE ALSO

Algorithm::SAT::Backtracking, Algorithm::SAT::Backtracking::DPLL, Algorithm::SAT::Backtracking::Ordered, Algorithm::SAT::Backtracking::Ordered::DPLL