Re: [ojAlgo-user] Quadratic Program fails
Mathematics, linear algebra and optimisation
Brought to you by:
apete
From: Anders P. <an...@op...> - 2014-01-09 20:07:39
|
When I run that code I get an ArrayIndexOutOfBoundsException, and that's because "C" should be a column vector rather than a row vector. Had you taken my advice and used ExpressionsBasedModel this wouldn't have happened. That class actually does something for you: 1) You can model your problems without worrying about specific solver requirements. 2) It knows which solver to use. 3) It knows how to use that solver. 4) It has a presolver that tries to simplify the problem before invoking a solver (sometimes it turns out there is no need to invoke a solver at all). 5) When/if needed it scales problem parameters, before creating solver specific data structures, to minimize numerical problems in the solvers. 6) It's the only way to access the integer solver. /Anders On 9 jan 2014, at 16:53, Nico Potyka <Nic...@gm...> wrote: > Hi, > > I tried to use ojAlgo to implement a norm minimization problem, but the solver fails even for very simple instances. The following example is one particular simple instance. Q is the identity matrix, C the zero vector. The constraints express that the solution is a probability function (AE for normalization and AI for non-negativity). Q is positive definite and the solution should be (0.5, 0.5), but qSolver fails. > > > PrimitiveDenseStore tmpQ = PrimitiveDenseStore.FACTORY.rows(new double[][]{{1, 0},{0, 1}}); > PrimitiveDenseStore tmpC = PrimitiveDenseStore.FACTORY.rows(new double[][]{{0, 0}}); > > PrimitiveDenseStore tmpAE = PrimitiveDenseStore.FACTORY.rows(new double[][]{{1, 1}}); > PrimitiveDenseStore tmpBE = PrimitiveDenseStore.FACTORY.rows(new double[][]{{1}}); > > PrimitiveDenseStore tmpAI = PrimitiveDenseStore.FACTORY.rows(new double[][]{{-1, 0}, {0, -1}}); > PrimitiveDenseStore tmpBI = PrimitiveDenseStore.FACTORY.rows(new double[][]{{0}, {0}}); > > QuadraticSolver qSolver = new QuadraticSolver.Builder(tmpQ, tmpC).equalities(tmpAE, tmpBE).inequalities(tmpAI, tmpBI).build(); > > Optimisation.Result tmpResult = qSolver.solve(); > System.out.println(tmpResult.getState()); > > > Is there something wrong in my code or is there a problem with the quadratic solver? > > Thanks > Nico > > ------------------------------------------------------------------------------ > CenturyLink Cloud: The Leader in Enterprise Cloud Services. > Learn Why More Businesses Are Choosing CenturyLink Cloud For > Critical Workloads, Development Environments & Everything In Between. > Get a Quote or Start a Free Trial Today. > http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > |