001package net.sf.cpsolver.studentsct.reservation; 002 003import java.util.Collection; 004 005import net.sf.cpsolver.studentsct.model.Offering; 006 007/** 008 * Group reservation. This is basically a {@link IndividualReservation}, but 009 * students cannot be assigned over the limit and the priority is lower than on 010 * individual reservations. Also, a different limit than the number of students 011 * in the group can be provided. 012 * 013 * <br> 014 * <br> 015 * 016 * @version StudentSct 1.2 (Student Sectioning)<br> 017 * Copyright (C) 2007 - 2010 Tomáš Müller<br> 018 * <a href="mailto:muller@unitime.org">muller@unitime.org</a><br> 019 * <a href="http://muller.unitime.org">http://muller.unitime.org</a><br> 020 * <br> 021 * This library is free software; you can redistribute it and/or modify 022 * it under the terms of the GNU Lesser General Public License as 023 * published by the Free Software Foundation; either version 3 of the 024 * License, or (at your option) any later version. <br> 025 * <br> 026 * This library is distributed in the hope that it will be useful, but 027 * WITHOUT ANY WARRANTY; without even the implied warranty of 028 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 029 * Lesser General Public License for more details. <br> 030 * <br> 031 * You should have received a copy of the GNU Lesser General Public 032 * License along with this library; if not see 033 * <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>. 034 */ 035public class GroupReservation extends IndividualReservation { 036 private double iLimit; 037 038 /** 039 * Constructor 040 * @param id unique id 041 * @param limit reservation limit (-1 for unlimited) 042 * @param offering offering for which the reservation is 043 * @param studentIds one or more students 044 */ 045 public GroupReservation(long id, double limit, Offering offering, Long... studentIds) { 046 super(id, offering, studentIds); 047 iLimit = limit; 048 } 049 050 /** 051 * Constructor 052 * @param id unique id 053 * @param limit reservation limit (-1 for unlimited) 054 * @param offering offering for which the reservation is 055 * @param studentIds one or more students 056 */ 057 public GroupReservation(long id, double limit, Offering offering, Collection<Long> studentIds) { 058 super(id, offering, studentIds); 059 iLimit = limit; 060 } 061 062 /** 063 * Group reservations are of the second highest priority 064 */ 065 @Override 066 public int getPriority() { 067 return 1; 068 } 069 070 /** 071 * Group reservations can not be assigned over the limit. 072 */ 073 @Override 074 public boolean canAssignOverLimit() { 075 return false; 076 } 077 078 /** 079 * Reservation limit 080 */ 081 @Override 082 public double getReservationLimit() { 083 return iLimit; 084 } 085 086 /** 087 * Set reservation limit (-1 for unlimited) 088 */ 089 public void setReservationLimit(double limit) { 090 iLimit = limit; 091 } 092 093 /** 094 * Overlaps are allowed for individual reservations. 095 */ 096 @Override 097 public boolean isAllowOverlap() { 098 return false; 099 } 100}