001    package net.sf.cpsolver.ifs.example.rpp;
002    
003    import net.sf.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     * @version IFS 1.2 (Iterative Forward Search)<br>
029     *          Copyright (C) 2006 - 2010 Tomas Muller<br>
030     *          <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
031     *          <a href="http://muller.unitime.org">http://muller.unitime.org</a><br>
032     * <br>
033     *          This library is free software; you can redistribute it and/or modify
034     *          it under the terms of the GNU Lesser General Public License as
035     *          published by the Free Software Foundation; either version 3 of the
036     *          License, or (at your option) any later version. <br>
037     * <br>
038     *          This library is distributed in the hope that it will be useful, but
039     *          WITHOUT ANY WARRANTY; without even the implied warranty of
040     *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
041     *          Lesser General Public License for more details. <br>
042     * <br>
043     *          You should have received a copy of the GNU Lesser General Public
044     *          License along with this library; if not see
045     *          <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>.
046     */
047    public class RPPModel extends Model<Rectangle, Location> {
048        /** Constructor. */
049        public RPPModel() {
050            super();
051        }
052    
053        /** Returns rectangle of the given name */
054        public Rectangle getRectangle(String name) {
055            for (Rectangle r : variables()) {
056                if (name.equals(r.getName()))
057                    return r;
058            }
059            return null;
060        }
061    
062    }