Reputation: 389
I intend to solve the following linear programming problem using the Simplex method provided in the Apache Commons Math library. I do not get it to work and I find the API documentation limited.
Problem
Starting from the vector s0
, determine s
, the solution of:
| min f' * s
| s
|
| s.t. s_l <= s <= s_u
where f
is a vector, s_l
and s_u
are the lower and upper bounds of s
, respectively.
I can solve this problem easily in Matlab using the command linprog(f, [], [], [], [], s_l, s_u, s0, options)
and wish to do the same in Java, preferably using Apache Commons Math.
SimplexSolver
I have tried to use the Apache Commons Math SimplexSolver
similar the explanation here:
http://google-opensource.blogspot.se/2009/06/introducing-apache-commons-math.html
But I can't seam to define my bounds s_l
and s_u
and I have to provide LinearConstraint
(which I do not have any) using this method.
Are you supposed to be able to to that?
Upvotes: 0
Views: 1139
Reputation: 21561
I am not sure whether there is a shortcut, but actually a lower and upper bound are just 2 linear constraints.
Make sure that your first variable is larger than the first element of the lower bound (constraint 1) and smaller than the first element of the upper bound (constraint 2).
Then make sure that your second variable .... and so on.
This may be laborious to write but it should not be too hard to get it right.
Upvotes: 0