All constraints in Numberjack extend the this class. It provides accessors to get information about the predicate trees and the variables the constraints constrain.
Returns a string representing the current domain of the predicate.
Parameters:  solver (NBJ_STD_Solver) – If specified, the solver from which the state will be sourced, if None then the most recently loaded solver is used. 

Return type:  str 
Creates a new Domain instance representing the current domain of the expression.
Parameters:  solver (NBJ_STD_Solver) – If specified, the solver from which the domain will be sourced, if None then the most recently loaded solver is used. 

Returns:  The current domain of the expression. 
Return type:  Domain 
Current upper bound of variable.
Parameters:  solver (NBJ_STD_Solver) – If specified, the solver from which the upper bound will be sourced, if None then the most recently loaded solver is used. 

Returns:  The current upper bound of the variable. 
Return type:  The same as the original domain, either int, float, or str. 
Current lower bound of the expression.
Parameters:  solver (NBJ_STD_Solver) – If specified, the solver from which the lower bound will be sourced, if None then the most recently loaded solver is used. 

Returns:  The current lower bound of the expression. 
Return type:  The same as the original domain, either int, float, or str. 
The current size of the expression’s domain.
Parameters:  solver (NBJ_STD_Solver) – If specified, the solver from which the domain size will be sourced, if None then the most recently loaded solver is used. 

Returns:  The size of the expression’s domain. 
Return type:  int 
Returns the solver with which this expression was last loaded.
Returns:  The last loaded solver, or None if it has not been loaded anywhere. 

Return type:  NBJ_STD_Solver 
The current value of the expression. Should be used to retrieve the assigned value of a variable and the value of expressions like the objective function.
In the case of variables, it may not be passed in to the solver if it is not involved in a nontrivial constraint. For example, x <= 1, x will not get added (by this constraint alone) if it has a upper bound which is less or equal to 1. The variable’s lower bound will be returned as the value in this case.
Parameters:  solver (NBJ_STD_Solver) – If specified, the solver from which the value will be sourced, if None then the most recently loaded solver is used. 

Returns:  The current value of the expression. 
Return type:  The same as the original domain, either int, float, or str. 
Returns a string representing the initial definition of the content of the predicate and all its children. For example:
var1 = Variable(0, 10)
constraint = var1 < 10
print constraint.initial()
>>> (x0 < 10)
Return type:  str 

Returns a string that represents the name of the Predicate and the name of all its children.
Return type:  str 

Deprecated since version 1.1: Instead you should use Expression.get_value() and call str() on that.
Returns a string containing the valuation of the predicate.
Parameters:  solver (NBJ_STD_Solver) – If specified, the solver from which the state will be sourced, if None then the most recently loaded solver is used. 

Return type:  str 
Negate expression, used to negate another expression. It is equivalent to multiplying by 1.
var = Variable(1, 10)
model.add(var < 3)
Absolute expression, represents the absolute value of an expression or variable.
var = Variable(5, 5)
model.add(Abs(var) < 3)
Each of the following classes take two subexpressions or variables as parameters and can usually be created by operator overloading. For example x * y will create a Numberjack.Mul instance if either x or y are Numberjack variables.
All binary predicates such as And, LessThan and GreaterThan extend this class. They are separated from the base Predicate class to facilitate ease of print representations of the predicates.
Logical ‘and’ expression. Can be used at both the toplevel to specify an ‘and’ constraint, or reified to equal the truth value of the relation.
var1 = Variable() # Binary variable
var2 = Variable() # Binary variable
model.add(var1 & var2) # Post var1 And var2 constraint
var1 = Variable() # Binary variable
var2 = Variable() # Binary variable
var3 = Variable() # Binary variable
model.add( var3 == (var1 & var2) ) # Used as an expression
Logical ‘or’ expression. Can be used at both the toplevel to specify an ‘or’ constraint, or reified to equal the truth value of the relation.
var1 = Variable() # Binary variable
var2 = Variable() # Binary variable
model.add(var1  var2) # Post var1 Or var2 constraint
var1 = Variable() # Binary variable
var2 = Variable() # Binary variable
var3 = Variable() # Binary variable
model.add( var3 == (var1  var2) ) # Used as an expression
Equality expression between two expressions, or an expression and a constant. It can be used as either a toplevel hard constraint or reified as a subexpression.
var1 = Variable(0, 10)
var2 = Variable(0, 100)
var3 = Variable()
model.add(var1 == var2)
model.add(var1 == 5)
model.add( var3 == (var1 == var2) )
Disequality expression between two expressions, or an expression and a constant. It can be used as either a toplevel hard constraint or reified as a subexpression.
var1 = Variable(0, 10)
var2 = Variable(0, 100)
var3 = Variable()
model.add(var1 != var2)
model.add(var1 != 5)
model.add( var3 != (var1 != var2) )
Lessthan expression between two expressions, or an expression and a constant. It can be used as either a toplevel hard constraint or reified as a subexpression.
var1 = Variable(0, 10)
var2 = Variable(0, 100)
var3 = Variable()
model.add(var1 < var2)
model.add(var1 < 5)
model.add( var3 < (var1 < var2) )
Less than or equal expression between two expressions, or an expression and a constant. It can be used as either a toplevel hard constraint or reified as a subexpression.
var1 = Variable(0, 10)
var2 = Variable(0, 100)
var3 = Variable()
model.add(var1 <= var2)
model.add(var1 <= 5)
model.add( var3 <= (var1 <= var2) )
Greaterthan expression between two expressions, or an expression and a constant. It can be used as either a toplevel hard constraint or reified as a subexpression.
var1 = Variable(0, 10)
var2 = Variable(0, 100)
var3 = Variable()
model.add(var1 > var2)
model.add(var1 > 5)
model.add( var3 > (var1 > var2) )
Greater than or equal expression between two expressions, or an expression and a constant. It can be used as either a toplevel hard constraint or reified as a subexpression.
var1 = Variable(0, 10)
var2 = Variable(0, 100)
var3 = Variable()
model.add(var1 >= var2)
model.add(var1 >= 5)
model.add( var3 >= (var1 >= var2) )
Multiplication expression to equal the multiplication of the two operands. Cannot be used as a toplevel constraint.
var1 = Variable(0, 10)
var2 = Variable(0, 100)
mulxp1 = var2 * var1
mulexp2 = var2 * 10
Warning
Cannot be used with all solvers and ConstraintNotSupportedError will be raised when loading the model if this is the case.
Division expression to equal the integral division of the two operands. Cannot be used as a toplevel constraint.
var1 = Variable(0, 10)
var2 = Variable(0, 100)
divexp1 = var2 / var1
divexp2 = var2 / 10
Warning
Cannot be used with all solvers and ConstraintNotSupportedError will be raised when loading the model if this is the case.
Modulus expression to equal the modulo two expressions or an expression and a constraint. Cannot be used as a toplevel constraint.
var1 = Variable(0, 10)
var2 = Variable(0, 100)
modexp1 = var2 % var1
modexp2 = var2 % 10
Note
For MIP and SAT, the constraint is encoded such that the remainder takes the sign of the numerator, as per the C standard. This differs from Python where the remainder takes the sign of the denominator.
Warning
Cannot be used with all solvers and ConstraintNotSupportedError will be raised when loading the model if this is the case.
Table constraint explicityly specifying the list of allowed or forbidden tuples. Must be used as a toplevel constraint, it cannot be used as a subexpression.
Parameters: 


Maximisation objective function, sets the goal of search to be the maximisation of its’ arguments.
Parameters:  vars – The Variable or Expression to be maximized. 
