| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| GVariable |
|
| 1.0;1 |
| 1 | /* | |
| 2 | This file is part of Combean. | |
| 3 | ||
| 4 | Combean is free software; you can redistribute it and/or modify | |
| 5 | it under the terms of the GNU General Public License as published by | |
| 6 | the Free Software Foundation; either version 2 of the License, or | |
| 7 | (at your option) any later version. | |
| 8 | ||
| 9 | Combean is distributed in the hope that it will be useful, | |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | GNU General Public License for more details. | |
| 13 | ||
| 14 | You should have received a copy of the GNU General Public License | |
| 15 | along with Foobar; if not, write to the Free Software | |
| 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 17 | */ | |
| 18 | package net.sourceforge.combean.mathprog.grooml; | |
| 19 | ||
| 20 | import net.sourceforge.combean.interfaces.mathprog.lp.LPVariable; | |
| 21 | ||
| 22 | ||
| 23 | /** | |
| 24 | * A single variable in an LP. | |
| 25 | * | |
| 26 | * Simple data holder, no own logic. Implements the LPVariable interface. | |
| 27 | */ | |
| 28 | class GVariable implements LPVariable { | |
| 29 | ||
| 30 | private String name = ""; | |
| 31 | private double coeff = 0.0; | |
| 32 | private double upperBound = Double.POSITIVE_INFINITY; | |
| 33 | private double lowerBound = 0.0; | |
| 34 | ||
| 35 | public GVariable(double coeff) { | |
| 36 | 740 | this.coeff = coeff; |
| 37 | 740 | this.upperBound = Double.POSITIVE_INFINITY; |
| 38 | 740 | this.lowerBound = 0.0; |
| 39 | } | |
| 40 | ||
| 41 | public GVariable(double coeff, Range rng) { | |
| 42 | 165 | this.coeff = coeff; |
| 43 | 165 | this.lowerBound = rng.from; |
| 44 | 165 | this.upperBound = rng.to; |
| 45 | } | |
| 46 | ||
| 47 | public String getName() { | |
| 48 | 295 | return this.name; |
| 49 | } | |
| 50 | ||
| 51 | public double getCoeff() { | |
| 52 | 835 | return this.coeff; |
| 53 | } | |
| 54 | ||
| 55 | public double getUpperBound() { | |
| 56 | 720 | return this.upperBound; |
| 57 | } | |
| 58 | ||
| 59 | public double getLowerBound() { | |
| 60 | 720 | return this.lowerBound; |
| 61 | } | |
| 62 | ||
| 63 | public String toString() { | |
| 64 | 10 | return "var '$name' ($coeff) [$lowerBound; $upperBound]"; |
| 65 | } | |
| 66 | ||
| 67 | public String toSummaryString() { | |
| 68 | 60 | return "$coeff | [$lowerBound; $upperBound]"; |
| 69 | } | |
| 70 | } |