The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

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

SYNOPSIS

    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 }

DESCRIPTION

Algorithm::SAT::Expression is a class that helps to build an expression to solve with Algorithm::SAT::Backtracking.

Look also at the test 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.

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");

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>