ifs.model
Class Model

java.lang.Object
  extended by ifs.model.Model
Direct Known Subclasses:
CSPModel, JobShopModel, RPPModel, StructuredCSPModel, TimetableModel, TimetableModel

public class Model
extends Object

Generic model (definition of a problem).

It consists of variables and constraints. It has also capability of memorizing the current and the best ever found assignment.

Example usage:

Version:
1.0
Author:
Tomáš Müller
See Also:
Variable, Constraint, Solution, Solver

Constructor Summary
Model()
          Constructor
 
Method Summary
 void addConstraint(Constraint constraint)
          Adds a constraint to the model
 void addModelListener(ModelListener listener)
          Adds a model listener
 void addVariable(Variable variable)
          Adds a variable to the model
 void afterAssigned(long iteration, Value value)
          Called after a value is assigned to its variable
 void afterUnassigned(long iteration, Value value)
          Called after a value is unassigned from its variable
 Vector assignedVariables()
          The list of assigned variables in the model
 void beforeAssigned(long iteration, Value value)
          Called before a value is assigned to its variable
 void beforeUnassigned(long iteration, Value value)
          Called before a value is unassigned from its variable
 Vector bestUnassignedVariables()
          The list of unassigned variables in the best ever found solution
 Hashtable conflictConstraints(Value value)
          The list of constraints which are in a conflict with the given value if it is assigned to its variable.
 Set conflictValues(Value value)
          Returns the set of confliction variables with this value, if it is assigned to its variable
 Vector constraints()
          The list of constraints in the model
 int countConstraints()
          The number of constraints in the model
 int countVariables()
          The number of variables in the model
 int getBestPerturbations()
          Returns the number of perturbation variables in the best ever found solution
 int getBestUnassignedVariables()
          Returns the number of unassigned variables in the best ever found solution
 Hashtable getInfo()
          Returns information about the current solution.
 Vector getModelListeners()
          The list of model listeners
 int getTotalValue()
          Value of the current solution.
 boolean init(Solver solver)
          Model initialization
 ModelListener modelListenerOfType(Class type)
          The list of model listeners that are of the given class
 Vector perturbVariables()
          The list of perturbation variables in the model, i.e., the variables which has an initial value but which are not assigned with this value.
 void removeConstraint(Constraint constraint)
          Removes a constraint from the model
 void removeModelListener(ModelListener listener)
          Removes a model listener
 void removeVariable(Variable variable)
          Removes a variable from the model
 void restoreBest()
          Restore the best ever found assignment into the current assignment
 void saveBest()
          Save the current assignment as the best ever found assignment
 String toString()
           
 Vector unassignedHardConstraints()
          The list of hard constraints which contain at least one variable that is not assigned.
 Vector unassignedVariables()
          The list of unassigned variables in the model
 Vector variables()
          The list of variables in the model
 Vector variablesWithoutInitialValue()
          The list of variales without initial value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Model

public Model()
Constructor

Method Detail

variables

public Vector variables()
The list of variables in the model


countVariables

public int countVariables()
The number of variables in the model


addVariable

public void addVariable(Variable variable)
Adds a variable to the model


removeVariable

public void removeVariable(Variable variable)
Removes a variable from the model


constraints

public Vector constraints()
The list of constraints in the model


countConstraints

public int countConstraints()
The number of constraints in the model


addConstraint

public void addConstraint(Constraint constraint)
Adds a constraint to the model


removeConstraint

public void removeConstraint(Constraint constraint)
Removes a constraint from the model


unassignedVariables

public Vector unassignedVariables()
The list of unassigned variables in the model


assignedVariables

public Vector assignedVariables()
The list of assigned variables in the model


perturbVariables

public Vector perturbVariables()
The list of perturbation variables in the model, i.e., the variables which has an initial value but which are not assigned with this value.


conflictValues

public Set conflictValues(Value value)
Returns the set of confliction variables with this value, if it is assigned to its variable


variablesWithoutInitialValue

public Vector variablesWithoutInitialValue()
The list of variales without initial value


beforeAssigned

public void beforeAssigned(long iteration,
                           Value value)
Called before a value is assigned to its variable


beforeUnassigned

public void beforeUnassigned(long iteration,
                             Value value)
Called before a value is unassigned from its variable


afterAssigned

public void afterAssigned(long iteration,
                          Value value)
Called after a value is assigned to its variable


afterUnassigned

public void afterUnassigned(long iteration,
                            Value value)
Called after a value is unassigned from its variable


toString

public String toString()
Overrides:
toString in class Object

getInfo

public Hashtable getInfo()
Returns information about the current solution. Information from all model listeners and constraints is also included.


getBestUnassignedVariables

public int getBestUnassignedVariables()
Returns the number of unassigned variables in the best ever found solution


getBestPerturbations

public int getBestPerturbations()
Returns the number of perturbation variables in the best ever found solution


saveBest

public void saveBest()
Save the current assignment as the best ever found assignment


restoreBest

public void restoreBest()
Restore the best ever found assignment into the current assignment


bestUnassignedVariables

public Vector bestUnassignedVariables()
The list of unassigned variables in the best ever found solution


getTotalValue

public int getTotalValue()
Value of the current solution. It is the sum of all assigned values, i.e., Value.toInt().


addModelListener

public void addModelListener(ModelListener listener)
Adds a model listener


removeModelListener

public void removeModelListener(ModelListener listener)
Removes a model listener


init

public boolean init(Solver solver)
Model initialization


getModelListeners

public Vector getModelListeners()
The list of model listeners


modelListenerOfType

public ModelListener modelListenerOfType(Class type)
The list of model listeners that are of the given class


conflictConstraints

public Hashtable conflictConstraints(Value value)
The list of constraints which are in a conflict with the given value if it is assigned to its variable. This means the constraints, which adds a value into the set of conflicting values in Constraint.computeConflicts(Value, Set).


unassignedHardConstraints

public Vector unassignedHardConstraints()
The list of hard constraints which contain at least one variable that is not assigned.



Copyright © 2005 Tomáš Müller