001 /*
002 * Created on 13.04.2004
003 *
004 * To change the template for this generated file go to
005 * Window>Preferences>Java>Code Generation>Code and Comments
006 */
007 package org.jaga.individualRepresentation.greycodedNumbers;
008
009 /**
010 * Represents a constraint to the range of values a decimal variable inside an
011 * {@link NDecimalsIndividual} can assume.
012 *
013 * <p><u>Project:</u> JAGA - Java API for Genetic Algorithms.</p>
014 *
015 * <p><u>Company:</u> University College London and JAGA.Org
016 * (<a href="http://www.jaga.org" target="_blank">http://www.jaga.org</a>).
017 * </p>
018 *
019 * <p><u>Copyright:</u> (c) 2004 by G. Paperin.<br/>
020 * This program is free software; you can redistribute it and/or modify
021 * it under the terms of the GNU General Public License as published by
022 * the Free Software Foundation, ONLY if you include a note of the original
023 * author(s) in any redistributed/modified copy.<br/>
024 * This program is distributed in the hope that it will be useful,
025 * but WITHOUT ANY WARRANTY; without even the implied warranty of
026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
027 * GNU General Public License for more details.<br/>
028 * You should have received a copy of the GNU General Public License
029 * along with this program; if not, write to the Free Software
030 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
031 * or see http://www.gnu.org/licenses/gpl.html</p>
032 *
033 * @author Greg Paperin (greg@jaga.org)
034 *
035 * @version JAGA public release 1.0 beta
036 */
037 public class RangeConstraint {
038
039 double min = -Double.MAX_VALUE;
040 double max = Double.MAX_VALUE;
041
042 public RangeConstraint() {}
043
044 public RangeConstraint(double min, double max) {
045 setRange(min, max);
046 }
047
048 private void setRange(double min, double max) {
049 if (min > max)
050 throw new IllegalArgumentException("Invalid (empty) range ["
051 + min + ", " + max + "]");
052 this.min = min;
053 this.max = max;
054 }
055
056 public double getMinValue() {
057 return this.min;
058 }
059
060 public double getMaxValue() {
061 return this.max;
062 }
063
064 }