To improve the speed in your example, you can also adjust the epsilon value, e.g. setting it to 1e-3, which leads to the same result with all constraints satisfied, takes on my machine 3.5s instead of 6s with the default value of 1e-6. But you will have to experiment with this setting to get optimal values for your problem.
Thomas On Tue, Apr 9, 2013 at 10:15 AM, Thomas Neidhart <[email protected]>wrote: > Hi Alexander, > > thanks, but there is a small problem with your constraints: > > you assign the zeros array to coeff, but this does not copy the array, so > the array will be filled with '1's instead of an array with only one '1' at > position i. > > for ( int i = 0; i < s_l.length; i++ ) { > double[] coef = zeros; > coef[i] = 1; > constraints.add( new LinearConstraint( coef, Relationship.GEQ, > s_l[i] ) ); > constraints.add( new LinearConstraint( coef, Relationship.LEQ, > s_u[i] ) ); > } > > change this to something like: > > double[] coef = Arrays.copyOf( zeros, zeros.length ); > > Another thing: the lower/upper bounds in this test are for all variable > 1/1. > > Thomas > > > > On Tue, Apr 9, 2013 at 9:52 AM, Alexander Sehlström < > [email protected]> wrote: > >> Issue created! >> >> https://issues.apache.org/jira/browse/MATH-966 >> >> >> 9 apr 2013 kl. 08:36 skrev Thomas Neidhart <[email protected]>: >> >> > On 04/09/2013 08:23 AM, Alexander Sehlström wrote: >> >> Thomas, >> >> >> >> After writing the pice of code you were asking for I found the error; >> The max iteration exception was thrown, but swallowed by some part of my >> code, hence not showing up. So by increasing from maximum 100 to 1000 >> iterations the SimplexSolver returns a result. >> >> >> >> It is quite slow however and do not come near the computation time I >> need solving the same problem in Matlab with linprog. Suggestions of other >> Apache Commons Math classes that are solving the same type of problems as >> the SimplexSolver do are gratefully accepted. >> > >> > Hi Alexander, >> > >> > good that your example works. The reason its slow is most likely related >> > to your problem setup. >> > >> > The SimplexSolver currently does not support lower/upper bounds for the >> > variables, thus you had to create separate constraints for each variable >> > as suggested before. This makes the calculation quite slow I guess, so >> > we should add direct support for such bounds (similar to matlab or >> octave). >> > >> > This can be done with the original tableau (see >> > http://homepages.rpi.edu/~mitchj/handouts/upperbounds/). >> > >> > It would be nice to have your example as performance test, so you could >> > add a feature request to the issue tracker yourself. >> > >> > Thomas >> > >> > --------------------------------------------------------------------- >> > To unsubscribe, e-mail: [email protected] >> > For additional commands, e-mail: [email protected] >> > >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> >
