1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
package net.sourceforge.combean.graph.alg.lp; |
23 | |
|
24 | |
import net.sourceforge.combean.interfaces.graph.Edge; |
25 | |
import net.sourceforge.combean.interfaces.graph.containers.doubleval.FixedDoubleEdgeMap; |
26 | |
import net.sourceforge.combean.interfaces.graph.prop.GlobalNumberedEdgesGraphProp; |
27 | |
import net.sourceforge.combean.interfaces.mathprog.lp.LPVariable; |
28 | |
import net.sourceforge.combean.interfaces.mathprog.lp.model.LPVariableSequence; |
29 | |
import net.sourceforge.combean.mathprog.lp.DoubleLPVariable; |
30 | |
import net.sourceforge.combean.mathprog.lp.model.AbstractLPVariableSequence; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
public class EdgesAsLPVariableSequence extends AbstractLPVariableSequence |
40 | |
implements LPVariableSequence { |
41 | |
|
42 | 30 | private GlobalNumberedEdgesGraphProp numberedEdges = null; |
43 | |
|
44 | 30 | private FixedDoubleEdgeMap edgeCost = null; |
45 | 30 | private FixedDoubleEdgeMap edgeUpperBound = null; |
46 | 30 | private FixedDoubleEdgeMap edgeLowerBound = null; |
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
public EdgesAsLPVariableSequence(String offsetId, |
55 | |
GlobalNumberedEdgesGraphProp numberedEdges) { |
56 | 30 | super(offsetId); |
57 | |
|
58 | 30 | this.numberedEdges = numberedEdges; |
59 | 30 | } |
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
public int getNumVars() { |
65 | 30 | return this.numberedEdges.getNumEdges(); |
66 | |
} |
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
public LPVariable getLPVariable(int localColumn) { |
72 | 150 | Edge e = this.numberedEdges.getEdge(localColumn); |
73 | |
|
74 | 150 | double coeff = 0; |
75 | 150 | if (this.edgeCost != null) { |
76 | 150 | coeff = this.edgeCost.getDouble(e); |
77 | |
} |
78 | |
|
79 | 150 | double lower = 0; |
80 | 150 | if (this.edgeLowerBound != null) { |
81 | 0 | lower = this.edgeLowerBound.getDouble(e); |
82 | |
} |
83 | |
|
84 | 150 | double upper = Double.POSITIVE_INFINITY; |
85 | 150 | if (this.edgeUpperBound != null) { |
86 | 135 | upper = this.edgeUpperBound.getDouble(e); |
87 | |
} |
88 | |
|
89 | 150 | return new DoubleLPVariable(getVarOffsetId() + localColumn, |
90 | |
coeff, lower, upper); |
91 | |
} |
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
public final void setEdgeCost(FixedDoubleEdgeMap edgeCost) { |
97 | 30 | this.edgeCost = edgeCost; |
98 | 30 | } |
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
public final void setEdgeLowerBound(FixedDoubleEdgeMap edgeLowerBound) { |
104 | 0 | this.edgeLowerBound = edgeLowerBound; |
105 | 0 | } |
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
public final void setEdgeUpperBound(FixedDoubleEdgeMap edgeUpperBound) { |
111 | 27 | this.edgeUpperBound = edgeUpperBound; |
112 | 27 | } |
113 | |
} |