Re: [ojAlgo-user] Removing Equalities and Inequalities methods
Mathematics, linear algebra and optimisation
Brought to you by:
apete
From: Andy B. <ber...@gm...> - 2012-05-18 17:55:59
|
Hi Anders, Just an FYI upfront, I am not much of a Matrice/Solver 'coder'. I know how to define the problems well, but like to use simple (to the user) code implementations. That is why I chose your package, as it was really clear to me to do something like: QuadraticSolver.Builder tmpBuilder = new QuadraticSolver.Builder(Q_ms, C_ms).equalities(AE_ms, BE_ms).inequalities(AI_ms, BI_ms); I couldn't figure out from the JavaDocs how to setup the Expression Based model, (months ago I spent a full day+ on trying to figure that out). Anyways, to my chagrin, I did an update yesterday when I read that you found an old bug and that the (QP?) Solver was now sped up by a factor of 100x. I compiled the update this morning and found out that the update broke my code. Any chance you could bring back the equalities and inequalities methods? From my limited knowledge, those seem to be very basic constraints that almost everybody would use. Or perhaps somebody could help me out on a code snippet to fix my "direct access to the solver" code (it is for a simple efficient frontier calc)... I really did spend a lot of time trying to get the expressions based model setup. Below is what I had, which no longer works. The 3 bolded and underlined methods under '-------- Solve the Problem --------" are what breaks... /** * We are solving the problem: * min 1/2 [X]'[Q][X] - [C]'[X] * where [AE][X] == [BE] * [AI][X] <= [BI] */ // required matrices and arrays MatrixStore Q_ms = null; MatrixStore C_ms = null; MatrixStore AE_ms = null; MatrixStore BE_ms = null; MatrixStore AI_ms = null; MatrixStore BI_ms = null; double[][] c_temp = null; double[][] ae = null; double[][] be = null; double[][] ai = null; double[][] bi = null; .............. I did not include Populating the matrices code, various different constraints depending if Fixed Returns are passed in or not, etc.. // create our actual matrix stores to be used in the calcs given problem setup Q_ms = PrimitiveDenseStore.FACTORY.rows(arrCovar); C_ms = PrimitiveDenseStore.FACTORY.rows(c_temp); AE_ms = PrimitiveDenseStore.FACTORY.rows(ae); BE_ms = PrimitiveDenseStore.FACTORY.rows(be); AI_ms = PrimitiveDenseStore.FACTORY.rows(ai); BI_ms = PrimitiveDenseStore.FACTORY.rows(bi); /** ------------------------------- Solve the Problem --------------------------------------*/ try { QuadraticSolver.Builder tmpBuilder = new QuadraticSolver.Builder(Q_ms, C_ms).*equalities*(AE_ms, BE_ms).inequalities(AI_ms, BI_ms); QuadraticSolver tmpSolver = tmpBuilder.build(); tmpSolver.*options.*timeLimit = Long.MAX_VALUE; OptimisationSolver.Result tmpResult = tmpSolver.*solve*(); BasicMatrix tmpSolution = tmpResult.getSolution(); PhysicalStore<Double> result = tmpSolution.toPrimitiveStore(); arrVariance[0] = result.transpose().multiplyRight(Q_ms).multiplyRight(result).get(0, 0); ...... <snip> Finally, if the bug fix you did for speeding up the calcs don't affect my above methodology I could just stay on my last compiled library. However, if the fix did affect the QP solver, is there a version that has the bug fix in it, but has not yet removed the deprecated methods? As a last resort, that version would be an acceptable fix for me (though it would be nice to understand the Expression Model ultimately) ... Thanks to everybody in advance, Andy or Andis (depending on which side of the Ocean you are on :-) ) > ---------------------------------------------------------------------- > > Message: 1 > Date: Sun, 13 May 2012 17:31:46 +0200 > From: Anders Peterson <an...@op...> > Subject: Re: [ojAlgo-user] Future changes to the optimisation package > To: oja...@li... > Message-ID: <2D5...@op...> > Content-Type: text/plain; charset=iso-8859-1 > > I deprecated (and removed) all those variants of addEpression(?) because I > realized there's an infinite number of methods that could be useful, and > instead of adding more variants I removed all but the most generic ones. I > still think that was a good decision. > > I've added a little bit to the on-line javadoc for Expressuon and > ExpressionsBasedModel. > > |