문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top