omnics.constraint
Class ScalarProduct
java.lang.Object
omnics.Constraint
omnics.constraint.ScalarProduct
- All Implemented Interfaces:
- java.io.Serializable
public class ScalarProduct
- extends Constraint
Implements the classic constraint:
a1*x1 + a2*x2 + ... + ak*xk sum,
where OP can be: =, ==, <, <=, >, >=, !=, <>
- Author:
- Cristian Frasinaru
- See Also:
- Serialized Form
|
Constructor Summary |
ScalarProduct(Var[] variables,
int[] coeffs,
int sum)
Creates a new instance of ScalarProduct |
ScalarProduct(Var[] variables,
int[] coeffs,
int sum,
java.lang.String operator)
Creates a new instance of ScalarProduct |
|
Method Summary |
int |
eval(Tuple tuple)
Evaluates a tuple. |
java.lang.String |
toString()
Returns a string representation of the constraint. |
| Methods inherited from class omnics.Constraint |
eval, eval, getFilter, getName, getProblem, getTuples, getVarArray, getVariables, setFilter, setName, setVariables, setVariables, variable |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
ScalarProduct
public ScalarProduct(Var[] variables,
int[] coeffs,
int sum)
- Creates a new instance of ScalarProduct
ScalarProduct
public ScalarProduct(Var[] variables,
int[] coeffs,
int sum,
java.lang.String operator)
- Creates a new instance of ScalarProduct
eval
public int eval(Tuple tuple)
- Description copied from class:
Constraint
- Evaluates a tuple. The result of the evaluation could be:
MIN or ALLOWED: the tuple is good
satisfies the constraint and can be part of a solution
- MAX or FORBIDDEN: the tuple is not good, cannot
be part of a solution
- a value in the interval (MIN,MAX): a penalty implied by
this tuple if it is used in a solution (in case of soft constraints)
Constants MIN, MAX, ALLOWED, FORBIDDEN are defined in
ValuationStructure
- Specified by:
eval in class Constraint
- Parameters:
tuple - some tuple
- Returns:
- a value between ValuationStructure.MIN and
ValuationStructure.MAX.
- See Also:
Constraint.eval(Tuple),
ValuationStructure
toString
public java.lang.String toString()
- Returns a string representation of the constraint.
- Overrides:
toString in class Constraint
- Returns:
- a string representation of the constraint