net.sf.cpsolver.ifs.extension
Class Assignment

java.lang.Object
  extended by net.sf.cpsolver.ifs.extension.Assignment

public class Assignment
extends Object

This class describing an assignment of a value to a variable together with a counter (used by CBS). Counter also supports ageing: the counter is multiplied by aging factor for each iteration.

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

Nested Class Summary
static class Assignment.AssignmentComparator
          Assignment comparator
 
Constructor Summary
Assignment(long iteration, Value value, double ageing)
          Constructor
 
Method Summary
static int combine(int a, int b)
          Combine two integers (for hash code)
 int compareTo(long iteration, Assignment a)
          Compare two assignments (their counters)
 boolean equals(Object o)
           
static Comparator getComparator(long iteration)
          Returns comparator of assignments
 Constraint getConstraint()
          Returns constraint
 double getCounter(long iteration)
          Get counter
 Value getValue()
          Returns value
 int hashCode()
           
 void incCounter(long iteration)
          Increments counter
 void revise(long iteration)
          Revise counter.
 void setConstraint(Constraint constraint)
          Sets constraint
 void setCounter(double cnt)
          Set counter
 String toString()
          String representation
 String toString(long iteration, boolean assignment)
          String representation (e.g., 10x A := a)
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Assignment

public Assignment(long iteration,
                  Value value,
                  double ageing)
Constructor

Parameters:
iteration - current iteration
value - value
ageing - ageing factor
Method Detail

getValue

public Value getValue()
Returns value


incCounter

public void incCounter(long iteration)
Increments counter

Parameters:
iteration - current iteration

setCounter

public void setCounter(double cnt)
Set counter

Parameters:
cnt - new value

getCounter

public double getCounter(long iteration)
Get counter

Parameters:
iteration - current iteration

getConstraint

public Constraint getConstraint()
Returns constraint


setConstraint

public void setConstraint(Constraint constraint)
Sets constraint


revise

public void revise(long iteration)
Revise counter. If ageing is used, counter is adopted to the current iteration: it is multiplited by ageing factor powered by the number of iterations since last revision.


combine

public static int combine(int a,
                          int b)
Combine two integers (for hash code)


hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

getComparator

public static Comparator getComparator(long iteration)
Returns comparator of assignments


toString

public String toString()
String representation

Overrides:
toString in class Object

toString

public String toString(long iteration,
                       boolean assignment)
String representation (e.g., 10x A := a)


compareTo

public int compareTo(long iteration,
                     Assignment a)
Compare two assignments (their counters)