gthole / lpp Goto Github PK
View Code? Open in Web Editor NEWRepresent linear programming problems and a solutions in Java.
Represent linear programming problems and a solutions in Java.
Hello,
I created the following minimization function:
public static LPP minimizeExampleOne() throws Exception {
return new LPP(
"Min",
new String[] {},
new double[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
new double[][] {
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0},
{0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 333, 0, 0},
{0, 0, 0, -1, 0, 0, 0, 28, 0, 0, 663, 166, 250, 0},
{0, 0, 0, 0, -1, 0, 0, 424, 0, 0, 331, 0, 500, 0},
{-1, 0, 0, 0, 0, 0, 0, 708, 386, 0, 0, 0, 0, 0},
{0, -1, 0, 0, 0, 0, 0, 0, 773, 256, 0, 0, 0, 0},
{0, 0, 0, 0, 0, -1, 0, 0, 0, 512, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, -1, 212, 386, 256, 331, 300, 250, 1000}
},
new String[] {">=", ">=", ">=", ">=", ">=", ">=", ">=",
">=", ">=", ">=", ">=", ">=", ">=", ">="},
new double[] {4803851, 28297010, 102898, 235794, 1286601, 89253045, 467921336,
0, 0, 0, 0, 0, 0, 0},
0);
}
Obviously trivial :-) but the output is:
Minimize 1x_0 + 1x_1 + 1x_2 + 1x_3 + 1x_4 + 1x_5 + 1x_6 + 1x_7 + 1x_8 + 1x_9 + 1x_10 + 1x_11 + 1x_12 + 1x_13
subject to the constraints:
1x_0 >= 4,803,851
1x_1 >= 28,297,010
1x_2 >= 102,898
1x_3 >= 235,794
1x_4 >= 1,286,601
1x_5 >= 89,253,045
1x_6 >= 467,921,336
-1x_2 + 333x_11 >= 0
-1x_3 + 28x_7 + 663x_10 + 166x_11 + 250x_12 >= 0
-1x_4 + 424x_7 + 331x_10 + 500x_12 >= 0
-1x_0 + 708x_7 + 386x_8 >= 0
-1x_1 + 773x_8 + 256x_9 >= 0
-1x_5 + 512x_9 >= 0
-1x_6 + 212x_7 + 386x_8 + 256x_9 + 331x_10 + 300x_11 + 250x_12 + 1,000x_13 >= 0
x_0 = 4,806,320.97
x_1 = 28,304,258.296
x_2 = 102,923.944
x_3 = 235,790.037
x_4 = 1,286,601.005
x_5 = 89,252,627.694
x_6 = 536,628,080.546
x_7 = 7,593.758
x_8 = 0
x_9 = 173,121.583
x_10 = 0
x_11 = 47,880.815
x_12 = 0
x_13 = 0
v_15 = 0
v_16 = 0
v_17 = 0
v_18 = 0
v_19 = 0
v_20 = 0
v_21 = 0
v_22 = 0
v_23 = 3,721,081.862
v_24 = 1,933,152.668
v_25 = 0
v_26 = 10,692,078.833
v_27 = 0
v_28 = 496,264,868,054.127
v_29 = 0
v_30 = 0
v_31 = 0
v_32 = 0
v_33 = 0
v_34 = 0
v_35 = 0
v_36 = 0
v_37 = 0
v_38 = 0
v_39 = 0
v_40 = 0
v_41 = 0
v_42 = 0
Objective Function Value = 1,454,726,287.769
Constraint 1 is binding with shadow price 141.688.
Constraint 2 is binding with shadow price 1.
Constraint 3 is binding with shadow price 1.08.
Constraint 4 is binding with shadow price 1.
Constraint 5 is binding with shadow price 1.
Constraint 6 is binding with shadow price 1.476.
Constraint 7 is binding with shadow price 1.
Constraint 8 is binding with shadow price 0.08.
Constraint 9 is binding with shadow price -0.
Constraint 10 is binding with shadow price -0.
Constraint 11 is binding with shadow price 141.688.
Constraint 12 is binding with shadow price -0.
Constraint 13 is binding with shadow price 0.476.
Constraint 14 is binding with shadow price -0.
Make Standard Form
Basic Variables: [0, 1, 2, 3, 4, 5, 6, 8, 13, 17, 21, 23, 24, 25]
Pivot at 9, 11
Pivot at 12, 9
Pivot at 11, 12
Pivot at 7, 10
Pivot at 23, 8
Pivot at 22, 9
Pivot at 27, 7
Which, as you'll note, gets some of the initial constraints wrong.
Constraints:
1x_3 >= 235,794
1x_5 >= 89,253,045
Result values:
x_3 = 235,790.037
x_5 = 89,252,627.694
Those values fail the basic >= test.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.