net.sf.cpsolver.ifs.example.rpp
Class Rectangle

java.lang.Object
  extended by net.sf.cpsolver.ifs.model.Variable
      extended by net.sf.cpsolver.ifs.example.rpp.Rectangle
All Implemented Interfaces:
Comparable

public class Rectangle
extends Variable

Rectangle (variable). It encodes the name, width and height of the rectangle, minimal and maximal position of the rectangle. It also contains an information about prohibited X and Y coordinate (for MPP).

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
 
Fields inherited from class net.sf.cpsolver.ifs.model.Variable
iId, iValue
 
Constructor Summary
Rectangle(String name, int width, int height, int minX, int maxX, int minY, int maxY, Location initialLocation)
          Constructor.
 
Method Summary
 boolean equals(Object o)
          Compares two rectangles (based on rectangle names)
 int getHeight()
          Returns height of the rectangle
 int getMaxX()
           
 int getMaxY()
           
 int getMinX()
           
 int getMinY()
           
 String getName()
          Returns name of the rectangle
 int getProhibitedX()
           
 int getProhibitedY()
           
 int getWidth()
          Returns width of the rectangle
 boolean isProhibited(int x, int y)
          Returns true if the given location is prohibited.
 void setBounds(int minX, int maxX, int minY, int maxY)
          Set the bounds (minimal and maximal values of X and Y coordinates).
 void setProhibited()
          Prohibits given initial location (for MPP).
 void setProhibited(int x, int y)
          Prohibits given X and Y coordinates (for MPP).
 String toString()
          String representation (for printing and debugging purposes)
 
Methods inherited from class net.sf.cpsolver.ifs.model.Variable
addContstraint, addVariableListener, assign, compareTo, constraints, constraintVariables, countAssignments, 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, unassign, values
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Rectangle

public Rectangle(String name,
                 int width,
                 int height,
                 int minX,
                 int maxX,
                 int minY,
                 int maxY,
                 Location initialLocation)
Constructor.

Parameters:
name - variable's name
width - width of the rectangle
height - height of the rectangle
minX - minimal X-coordinate
maxX - maximal X-coordinate
minY - minimal Y-coordinate
maxY - maximal Y-coordinate
initialLocation - initial location (null if none)
Method Detail

setProhibited

public void setProhibited(int x,
                          int y)
Prohibits given X and Y coordinates (for MPP).


setProhibited

public void setProhibited()
Prohibits given initial location (for MPP).


isProhibited

public boolean isProhibited(int x,
                            int y)
Returns true if the given location is prohibited. This means that either X or Y equals to the prohibited X or Y coordinate respectively.


getProhibitedX

public int getProhibitedX()

getProhibitedY

public int getProhibitedY()

getMinX

public int getMinX()

getMaxX

public int getMaxX()

getMinY

public int getMinY()

getMaxY

public int getMaxY()

getWidth

public int getWidth()
Returns width of the rectangle


getHeight

public int getHeight()
Returns height of the rectangle


getName

public String getName()
Returns name of the rectangle

Overrides:
getName in class Variable

setBounds

public void setBounds(int minX,
                      int maxX,
                      int minY,
                      int maxY)
Set the bounds (minimal and maximal values of X and Y coordinates).


toString

public String toString()
String representation (for printing and debugging purposes)

Overrides:
toString in class Variable

equals

public boolean equals(Object o)
Compares two rectangles (based on rectangle names)

Overrides:
equals in class Variable