sitelogo
Constraints

MINERVA provides advanced functionality for constraint handling together with the possibility to add your own user defined constraint handling.

Constraint handling is very powerful e.g. for difficult management problems: resource allocation, scheduling, planning.

MINERVA defines 2 predicates for constraint handling:

        co_add(+Var, +Constraint)
        co_get(+Var, -Constraint)
The programmer is has to supply two user defined predicates:
        co_merge(+Var, +ConstraintList)
        co_check(+Term, +Constraint)

co_add(+Var, +Constraint)
Add a constraint to a variable or constraint variable. "Constraint" can be any term but not a variable.

If "Var" is a variable, then it becomes a constraint variable.

If "Var" is a constraintvariable, then the constraint becomes marked as additional constraint and the user defined predicate co_merge(+Var,[NewConstraint,OldConstraint]) is invoked.

If "Var" is not a variable, then the user defined predicate co_check(+Var, NewConstraint) is invoked.

co_get(+Var, -Constraint)
co_get(+Var, -Constraint) returns the current constraint associated with a constraint variable. If "Var" is not a constraint variable, then the predicate fails.

co_merge(+Var, +ConstraintList)
When constraint variables are unified, then their associated constraints also have to be unified. This is the job of co_merge/2. The list of individual constraints must be combined into a new constraint, which can then be again associated with the constraint variable with co_add/2. If the individual constraints cause a contradiction, then the predicate shall fail.

Before co_merge/2 is invoked, the associated constraint variable is turned into a normal variable. Only after the following invokation of co_add/2 and of course upon backtracking it becomes a constraint variable again.

co_check(+Term, +Constraint)
The user defined predicate co_check/2 is invoked when a constraint variable is instantiated, i.e. bound to a term which is not a variable. co_check/2 must only succeed if this binding is allowed under the given Constraint "Constraint".

Examples

For examples please refer to the section ExamplePrograms.

Standard

These predicates are not part of the ISO-Prolog Standard.


co_add/2
co_get/2
co_merge/2
co_check/2

Up read on...
scroll to top managed with ubiCMS