Algorithm-CP-IZ
view release on metacpan or search on metacpan
lib/Algorithm/CP/IZ.pm view on Meta::CPAN
my $var_array = shift;
push(@r, [map { $_->value } @$var_array]);
};
PARAMS will be hashref containning following keys.
=over 2
=item FindFreeVar
Same as search method.
=back
Returns 1 (success) or 0 (fail).
=item get_nb_fails
Returns fail count while searching solution.
=item get_nb_choice_points
Returns choice count while searching solution.
=item save_context
Save current status of variables and constraints.
my $v1 = $iz->create_int(1, 9);
$iz->save_context; # current status is saved.
$v1->Le(5); # $v1 is {1..5}
$iz->restore_context; # $v1 is restored to {1..9}
Returns integer which will be used for restore_context_until.
=item restore_context
Restore status of variables and constraints to last point which
'save_context' is called.
=item restore_context_until(LABEL)
Restore status of variables and constraints to point of label
which 'save_context' returns.
=item restore_all
Restore status of variables and constraints to point of first
'save_context' call.
=item forget_save_context
Last save_context point is forgotten by calling this function.
=item forgest_save_context_until(LABEL)
save_context points until LABEL are forgotten by calling this function.
=item cancel_search
Cancel running search from other thread or signal handler.
Context will be restored using restore_context_until if needed.
=item backtrack(VAR, INDEX, CALLBACK)
Set a callback function which will be called when context is restored to
current status.
VAR is an instance of Algorithm::CP::IZ::Int.
INDEX is an integer value.
CALLBACK is a coderef which takes parameters like:
sub callback {
# $var = VAR, $index = INDEX
my ($var, $index) = @_;
}
=item event_all_known(VARIABLES, CALLBACK, EXTRA)
Set a callback function which will be called when all variables in VARIABLES are
instantiated.
VARIABLES is an arrayref contains instances of Algorithm::CP::IZ::Int.
CALLBACK is a coderef and takes parameters and must return like:
sub callback {
# $variables and $extra are same as parameter.
my ($variables, $extra) = @_;
# return 1(success) or 0(fail)
return 1;
}
EXTRA is a just a data passed to callbeck as parameter (it can be anything).
=item event_known(VARIABLES, CALLBACK, EXTRA)
Set a callback function which will be called when any variable in VARIABLES is
instantiated.
VARIABLES is an arrayref contains instances of Algorithm::CP::IZ::Int.
CALLBACK is a coderef and takes parameters and must return like:
sub callback {
# $val is instantited now.
# $index is position in $variables.
# $variables and $extra are same as parameter.
my ($val, $index, $variables, $extra) = @_;
# return 1(success) or 0(fail)
return 1;
}
EXTRA is a just a data passed to callbeck as parameter (it can be anything).
=item event_new_min(VARIABLES, CALLBACK, EXTRA)
( run in 1.580 second using v1.01-cache-2.11-cpan-97f6503c9c8 )