-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClLinearInequality.java
216 lines (189 loc) · 5.58 KB
/
ClLinearInequality.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
// $Id$
//
// Cassowary Incremental Constraint Solver
// Original Smalltalk Implementation by Alan Borning
// This Java Implementation by Greg J. Badros, <[email protected]>
// http://www.cs.washington.edu/homes/gjb
// (C) 1998, 1999 Greg J. Badros and Alan Borning
// See ../LICENSE for legal details regarding this software
//
// ClLinearInequality
//
package EDU.Washington.grad.gjb.cassowary;
public class ClLinearInequality extends ClLinearConstraint
{
public ClLinearInequality(ClLinearExpression cle,
ClStrength strength,
double weight)
{
super(cle,strength,weight);
}
public ClLinearInequality(ClLinearExpression cle,
ClStrength strength)
{
super(cle,strength);
}
public ClLinearInequality(ClLinearExpression cle)
{
super(cle);
}
public ClLinearInequality(ClVariable clv1,
byte op_enum,
ClVariable clv2,
ClStrength strength,
double weight)
throws ExCLInternalError
{
super(new ClLinearExpression(clv2),strength,weight);
if (op_enum == CL.GEQ) {
_expression.multiplyMe(-1.0);
_expression.addVariable(clv1);
} else if (op_enum == CL.LEQ) {
_expression.addVariable(clv1,-1.0);
} else // the operator was invalid
throw new ExCLInternalError("Invalid operator in ClLinearInequality constructor");
}
public ClLinearInequality(ClVariable clv1,
byte op_enum,
ClVariable clv2,
ClStrength strength)
throws ExCLInternalError
{
this(clv1,op_enum,clv2,strength,1.0);
}
public ClLinearInequality(ClVariable clv1,
byte op_enum,
ClVariable clv2)
throws ExCLInternalError
{
this(clv1,op_enum,clv2,ClStrength.required,1.0);
}
public ClLinearInequality(ClVariable clv,
byte op_enum,
double val,
ClStrength strength,
double weight)
throws ExCLInternalError
{
super(new ClLinearExpression(val),strength,weight);
if (op_enum == CL.GEQ) {
_expression.multiplyMe(-1.0);
_expression.addVariable(clv);
} else if (op_enum == CL.LEQ) {
_expression.addVariable(clv,-1.0);
} else // the operator was invalid
throw new ExCLInternalError("Invalid operator in ClLinearInequality constructor");
}
public ClLinearInequality(ClVariable clv,
byte op_enum,
double val,
ClStrength strength)
throws ExCLInternalError
{
this(clv,op_enum,val,strength,1.0);
}
public ClLinearInequality(ClVariable clv,
byte op_enum,
double val)
throws ExCLInternalError
{
this(clv,op_enum,val,ClStrength.required,1.0);
}
public ClLinearInequality(ClLinearExpression cle1,
byte op_enum,
ClLinearExpression cle2,
ClStrength strength,
double weight)
throws ExCLInternalError
{
super(((ClLinearExpression) cle2.clone()),strength,weight);
if (op_enum == CL.GEQ) {
_expression.multiplyMe(-1.0);
_expression.addExpression(cle1);
} else if (op_enum == CL.LEQ) {
_expression.addExpression(cle1,-1.0);
} else // the operator was invalid
throw new ExCLInternalError("Invalid operator in ClLinearInequality constructor");
}
public ClLinearInequality(ClLinearExpression cle1,
byte op_enum,
ClLinearExpression cle2,
ClStrength strength)
throws ExCLInternalError
{
this(cle1,op_enum,cle2,strength,1.0);
}
public ClLinearInequality(ClLinearExpression cle1,
byte op_enum,
ClLinearExpression cle2)
throws ExCLInternalError
{
this(cle1,op_enum,cle2,ClStrength.required,1.0);
}
public ClLinearInequality(ClAbstractVariable clv,
byte op_enum,
ClLinearExpression cle,
ClStrength strength,
double weight)
throws ExCLInternalError
{
super(((ClLinearExpression) cle.clone()),strength,weight);
if (op_enum == CL.GEQ) {
_expression.multiplyMe(-1.0);
_expression.addVariable(clv);
} else if (op_enum == CL.LEQ) {
_expression.addVariable(clv,-1.0);
} else // the operator was invalid
throw new ExCLInternalError("Invalid operator in ClLinearInequality constructor");
}
public ClLinearInequality(ClAbstractVariable clv,
byte op_enum,
ClLinearExpression cle,
ClStrength strength)
throws ExCLInternalError
{
this(clv,op_enum,cle,strength,1.0);
}
public ClLinearInequality(ClAbstractVariable clv,
byte op_enum,
ClLinearExpression cle)
throws ExCLInternalError
{
this(clv,op_enum,cle,ClStrength.required,1.0);
}
public ClLinearInequality(ClLinearExpression cle,
byte op_enum,
ClAbstractVariable clv,
ClStrength strength,
double weight)
throws ExCLInternalError
{
super(((ClLinearExpression) cle.clone()),strength,weight);
if (op_enum == CL.LEQ) {
_expression.multiplyMe(-1.0);
_expression.addVariable(clv);
} else if (op_enum == CL.GEQ) {
_expression.addVariable(clv,-1.0);
} else // the operator was invalid
throw new ExCLInternalError("Invalid operator in ClLinearInequality constructor");
}
public ClLinearInequality(ClLinearExpression cle,
byte op_enum,
ClAbstractVariable clv,
ClStrength strength)
throws ExCLInternalError
{
this(cle,op_enum,clv,strength,1.0);
}
public ClLinearInequality(ClLinearExpression cle,
byte op_enum,
ClAbstractVariable clv)
throws ExCLInternalError
{
this(cle,op_enum,clv,ClStrength.required,1.0);
}
public final boolean isInequality()
{ return true; }
public final String toString()
{ return super.toString() + " >= 0 )"; }
}