001 package net.sf.cpsolver.ifs.example.rpp; 002 003 import java.util.*; 004 005 import net.sf.cpsolver.ifs.model.*; 006 007 /** 008 * RPP model. 009 * <br><br> 010 * 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>) 011 * seeks to place a set of randomly generated rectangles (called objects) of different sizes into a larger rectangle 012 * (called placement area) in such a way 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 randomly generated for each object. 014 * The ratio between the total area of all objects and the size of the placement area will be denoted as the filled area ratio. 015 * <br><br> 016 * RPP allows us to generate various instances of the problem similar to a trivial timetabling problem. The correspondence is 017 * as follows: the object corresponds to a course to be timetabled – the x-coordinate to its time, the y-coordinate to its classroom. 018 * For example, a course taking three hours corresponds to an object with dimensions 3x1 (the course should be taught in one 019 * classroom only). Each course can be placed only in a classroom of sufficient capacity – we can expect 020 * that the classrooms are ordered increasingly in their size so each object will have a lower bound on its y-coordinate. 021 * 022 * @version 023 * IFS 1.1 (Iterative Forward Search)<br> 024 * Copyright (C) 2006 Tomáš Müller<br> 025 * <a href="mailto:muller@unitime.org">muller@unitime.org</a><br> 026 * Lazenska 391, 76314 Zlin, Czech Republic<br> 027 * <br> 028 * This library is free software; you can redistribute it and/or 029 * modify it under the terms of the GNU Lesser General Public 030 * License as published by the Free Software Foundation; either 031 * version 2.1 of the License, or (at your option) any later version. 032 * <br><br> 033 * This library is distributed in the hope that it will be useful, 034 * but WITHOUT ANY WARRANTY; without even the implied warranty of 035 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 036 * Lesser General Public License for more details. 037 * <br><br> 038 * You should have received a copy of the GNU Lesser General Public 039 * License along with this library; if not, write to the Free Software 040 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 041 */ 042 public class RPPModel extends Model { 043 /** Constructor. */ 044 public RPPModel() { 045 super(); 046 } 047 048 /** Returns rectangle of the given name */ 049 public Rectangle getRectangle(String name) { 050 for (Enumeration i = variables().elements(); i.hasMoreElements();) { 051 Variable v = (Variable)i.nextElement(); 052 if (v instanceof Rectangle && name.equals(((Rectangle)v).getName())) 053 return (Rectangle)v; 054 } 055 return null; 056 } 057 058 }