Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
DoubleLPConstraint |
|
| 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 Combean; if not, write to the Free Software | |
16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
17 | */ | |
18 | /* | |
19 | * Created on 22.04.2005 | |
20 | * | |
21 | */ | |
22 | package net.sourceforge.combean.mathprog.lp; | |
23 | ||
24 | import net.sourceforge.combean.interfaces.mathprog.lp.LPConstraint; | |
25 | import net.sourceforge.combean.mathprog.lp.model.statics.LPModelStringifier; | |
26 | ||
27 | /** | |
28 | * A linear constraint with representation based on plain Java doubles. | |
29 | * | |
30 | * @author schickin | |
31 | * | |
32 | */ | |
33 | public class DoubleLPConstraint implements LPConstraint { | |
34 | ||
35 | 513 | private byte relation = LPConstraint.REL_UNDEFINED; |
36 | 513 | private double rhs = 0.0; |
37 | ||
38 | 513 | private String name = ""; |
39 | ||
40 | /** | |
41 | * Constructor for an unnamed constraint | |
42 | * | |
43 | * @param relation the relation | |
44 | * @param rhs the right-hand side | |
45 | */ | |
46 | public DoubleLPConstraint(byte relation, double rhs) { | |
47 | 0 | super(); |
48 | ||
49 | 0 | this.relation = relation; |
50 | 0 | this.rhs = rhs; |
51 | 0 | } |
52 | ||
53 | /** | |
54 | * Constructor of a named constraint | |
55 | * | |
56 | * @param name the name of the constraint | |
57 | * @param relation the relation | |
58 | * @param rhs the right-hand side | |
59 | */ | |
60 | public DoubleLPConstraint(String name, byte relation, double rhs) { | |
61 | 513 | super(); |
62 | ||
63 | 513 | this.name = name; |
64 | 513 | this.relation = relation; |
65 | 513 | this.rhs = rhs; |
66 | 513 | } |
67 | ||
68 | /* (non-Javadoc) | |
69 | * @see net.sourceforge.combean.interfaces.mathprog.lp.LPConstraint#getRelation() | |
70 | */ | |
71 | public byte getRelation() { | |
72 | 513 | return this.relation; |
73 | } | |
74 | ||
75 | /* (non-Javadoc) | |
76 | * @see net.sourceforge.combean.interfaces.mathprog.lp.LPConstraint#getRhs() | |
77 | */ | |
78 | public double getRhs() { | |
79 | 513 | return this.rhs; |
80 | } | |
81 | ||
82 | /* (non-Javadoc) | |
83 | * @see net.sourceforge.combean.interfaces.base.NamedObject#getName() | |
84 | */ | |
85 | public String getName() { | |
86 | 447 | return this.name; |
87 | } | |
88 | ||
89 | public String toString() { | |
90 | 0 | StringBuffer result = new StringBuffer(); |
91 | 0 | result.append(getClass().getName() + " {"); |
92 | 0 | result.append(" name '" + getName() + "'"); |
93 | 0 | result.append(" " + |
94 | LPModelStringifier.getRelationSymbol(getRelation()) + | |
95 | " " + getRhs()); | |
96 | 0 | result.append("}"); |
97 | ||
98 | 0 | return result.toString(); |
99 | } | |
100 | } |