Re: [ojAlgo-user] ojalgo v3.2: quadratic optimization, trouble when running an optimization with "t
Mathematics, linear algebra and optimisation
Brought to you by:
apete
From: Anders P. <an...@op...> - 2012-05-14 07:47:23
|
There was a problem with the LInearSolver and constraints with negative valued upper limits. I've released v32.2 with that fixed. Also; feeding the QuadraticSolver an initial iteration point (feasible solution) is not always helpful. In a general case you're probably better off not doing this. /Anders On 10 maj 2012, at 09:33, Anders Peterson wrote: > You're right ojAlgo currently does not have a direct/smart way to detect infeasibility of the inequality constraints in a quadratic program. The LinearSolver should be able to do that for you, and if you get a feasible solution from the linear solver you can feed that as a starting point for the quadratic solver. > > /Anders > > > On 9 maj 2012, at 18:00, Reda-Jürg MESSIKH wrote: > >> H Anders, >> >> I found yet another odd behaviour. >> >> The problem defined with the data below (same notation as the former emails) has no solution (the inequalities are impossible to satisfy). >> >> >> >> Matlab detects this impossibility immediately (less than 3seconds) and exits with the right message. >> >> OjAlgo takes a really long time (more than 1 minute, I have interupted the execution afterwards). >> >> I susepct that there is no preliminary check whether the inequalities are not overly stringent and hence this behaviour. If you agree with this point, wouldn't it be a good thing to add such preliminary checks ? >> >> >> Reda >> >> >> >> >> >> >> From: "Anders Peterson" <an...@op...> >> >> To: Reda-Jürg MESSIKH <rme...@pi...> >> Date: 09.05.2012 10:11 >> Subject: Re: ojalgo v3.2: quadratic optimization, trouble when running an optimization with "tight" upper bounds for the solution >> >> >> >> There is still the issue that ojAlgo and MATLAB gave different solutions. Which is "better"? What does MATLAB say about the ojAlgo solution, is it a feasible solution? What does ojAlgo say about the MATLAB solution... >> >> >> On 8 maj 2012, at 17:18, Reda-Jürg MESSIKH wrote: >> >>> Hi Anders, thanks for the upload. >>> >>> As per FinanceUtils, I am not sure what I have done wrong before, now all is fine. >>> >>> Reda >>> >>> >>> >>> >>> From: "Anders Peterson" <an...@op...> >>> >>> To: Reda-Jürg MESSIKH <rme...@pi...> >>> Date: 08.05.2012 16:42 >>> Subject: Re: ojalgo v3.2: quadratic optimization, trouble when running an optimization with "tight" upper bounds for the solution >>> >>> >>> >>> Just uploaded a new snapshot to sourceforge. >>> >>> What problem do you have with FinanceUtils? I don't see any. >>> >>> /Anders >>> >>> >>> On 8 maj 2012, at 16:13, Reda-Jürg MESSIKH wrote: >>> >>>> Hi Anders, >>>> >>>> I just did a few tests that are conclusive, so would it be possible to do another build ? >>>> >>>> As a side remark, while building your modified source code, we have seen that the financeUtils does not build. >>>> >>>> Reda >>>> >>>> >>>> >>>> >>>> >>>> From: "Anders Peterson" <an...@op...> >>>> >>>> To: Reda-Jürg MESSIKH <rme...@pi...> >>>> Date: 08.05.2012 14:52 >>>> Subject: Re: ojalgo v3.2: quadratic optimization, trouble when running an optimization with "tight" upper bounds for the solution >>>> >>>> >>>> >>>> Now ojAlgo can get the solution in 6s... >>>> >>>> I believe I just found a bug that must have been there for years. Get the latest code from CVS, and see if there are any (other) problems with your use cases. >>>> >>>> /Anders >>>> >>>> [attachment "ojalgo_solution.txt" deleted by Reda-Jürg MESSIKH/GVA/PCO] >>>> >>>> On 8 maj 2012, at 14:15, Reda-Jürg MESSIKH wrote: >>>> >>>>> Hi Anders, >>>>> >>>>> Thanks for your answer. Indeed, 800s is still much longer than matlab. >>>>> >>>>> I will try to use other formulations of the problem and, if time permits, I will check the difference of handling between matlab and ojalgo. >>>>> >>>>> The problem is of Markowitz type, where Q is the covariance matrix and C (all zeros) are the expected returns of the assets. I have two risk linear constraints and an upper bound for the exposure to each asset. >>>>> Is there an easie/ better formulation in ojAlgo of such problems ? >>>>> >>>>> Reda >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> From: "Anders Peterson" <an...@op...> >>>>> >>>>> To: Reda-Jürg MESSIKH <rme...@pi...> >>>>> Date: 08.05.2012 12:24 >>>>> Subject: Re: ojalgo v3.2: quadratic optimization, trouble when running an optimization with "tight" upper bounds for the solution >>>>> >>>>> >>>>> >>>>> Don't have a good/quick solution to this problem... >>>>> >>>>> I have managed to get a solution from ojAlgo that "it" claims to be optimal, but it's not the same solution as you got from Matlab and it took a very long time to get it (800s). >>>>> >>>>> [attachment "ojalgo_solution.txt" deleted by Reda-Jürg MESSIKH/GVA/PCO] >>>>> >>>>> If you want to try the code modifications I made they're in CVS. >>>>> >>>>> Is it possible for you to experiment with other problem formulations? Can you express the constraints in some alternate way? What are you optimizing - what does "Q" express? >>>>> >>>>> BTW: If you have matrices on file / as strings and you're going to put the elements in an ExpressionsBasedModel it's better to create BigDecimals directly from the strings (don't use PrimitiveDenseStore as an intermediate type). If you need some sort of intermediate type use BigDenseStore or Array2D<BigDecimal>. >>>>> >>>>> /Anders >>>>> >>>>> >>>>> On 7 maj 2012, at 19:14, Reda-Jürg MESSIKH wrote: >>>>> >>>>>> Hi Anders, >>>>>> >>>>>> Here is the same stuff but with the matrix hardcoded into the code >>>>>> >>>>>> >>>>>> >>>>>> The matlab solution: >>>>>> >>>>>> >>>>>> >>>>>> Thanks again, >>>>>> Reda >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> From: "Anders Peterson" <an...@op...> >>>>>> >>>>>> To: Reda-Jürg MESSIKH <rme...@pi...> >>>>>> Date: 07.05.2012 13:57 >>>>>> Subject: Re: ojalgo v3.2: quadratic optimization, trouble when running an optimization with "tight" upper bounds for the solution >>>>>> >>>>>> >>>>>> >>>>>> On 7 maj 2012, at 13:19, Anders Peterson wrote: >>>>>> >>>>>>> It would be easier to debug if there was only one problem, can you try to get rid of those NumberFormatException for me? >>>>>> >>>>>> I'm assuming this works for you so the problem is os/jvm specific. Instead trying to hunt down what goes wrong send me code where the matrices are hardcoded. After you've read the files, copy the matrices to PrimitiveMatrix instances and the call toString() on them. The output can be copy-pasted in to your code. >>>>>> >>>>>> /Anders >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> ________________________________________________________________ >>>>>> >>>>>> PAM S.A Geneva Tel. +41 (0)58 323 3333 >>>>>> 60, route des Acacias Fax +41 (0)58 323 2324 >>>>>> CH-1211 GENEVE 73 http://www.pictet.com/ >>>>>> ________________________________________________________________ >>>>>> >>>>>> This document should only be read by those persons to whom it is >>>>>> addressed and is not intended to be relied upon by any person >>>>>> without subsequent written confirmation of its contents. If you >>>>>> have received this e-mail message in error, please destroy it >>>>>> and delete it from your computer. >>>>>> Any form of reproduction, dissemination, copying, disclosure, >>>>>> modification, distribution and/or publication of this E-mail >>>>>> message is strictly prohibited. >>>>>> ________________________________________________________________ >>>>>> >>>>>> Pictet reserves the right to monitor and record business and >>>>>> personal communications. By responding to an email or call from >>>>>> a Pictet employee you are taken to have consented to such >>>>>> monitoring and recording. >>>>>> ________________________________________________________________ >>>>>> >>>>>> >>>>>> <MatrixReader.java><QuadraticDemo.java><matlab_solution.txt> >>>>> >>>>> >>>>> >>>>> ________________________________________________________________ >>>>> >>>>> PAM S.A Geneva Tel. +41 (0)58 323 3333 >>>>> 60, route des Acacias Fax +41 (0)58 323 2324 >>>>> CH-1211 GENEVE 73 http://www.pictet.com/ >>>>> ________________________________________________________________ >>>>> >>>>> This document should only be read by those persons to whom it is >>>>> addressed and is not intended to be relied upon by any person >>>>> without subsequent written confirmation of its contents. If you >>>>> have received this e-mail message in error, please destroy it >>>>> and delete it from your computer. >>>>> Any form of reproduction, dissemination, copying, disclosure, >>>>> modification, distribution and/or publication of this E-mail >>>>> message is strictly prohibited. >>>>> ________________________________________________________________ >>>>> >>>>> Pictet reserves the right to monitor and record business and >>>>> personal communications. By responding to an email or call from >>>>> a Pictet employee you are taken to have consented to such >>>>> monitoring and recording. >>>>> ________________________________________________________________ >>>>> >>>>> >>>> >>>> >>>> >>>> ________________________________________________________________ >>>> >>>> PAM S.A Geneva Tel. +41 (0)58 323 3333 >>>> 60, route des Acacias Fax +41 (0)58 323 2324 >>>> CH-1211 GENEVE 73 http://www.pictet.com/ >>>> ________________________________________________________________ >>>> >>>> This document should only be read by those persons to whom it is >>>> addressed and is not intended to be relied upon by any person >>>> without subsequent written confirmation of its contents. If you >>>> have received this e-mail message in error, please destroy it >>>> and delete it from your computer. >>>> Any form of reproduction, dissemination, copying, disclosure, >>>> modification, distribution and/or publication of this E-mail >>>> message is strictly prohibited. >>>> ________________________________________________________________ >>>> >>>> Pictet reserves the right to monitor and record business and >>>> personal communications. By responding to an email or call from >>>> a Pictet employee you are taken to have consented to such >>>> monitoring and recording. >>>> ________________________________________________________________ >>>> >>>> >>> >>> >>> >>> >>> ________________________________________________________________ >>> >>> PAM S.A Geneva Tel. +41 (0)58 323 3333 >>> 60, route des Acacias Fax +41 (0)58 323 2324 >>> CH-1211 GENEVE 73 http://www.pictet.com/ >>> ________________________________________________________________ >>> >>> This document should only be read by those persons to whom it is >>> addressed and is not intended to be relied upon by any person >>> without subsequent written confirmation of its contents. If you >>> have received this e-mail message in error, please destroy it >>> and delete it from your computer. >>> Any form of reproduction, dissemination, copying, disclosure, >>> modification, distribution and/or publication of this E-mail >>> message is strictly prohibited. >>> ________________________________________________________________ >>> >>> Pictet reserves the right to monitor and record business and >>> personal communications. By responding to an email or call from >>> a Pictet employee you are taken to have consented to such >>> monitoring and recording. >>> ________________________________________________________________ >>> >>> >> >> >> >> >> ________________________________________________________________ >> >> PAM S.A Geneva Tel. +41 (0)58 323 3333 >> 60, route des Acacias Fax +41 (0)58 323 2324 >> CH-1211 GENEVE 73 http://www.pictet.com/ >> ________________________________________________________________ >> >> This document should only be read by those persons to whom it is >> addressed and is not intended to be relied upon by any person >> without subsequent written confirmation of its contents. If you >> have received this e-mail message in error, please destroy it >> and delete it from your computer. >> Any form of reproduction, dissemination, copying, disclosure, >> modification, distribution and/or publication of this E-mail >> message is strictly prohibited. >> ________________________________________________________________ >> >> Pictet reserves the right to monitor and record business and >> personal communications. By responding to an email or call from >> a Pictet employee you are taken to have consented to such >> monitoring and recording. >> ________________________________________________________________ >> >> >> <Q.txt><C.txt><BE.txt><AE.txt><AI.txt><BI.txt> > |