commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michele Mazzucco <michelemazzu...@gmail.com>
Subject [math] SimplexSolver - how to restrict solution to integer values?
Date Tue, 21 Jun 2011 14:39:49 GMT
Hi all,

I am trying to solve an optimization problem using the SimplexSolver.
The solution should be of type integer (e.g., which shoes and how many of each type to buy?),
not double:

Best      4.462 at [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 6.561679790026248] found in 2 iterations


I am using the following code

	LinearObjectiveFunction f = new LinearObjectiveFunction(new double[]{0.085d, 0.34d, 0.68d,
0.5d, 1d, 2d, 0.17d, 0.68d}, 0d);
        
        Collection<LinearConstraint> constraints = new ArrayList<LinearConstraint>();
	constraints.add(new LinearConstraint(new double[] {1d, 4.12, 8.24d, 7.57d, 15.14d, 30.28d,
3.8d, 15.24d}, Relationship.GEQ, 100));
       
        
        
        SimplexSolver solver = new SimplexSolver();
        RealPointValuePair solution = solver.optimize(f, constraints, GoalType.MINIMIZE, true);
        
        double value = solution.getValue();
        double[] point = solution.getPointRef();
        
        
        System.out.printf("Best %10.3f at %s found in %d iterations\n", value, Arrays.toString(point),
solver.getIterations());



Is there any way to achieve my goal?


Thanks,
Michele
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message