net.sf.cpsolver.ifs.example.tt
Class Location

java.lang.Object
  extended by net.sf.cpsolver.ifs.model.Value
      extended by net.sf.cpsolver.ifs.example.tt.Location
All Implemented Interfaces:
Comparable

public class Location
extends Value

Location (value, i.e., a single placement of the activity). Location encodes a slot and a selection of resources.

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.Value
iValue
 
Constructor Summary
Location(Activity activity, int day, int hour, Resource[] resources)
          Constructor. slot = nrHours * day + hour
Location(Activity activity, int slot, Resource[] resources)
          Constructor.
 
Method Summary
 int computeNrOfDiscouragedSlots()
          Computes number of discouraged slots (over all resources and the activity)
 boolean containResource(Resource resource)
          Returns true if the given resource is used by this location
 String getName()
          Values name -- for printing purposes (E.g., Monday 7:30)
 int getNrOfDiscouragedSlots()
          Number of slots (over all resources) which are discouraged
 Resource getResource(int idx)
          Gets given resource
 Resource[] getResources()
          Gets selection of resources
 int getSlot()
          Gets slot
 boolean hasIntersection(Location location)
          Returns true if the location intersects with another location.
 boolean isProhibited()
          Returns true if the location is prohibited.
 double toDouble()
          Int value (for optimization) -- getNrOfDiscouragedSlots() is returned
 
Methods inherited from class net.sf.cpsolver.ifs.model.Value
assigned, compareTo, conflicts, countAssignments, equals, getDescription, getExtra, getId, hashCode, isConsistent, lastAssignmentIteration, lastUnassignmentIteration, setExtra, setVariable, toString, unassigned, valueEquals, variable
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Location

public Location(Activity activity,
                int slot,
                Resource[] resources)
Constructor.

Parameters:
activity - parent activity
slot - starting time
resources - selection of resources

Location

public Location(Activity activity,
                int day,
                int hour,
                Resource[] resources)
Constructor. slot = nrHours * day + hour

Parameters:
activity - parent activity
day - day
hour - starting hour
resources - required resources
Method Detail

getSlot

public int getSlot()
Gets slot


getResources

public Resource[] getResources()
Gets selection of resources


getResource

public Resource getResource(int idx)
Gets given resource


containResource

public boolean containResource(Resource resource)
Returns true if the given resource is used by this location


getNrOfDiscouragedSlots

public int getNrOfDiscouragedSlots()
Number of slots (over all resources) which are discouraged


toDouble

public double toDouble()
Int value (for optimization) -- getNrOfDiscouragedSlots() is returned

Overrides:
toDouble in class Value

computeNrOfDiscouragedSlots

public int computeNrOfDiscouragedSlots()
Computes number of discouraged slots (over all resources and the activity)


hasIntersection

public boolean hasIntersection(Location location)
Returns true if the location intersects with another location. This means the same resource is used in the same time.


isProhibited

public boolean isProhibited()
Returns true if the location is prohibited. This means that the activity or a required resource has a time slot which is used by this location prohibited.


getName

public String getName()
Description copied from class: Value
Values name -- for printing purposes (E.g., Monday 7:30)

Overrides:
getName in class Value