Algorithm-SAT-Backtracking
view release on metacpan or search on metacpan
lib/Algorithm/SAT/Backtracking.pm view on Meta::CPAN
my $choice;
foreach my $variable ( @{$variables} ) {
$choice = $variable and last if ( !exists $model->{$variable} );
}
return $choice;
}
# ### update
# Copies the model, then sets `choice` = `value` in the model, and returns it.
sub update {
my ( $self, $copy, $choice, $value ) = @_;
$copy = dclone($copy);
$copy->{$choice} = $value;
return $copy;
}
# ### resolve
# Resolve some variable to its actual value, or undefined.
sub resolve {
lib/Algorithm/SAT/Backtracking/Ordered.pm view on Meta::CPAN
sub solve {
my ( $self, $variables, $clauses, $model ) = @_;
$model = Hash::Ordered->new if !defined $model;
return $self->SUPER::solve( $variables, $clauses, $model );
}
# ### update
# Copies the model, then sets `choice` = `value` in the model, and returns it, keeping the order of keys.
sub update {
my ( $self, $copy, $choice, $value ) = @_;
$copy = $copy->clone;
$copy->set( $choice => $value );
return $copy;
}
# ### resolve
# Resolve some variable to its actual value, or undefined.
sub resolve {
( run in 0.580 second using v1.01-cache-2.11-cpan-702932259ff )