Thanks again Thomas!
/Alexander
PS. For those interested, the resulting code looks like:
// Objective function
LinearObjectiveFunction g = new LinearObjectiveFunction(gArray, 0); // gArray
computed elsewhere
// Boundaries: s_l <= s <= s_u
// - Treat the boundaries as linear constraints.
Collection<LinearConstraint> constraints = new ArrayList();
DoubleMatrix eye = DoubleMatrix.eye(x.length); // I use the JBlas
matrix library
for (int i = 0; i < s_l.length; i++) {
double[] coef = eye.getRow(i).toArray();
constraints.add(new LinearConstraint(coef, Relationship.GEQ,
s_l.get(i)));
constraints.add(new LinearConstraint(coef, Relationship.LEQ,
s_u.get(i)));
}
// Solve
PointValuePair result = new SimplexSolver().optimize(g, new
LinearConstraintSet(constraints), GoalType.MINIMIZE, new MaxIter(100));
double[] s = result.getPoint();
7 mar 2013 kl. 19:05 skrev Thomas Neidhart <[email protected]>:
> On 03/07/2013 06:31 PM, Alexander Sehlström wrote:
>> Thomas,
>>
>> Thanks for the suggested solution. Seams to do the job as it no longer
>> throws errors.
>>
>> How do I retrieve my resulting double[] s from the PointValuePair r = new
>> SimplexSolver().optimize(...)?
>
> r.getPoint() returns the found solution for s in your case (if I
> understand your setup correctly).
>
> If you have more problems please also attach your example.
>
> Thomas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>