[jira] [Updated] (MATH-966) Native support for upper and lower bound for SimplexSolver

2017-04-18 Thread Rob Tompkins (JIRA)

 [ 
https://issues.apache.org/jira/browse/MATH-966?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Rob Tompkins updated MATH-966:
--
Fix Version/s: 4.X

> Native support for upper and lower bound for SimplexSolver
> --
>
> Key: MATH-966
> URL: https://issues.apache.org/jira/browse/MATH-966
> Project: Commons Math
>  Issue Type: Improvement
>Affects Versions: 3.1.1, 4.0
>Reporter: Alexander Sehlström
>Priority: Minor
> Fix For: 4.X
>
> Attachments: simplextest.java
>
>
> The SimplexSolver (import 
> org.apache.commons.math3.optim.linear.SimplexSolver) do not support lower and 
> upper bounds as input arguments. It would be convenient to have this support 
> since this would be very helpful when dealing with unconstrained problems (no 
> Ax = c present) that has bounds on x (x_l <= x <= x_u).
> Attached is a piece of code in need for such a feature where a lot of 
> fiddeling is needed in order to convert the bounds (x_l <= x <= x_u) to 
> constraints (Ax = c).



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Updated] (MATH-966) Native support for upper and lower bound for SimplexSolver

2014-02-18 Thread Thomas Neidhart (JIRA)

 [ 
https://issues.apache.org/jira/browse/MATH-966?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Thomas Neidhart updated MATH-966:
-

Assignee: (was: Thomas Neidhart)

 Native support for upper and lower bound for SimplexSolver
 --

 Key: MATH-966
 URL: https://issues.apache.org/jira/browse/MATH-966
 Project: Commons Math
  Issue Type: Improvement
Affects Versions: 4.0, 3.1.1
Reporter: Alexander Sehlström
Priority: Minor
 Attachments: simplextest.java


 The SimplexSolver (import 
 org.apache.commons.math3.optim.linear.SimplexSolver) do not support lower and 
 upper bounds as input arguments. It would be convenient to have this support 
 since this would be very helpful when dealing with unconstrained problems (no 
 Ax = c present) that has bounds on x (x_l = x = x_u).
 Attached is a piece of code in need for such a feature where a lot of 
 fiddeling is needed in order to convert the bounds (x_l = x = x_u) to 
 constraints (Ax = c).



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)


[jira] [Updated] (MATH-966) Native support for upper and lower bound for SimplexSolver

2013-04-09 Thread JIRA

 [ 
https://issues.apache.org/jira/browse/MATH-966?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Alexander Sehlström updated MATH-966:
-

Description: 
The SimplexSolver (import org.apache.commons.math3.optim.linear.SimplexSolver) 
do not support lower and upper bounds as input arguments. It would be 
convenient to have this support since this would be very helpful when dealing 
with unconstrained problems (no Ax = c present) that has bounds on x (x_l = x 
= x_u).

Attached is a piece of code in need for such a feature where a lot of fiddeling 
is needed in order to convert the bounds (x_l = x = x_u) to constraints (Ax = 
c).

  was:
Using the SimplexSolver takes about twice as long as using Matlab's linprog to 
solve s in min g'*s. Can it perhaps be related to the lack of support for lower 
and upper bounds and thus the need to translate these into linear constraints? 
In my simple test the number of elements in g is 640 making the number of 
needed constraints at least 1280.

Test code below.

-

import java.util.ArrayList;
import java.util.Collection;

import org.apache.commons.lang3.time.StopWatch;
import org.apache.commons.math3.optim.MaxIter;
import org.apache.commons.math3.optim.PointValuePair;
import org.apache.commons.math3.optim.linear.LinearConstraint;
import org.apache.commons.math3.optim.linear.LinearConstraintSet;
import org.apache.commons.math3.optim.linear.LinearObjectiveFunction;
import org.apache.commons.math3.optim.linear.NonNegativeConstraint;
import org.apache.commons.math3.optim.linear.Relationship;
import org.apache.commons.math3.optim.linear.SimplexSolver;

public class simplextest {
/**
 * Test of SimplexSolver.
 * 
 * The code is the core part of an SLP solver implementation, see [1].
 * 
 * The solution of the linear programming problem g( x )'*s takes around
 * 7900-8000 ms to solve in Matlab using the method linprog. This code,
 * using Apache Commons Math SimplexSolver, takes about twice that 
amount
 * of time to solve.
 * 
 * [1]F. A. Gomes and T. A. Senne. An slp algorithm and its 
application
 *to topology optimization. Computational  Applied Mathematics,
 *30(1):53–89, 2011.

 * @param args
 */
public static void main(String[] args) {
double delta = 1.0;
double xmax  = 1.0;
double xmin  = 0.0;

double[] x = new double[640];
for (int i = 0; i  x.length; i++) {
x[i] = 1.0;
}

double[] zeros = new double[x.length];
for (int i = 0; i  x.length; i++) {
zeros[i] = 0;
}

/* 

 * Starting from s_n, determine s_c, the solution of:
 * 
 * min   g( x )' * s
 *  s
 *   A * s = -c, (1)
 * s.t.
 *   s_l = s = s_u
 * 
 * where g( x ) is the vector of first order derivatives of f( 
x ) with
 * respect to xi, s is the step length to use for update of x, 
A is
 * a matrix of constraint coefficients and c a constraint 
vector.
 * The lower and upper bounds of s are defined as:
 * 
 * s_l = max( -delta, xmin - x ),   
 (2)
 * s_u = min(  delta, xmax - x ),   
 (3)
 * 
 * respectively.
 * 
 * 

 */

// Gradient g( x ) of objective function f( x ) at point x
LinearObjectiveFunction lof = new LinearObjectiveFunction(g, 0);

// Constraints A and -c
// - none present

// Boundaries s_l and s_u
double[] s_l = x;
double[] s_u = x;
for (int i = 0; i  x.length; i++) {
s_l[i] = Math.max(-delta, xmin-x[i]);
s_u[i] = Math.min( delta, xmax-x[i]);
}

CollectionLinearConstraint constraints = new ArrayList();

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]));
}

LinearConstraintSet lcs = 

[jira] [Updated] (MATH-966) Native support for upper and lower bound for SimplexSolver

2013-04-09 Thread JIRA

 [ 
https://issues.apache.org/jira/browse/MATH-966?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Alexander Sehlström updated MATH-966:
-

Attachment: simplextest.java

Test file.

 Native support for upper and lower bound for SimplexSolver
 --

 Key: MATH-966
 URL: https://issues.apache.org/jira/browse/MATH-966
 Project: Commons Math
  Issue Type: Improvement
Affects Versions: 4.0, 3.1.1
Reporter: Alexander Sehlström
Priority: Minor
 Attachments: simplextest.java


 The SimplexSolver (import 
 org.apache.commons.math3.optim.linear.SimplexSolver) do not support lower and 
 upper bounds as input arguments. It would be convenient to have this support 
 since this would be very helpful when dealing with unconstrained problems (no 
 Ax = c present) that has bounds on x (x_l = x = x_u).
 Attached is a piece of code in need for such a feature where a lot of 
 fiddeling is needed in order to convert the bounds (x_l = x = x_u) to 
 constraints (Ax = c).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira