简体   繁体   中英

Apache Commons Math SimplexSolver with lower and upper bounds?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM