001package org.cpsolver.ifs.example.rpp;
002
003import org.cpsolver.ifs.model.Model;
004
005/**
006 * RPP model. <br>
007 * <br>
008 * The random placement problem (RPP; for more details, see <a href=
009 * 'http://www.fi.muni.cz/~hanka/rpp/'>http://www.fi.muni.cz/~hanka/rpp/</a>)
010 * seeks to place a set of randomly generated rectangles (called objects) of
011 * different sizes into a larger rectangle (called placement area) in such a way
012 * that no objects overlap and all objects' borders are parallel to the border
013 * of the placement area. In addition, a set of allowable placements can be
014 * randomly generated for each object. The ratio between the total area of all
015 * objects and the size of the placement area will be denoted as the filled area
016 * ratio. <br>
017 * <br>
018 * RPP allows us to generate various instances of the problem similar to a
019 * trivial timetabling problem. The correspondence is as follows: the object
020 * corresponds to a course to be timetabled - the x-coordinate to its time, the
021 * y-coordinate to its classroom. For example, a course taking three hours
022 * corresponds to an object with dimensions 3x1 (the course should be taught in
023 * one classroom only). Each course can be placed only in a classroom of
024 * sufficient capacity - we can expect that the classrooms are ordered
025 * increasingly in their size so each object will have a lower bound on its
026 * y-coordinate.
027 * 
028 * @author  Tomáš Müller
029 * @version IFS 1.3 (Iterative Forward Search)<br>
030 *          Copyright (C) 2006 - 2014 Tomáš Müller<br>
031 *          <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
032 *          <a href="http://muller.unitime.org">http://muller.unitime.org</a><br>
033 * <br>
034 *          This library is free software; you can redistribute it and/or modify
035 *          it under the terms of the GNU Lesser General Public License as
036 *          published by the Free Software Foundation; either version 3 of the
037 *          License, or (at your option) any later version. <br>
038 * <br>
039 *          This library is distributed in the hope that it will be useful, but
040 *          WITHOUT ANY WARRANTY; without even the implied warranty of
041 *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
042 *          Lesser General Public License for more details. <br>
043 * <br>
044 *          You should have received a copy of the GNU Lesser General Public
045 *          License along with this library; if not see
046 *          <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>.
047 */
048public class RPPModel extends Model<Rectangle, Location> {
049    /** Constructor. */
050    public RPPModel() {
051        super();
052    }
053
054    /** Returns rectangle of the given name 
055     * @param name rectangle name
056     * @return rectangle of the given name
057     **/
058    public Rectangle getRectangle(String name) {
059        for (Rectangle r : variables()) {
060            if (name.equals(r.getName()))
061                return r;
062        }
063        return null;
064    }
065
066}