Re: [ojAlgo-user] Knapsack problem with binary variables
Mathematics, linear algebra and optimisation
Brought to you by:
apete
From: Luke L. <luk...@gm...> - 2010-04-18 21:16:55
|
On 12 April 2010 20:31, Anders Peterson <an...@op...> wrote: > Don't think you've done anything wrong. > > I've looked briefly at your test case and can already conclude that the IntegerSolver does not work properly for maximization problems (all the test cases are minimization problems). Immediately fixed one part of the problem, but it still doesn't work... > > I'll definitely look into this some more, but I'm a little short on time currently. It may take some time. > > You can turn on debugging with > > GenericSolver.DEBUG = true; > > > Once you've called > > model.maximise(); > > the problem is already solved, and the solution written back to your variables. > > You may simply > > System.out.println(model); > > go "see" the results. This way you don't get access to the OptimisationState. > > > If you want to solve the problem with explicit access to the Solver and Result you'd do something like this: > > model.setMaximisation(true); > final OptimisationSolver solver = model.getDefaultSolver(); > final Result result = solver.solve(); > > > /Anders > > Thank you for your reply. I have checked out the latest code from CVS. The test case in my previous email now works as expected. However, when I change the numbers, I still get some unexpected results. For instance, when I set my variable maxWeight = 1.1 or maxWeight = 5, the integer constraints don't hold. I can write a junit test if it would help. Best, Luke |