    001    package ifs.example.rpp;
    002
    003    import ifs.model.*;
    004    import java.util.*;
    005
    006    /**
    007     * RPP model.
    008     * <br><br>
    009     * The random placement problem (RPP; for more details, see <a href='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 different sizes into a larger rectangle
    011     * (called placement area) in such a way that no objects overlap and all objects’ borders are parallel to the border
    012     * of the placement area. In addition, a set of allowable placements can be randomly generated for each object.
    013     * The ratio between the total area of all objects and the size of the placement area will be denoted as the filled area ratio.
    014     * <br><br>
    015     * RPP allows us to generate various instances of the problem similar to a trivial timetabling problem. The correspondence is
    016     * as follows: the object corresponds to a course to be timetabled – the x-coordinate to its time, the y-coordinate to its classroom.
    017     * For example, a course taking three hours corresponds to an object with dimensions 3x1 (the course should be taught in one
    018     * classroom only).  Each course can be placed only in a classroom of sufficient capacity – we can expect
    019     * that the classrooms are ordered increasingly in their size so each object will have a lower bound on its y-coordinate.
    020     *
    021     * @author <a href="mailto:muller@ktiml.mff.cuni.cz">Tomáš Müller</a>
    022     * @version 1.0
    023     */
    024    public class RPPModel extends Model {
    025        /** Constructor. */
    026        public RPPModel() {
    027            super();
    028        }
    029
    030        /** Returns rectangle of the given name */
    031        public Rectangle getRectangle(String name) {
    032            for (Enumeration i = variables().elements(); i.hasMoreElements();) {
    033                Variable v = (Variable)i.nextElement();
    034                if (v instanceof Rectangle && name.equals(((Rectangle)v).getName()))
    035                    return (Rectangle)v;
    036            }
    037            return null;
    038        }
    039
    040    }