net.sf.cpsolver.ifs.multi
Class MultiVariable

java.lang.Object
  extended by net.sf.cpsolver.ifs.model.Variable
      extended by net.sf.cpsolver.ifs.multi.MultiVariable
All Implemented Interfaces:
Comparable, VariableListener

public class MultiVariable
extends Variable
implements VariableListener

A variable containing multiple "normal" variables.

Version:
IFS 1.1 (Iterative Forward Search)
Copyright (C) 2006 Tomáš Müller
muller@unitime.org
Lazenska 391, 76314 Zlin, Czech Republic

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Field Summary
static boolean sCacheValues
           
 
Fields inherited from class net.sf.cpsolver.ifs.model.Variable
iId, iValue
 
Constructor Summary
MultiVariable()
           
MultiVariable(Vector variables)
          Constructor
 
Method Summary
 void addVariable(Variable variable)
          Add "normal" variable
 void assign(long iteration, Value value)
          Assign value to this variable.
 Vector computeValues()
          Variable domain -- Cartesian product of the domains of the "normal" variables
 String getName()
          Variable's name -- for printing purposes
 void removeVariable(Variable variable)
          Remove "normal" variable
 int size()
          Number of "normal" variables
 void unassign(long iteration)
          Unassign value from this variable.
 void valueRemoved(long iteration, Value value)
          Called by the variable when a value is permanently removed from its domain
 Vector values()
          Domain
 void variableAssigned(long iteration, Value value)
          Called by the variable when a value is assigned to it
 Vector variables()
          List of "normal" variables
 void variableUnassigned(long iteration, Value value)
          Called by the variable when a value is unassigned from it
 
Methods inherited from class net.sf.cpsolver.ifs.model.Variable
addContstraint, addVariableListener, compareTo, constraints, constraintVariables, countAssignments, equals, getAssignment, getBestAssignment, getBestAssignmentIteration, getDescription, getExtra, getId, getInitialAssignment, getModel, getVariableListeners, hardConstraints, hasAssignment, hashCode, hasInitialAssignment, hasValues, lastAssignmentIteration, lastUnassignmentIteration, removeContstraint, removeInitialValue, removeValue, removeVariableListener, setBestAssignment, setExtra, setInitialAssignment, setModel, setValues, softConstraints, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

sCacheValues

public static boolean sCacheValues
Constructor Detail

MultiVariable

public MultiVariable(Vector variables)
Constructor

Parameters:
variables - list of "normal" variables

MultiVariable

public MultiVariable()
Method Detail

addVariable

public void addVariable(Variable variable)
Add "normal" variable


removeVariable

public void removeVariable(Variable variable)
Remove "normal" variable


variables

public Vector variables()
List of "normal" variables


size

public int size()
Number of "normal" variables


computeValues

public Vector computeValues()
Variable domain -- Cartesian product of the domains of the "normal" variables


values

public Vector values()
Description copied from class: Variable
Domain

Overrides:
values in class Variable

assign

public void assign(long iteration,
                   Value value)
Description copied from class: Variable
Assign value to this variable. If the variable has already assigned another value, it is unassigned first. Also, all conflicting values are unassigned before the given value is assigned to this variable.

Overrides:
assign in class Variable
Parameters:
iteration - current iteration
value - the value to be assigned

unassign

public void unassign(long iteration)
Description copied from class: Variable
Unassign value from this variable.

Overrides:
unassign in class Variable
Parameters:
iteration - current iteration

getName

public String getName()
Description copied from class: Variable
Variable's name -- for printing purposes

Overrides:
getName in class Variable

variableAssigned

public void variableAssigned(long iteration,
                             Value value)
Description copied from interface: VariableListener
Called by the variable when a value is assigned to it

Specified by:
variableAssigned in interface VariableListener
Parameters:
iteration - current iteration
value - assigned to the variable

variableUnassigned

public void variableUnassigned(long iteration,
                               Value value)
Description copied from interface: VariableListener
Called by the variable when a value is unassigned from it

Specified by:
variableUnassigned in interface VariableListener
Parameters:
iteration - current iteration
value - unassigned from the variable

valueRemoved

public void valueRemoved(long iteration,
                         Value value)
Description copied from interface: VariableListener
Called by the variable when a value is permanently removed from its domain

Specified by:
valueRemoved in interface VariableListener
Parameters:
iteration - current iteration
value - removed from the variable's domain