ojalgo-user Mailing List for oj! Algorithms (Page 10)
Mathematics, linear algebra and optimisation
Brought to you by:
apete
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
|
Feb
(1) |
Mar
|
Apr
(14) |
May
(1) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
(1) |
2005 |
Jan
(3) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
(1) |
Sep
(3) |
Oct
|
Nov
|
Dec
(1) |
2006 |
Jan
(1) |
Feb
(1) |
Mar
(1) |
Apr
|
May
(1) |
Jun
(2) |
Jul
|
Aug
(5) |
Sep
|
Oct
(3) |
Nov
(4) |
Dec
(2) |
2007 |
Jan
(8) |
Feb
(1) |
Mar
(2) |
Apr
(11) |
May
(6) |
Jun
|
Jul
(10) |
Aug
(2) |
Sep
|
Oct
(4) |
Nov
|
Dec
(11) |
2008 |
Jan
(22) |
Feb
(4) |
Mar
(2) |
Apr
(4) |
May
(2) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(6) |
Nov
(17) |
Dec
(5) |
2009 |
Jan
(15) |
Feb
(2) |
Mar
(2) |
Apr
(3) |
May
(4) |
Jun
(5) |
Jul
(9) |
Aug
(2) |
Sep
|
Oct
(5) |
Nov
(14) |
Dec
|
2010 |
Jan
(3) |
Feb
(5) |
Mar
(2) |
Apr
(19) |
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
(5) |
Nov
(3) |
Dec
|
2011 |
Jan
|
Feb
(1) |
Mar
(7) |
Apr
(10) |
May
(1) |
Jun
(15) |
Jul
(1) |
Aug
|
Sep
|
Oct
(13) |
Nov
(9) |
Dec
(11) |
2012 |
Jan
|
Feb
(1) |
Mar
(9) |
Apr
(23) |
May
(16) |
Jun
(9) |
Jul
(13) |
Aug
|
Sep
(4) |
Oct
(1) |
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
(12) |
Mar
(7) |
Apr
(24) |
May
|
Jun
(7) |
Jul
(4) |
Aug
|
Sep
(3) |
Oct
(16) |
Nov
(7) |
Dec
(3) |
2014 |
Jan
(22) |
Feb
(1) |
Mar
(1) |
Apr
|
May
(2) |
Jun
(3) |
Jul
(4) |
Aug
(4) |
Sep
(1) |
Oct
(2) |
Nov
(6) |
Dec
(2) |
2015 |
Jan
(11) |
Feb
(10) |
Mar
(1) |
Apr
(9) |
May
|
Jun
|
Jul
(1) |
Aug
(4) |
Sep
(6) |
Oct
(3) |
Nov
(15) |
Dec
(4) |
2016 |
Jan
(6) |
Feb
|
Mar
(18) |
Apr
(5) |
May
(9) |
Jun
(3) |
Jul
(5) |
Aug
(2) |
Sep
(5) |
Oct
(2) |
Nov
|
Dec
(5) |
2017 |
Jan
(4) |
Feb
(3) |
Mar
|
Apr
|
May
(12) |
Jun
(1) |
Jul
(4) |
Aug
|
Sep
(3) |
Oct
(1) |
Nov
|
Dec
(1) |
2018 |
Jan
(5) |
Feb
|
Mar
(1) |
Apr
(1) |
May
(1) |
Jun
|
Jul
(4) |
Aug
(1) |
Sep
(8) |
Oct
|
Nov
|
Dec
(1) |
2019 |
Jan
|
Feb
(2) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Anthony E. <ant...@al...> - 2013-12-03 08:48:08
|
Thanks Sent from my iPhone > On 3 Dec 2013, at 08:35, Anders Peterson <an...@op...> wrote: > > Yes you can. That's precisely what that method does. > > Either (but not both) of the limits may be null. > > The indices are consistent with with the order of the assets when specifying returns, covariances, weights or whatever... > > /Anders > > >> On 2 dec 2013, at 08:24, Anthony Edwards <ant...@al...> wrote: >> >> Hi Anders >> >> Can we add constraints to the Markowitz class such that the sum of the >> weights for a few of the assets can be constrained to lie with an upper and >> lower limit (so we can limit the models exposure on a sector basis)? >> >> The javadoc has an addConstraint(lowerlimit, upperlimit, .... indices) but >> i'm not sure how to use this to achieve whet we need. >> >> Thanks again for your help >> >> Tony >> >> -----Original Message----- >>> From: Anders Peterson >> Sent: Wednesday, November 06, 2013 7:02 PM >> To: ojAlgo ojAlgo >> Subject: Re: [ojAlgo-user] MarkowitzModel and Long/Short strategies >> >> Not with the MarkowitzModel class. You'd have to implement your own model >> using ExpressionsBasedModel. >> >> http://ojalgo.org/generated/org/ojalgo/optimisation/ExpressionsBasedModel.html >> >> /Andes >> >> >> On 5 nov 2013, at 18:18, Anthony Edwards >> <ant...@al...> wrote: >> >>> Hi >>> >>> Is there a way to add a constraint such that the sum of the absolute >>> values of the weights cannot exceed a specified value? >>> >>> I know i can set an upper and lower bound on each weight, but can I >>> control the sum of the absolute value of the weights? >>> >>> Thanks >>> >>> Tony >>> ------------------------------------------------------------------------------ >>> November Webinars for C, C++, Fortran Developers >>> Accelerate application performance with scalable programming models. >>> Explore >>> techniques for threading, error checking, porting, and tuning. Get the >>> most >>> from the latest Intel processors and coprocessors. See abstracts and >>> register >>> http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk_______________________________________________ >>> ojAlgo-user mailing list >>> ojA...@li... >>> https://lists.sourceforge.net/lists/listinfo/ojalgo-user >> >> >> ------------------------------------------------------------------------------ >> November Webinars for C, C++, Fortran Developers >> Accelerate application performance with scalable programming models. Explore >> techniques for threading, error checking, porting, and tuning. Get the most >> from the latest Intel processors and coprocessors. See abstracts and >> register >> http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk >> _______________________________________________ >> ojAlgo-user mailing list >> ojA...@li... >> https://lists.sourceforge.net/lists/listinfo/ojalgo-user >> >> >> ------------------------------------------------------------------------------ >> Rapidly troubleshoot problems before they affect your business. Most IT >> organizations don't have a clear picture of how application performance >> affects their revenue. With AppDynamics, you get 100% visibility into your >> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! >> http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk >> _______________________________________________ >> ojAlgo-user mailing list >> ojA...@li... >> https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > > ------------------------------------------------------------------------------ > Rapidly troubleshoot problems before they affect your business. Most IT > organizations don't have a clear picture of how application performance > affects their revenue. With AppDynamics, you get 100% visibility into your > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! > http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Anders P. <an...@op...> - 2013-12-03 08:36:07
|
Yes you can. That's precisely what that method does. Either (but not both) of the limits may be null. The indices are consistent with with the order of the assets when specifying returns, covariances, weights or whatever... /Anders On 2 dec 2013, at 08:24, Anthony Edwards <ant...@al...> wrote: > Hi Anders > > Can we add constraints to the Markowitz class such that the sum of the > weights for a few of the assets can be constrained to lie with an upper and > lower limit (so we can limit the models exposure on a sector basis)? > > The javadoc has an addConstraint(lowerlimit, upperlimit, .... indices) but > i'm not sure how to use this to achieve whet we need. > > Thanks again for your help > > Tony > > -----Original Message----- >> From: Anders Peterson > Sent: Wednesday, November 06, 2013 7:02 PM > To: ojAlgo ojAlgo > Subject: Re: [ojAlgo-user] MarkowitzModel and Long/Short strategies > > Not with the MarkowitzModel class. You'd have to implement your own model > using ExpressionsBasedModel. > > http://ojalgo.org/generated/org/ojalgo/optimisation/ExpressionsBasedModel.html > > /Andes > > > On 5 nov 2013, at 18:18, Anthony Edwards > <ant...@al...> wrote: > >> Hi >> >> Is there a way to add a constraint such that the sum of the absolute >> values of the weights cannot exceed a specified value? >> >> I know i can set an upper and lower bound on each weight, but can I >> control the sum of the absolute value of the weights? >> >> Thanks >> >> Tony >> ------------------------------------------------------------------------------ >> November Webinars for C, C++, Fortran Developers >> Accelerate application performance with scalable programming models. >> Explore >> techniques for threading, error checking, porting, and tuning. Get the >> most >> from the latest Intel processors and coprocessors. See abstracts and >> register >> http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk_______________________________________________ >> ojAlgo-user mailing list >> ojA...@li... >> https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > > ------------------------------------------------------------------------------ > November Webinars for C, C++, Fortran Developers > Accelerate application performance with scalable programming models. Explore > techniques for threading, error checking, porting, and tuning. Get the most > from the latest Intel processors and coprocessors. See abstracts and > register > http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > > ------------------------------------------------------------------------------ > Rapidly troubleshoot problems before they affect your business. Most IT > organizations don't have a clear picture of how application performance > affects their revenue. With AppDynamics, you get 100% visibility into your > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! > http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > |
From: Anthony E. <ant...@al...> - 2013-12-02 07:24:15
|
Hi Anders Can we add constraints to the Markowitz class such that the sum of the weights for a few of the assets can be constrained to lie with an upper and lower limit (so we can limit the models exposure on a sector basis)? The javadoc has an addConstraint(lowerlimit, upperlimit, .... indices) but i'm not sure how to use this to achieve whet we need. Thanks again for your help Tony -----Original Message----- From: Anders Peterson Sent: Wednesday, November 06, 2013 7:02 PM To: ojAlgo ojAlgo Subject: Re: [ojAlgo-user] MarkowitzModel and Long/Short strategies Not with the MarkowitzModel class. You'd have to implement your own model using ExpressionsBasedModel. http://ojalgo.org/generated/org/ojalgo/optimisation/ExpressionsBasedModel.html /Andes On 5 nov 2013, at 18:18, Anthony Edwards <ant...@al...> wrote: > Hi > > Is there a way to add a constraint such that the sum of the absolute > values of the weights cannot exceed a specified value? > > I know i can set an upper and lower bound on each weight, but can I > control the sum of the absolute value of the weights? > > Thanks > > Tony > ------------------------------------------------------------------------------ > November Webinars for C, C++, Fortran Developers > Accelerate application performance with scalable programming models. > Explore > techniques for threading, error checking, porting, and tuning. Get the > most > from the latest Intel processors and coprocessors. See abstracts and > register > http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk_______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user ------------------------------------------------------------------------------ November Webinars for C, C++, Fortran Developers Accelerate application performance with scalable programming models. Explore techniques for threading, error checking, porting, and tuning. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk _______________________________________________ ojAlgo-user mailing list ojA...@li... https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Anders P. <an...@op...> - 2013-11-26 06:04:37
|
final Eigenvalue<ComplexNumber> tmpEvD = EigenvalueDecomposition.makeComplex(true); tmpEvD.compute(tmpA); final MatrixStore<ComplexNumber> tmpV = tmpEvD.getV(); http://ojalgo.org/generated/org/ojalgo/matrix/decomposition/Eigenvalue.html According to the docs you cannot trust that the eigenvalues are ordered (descending) when you extract the matrices, but the matrices D and V do of course match. /Anders On 26 nov 2013, at 05:06, Kieran Bjergstrom <kn...@ch...> wrote: > Dear All, > > I'm am attempting to use ojAlgo to find the eigendecomposition of > complex hermitian matrices with corresponding eigenvectors; acquiring > the eigenvalues has been trivial, however I am unsure as to how to find > the eigenvectors. > > From what I can see EigenvalueDecomposition has methods getD and getV, > which I expect would provide the eigenvalues with and corresponding > eigenvectors, however this requires explicitly instantiating > EigenvalueDecomposition - something which I don't understand how to do. > > As it stands, I have the following test code: > > ----- > //saves a bit of space > static ComplexNumber c(double a, double b){ > ComplexNumber z = new ComplexNumber(a,b); > return z; > } > > public static void main(String[] args) { > final ComplexNumber[][] tmpData = {{c(1),c(1,-1)},{c(1,1),c(-1)}}; > ComplexMatrix tmpA = tmpFactory.rows(tmpData); > List<ComplexNumber> s = tmpA.getEigenvalues(); > } > > ----- > > Which finds the Eigenvalues. How would one proceed to find the > eigenvectors for the ComplexMatrix tmpA, and are these eigenvectors, in > general, ordered to correlate with the eigenvalues? If possible I would > appreciate a concrete piece of code, as I haven't been able to gleam > further understanding from the javadocs. > > Thanks, > Kieran > > ------------------------------------------------------------------------------ > Shape the Mobile Experience: Free Subscription > Software experts and developers: Be at the forefront of tech innovation. > Intel(R) Software Adrenaline delivers strategic insight and game-changing > conversations that shape the rapidly evolving mobile landscape. Sign up now. > http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > |
From: Kieran B. <kn...@ch...> - 2013-11-26 04:21:43
|
Dear All, I'm am attempting to use ojAlgo to find the eigendecomposition of complex hermitian matrices with corresponding eigenvectors; acquiring the eigenvalues has been trivial, however I am unsure as to how to find the eigenvectors. From what I can see EigenvalueDecomposition has methods getD and getV, which I expect would provide the eigenvalues with and corresponding eigenvectors, however this requires explicitly instantiating EigenvalueDecomposition - something which I don't understand how to do. As it stands, I have the following test code: ----- //saves a bit of space static ComplexNumber c(double a, double b){ ComplexNumber z = new ComplexNumber(a,b); return z; } public static void main(String[] args) { final ComplexNumber[][] tmpData = {{c(1),c(1,-1)},{c(1,1),c(-1)}}; ComplexMatrix tmpA = tmpFactory.rows(tmpData); List<ComplexNumber> s = tmpA.getEigenvalues(); } ----- Which finds the Eigenvalues. How would one proceed to find the eigenvectors for the ComplexMatrix tmpA, and are these eigenvectors, in general, ordered to correlate with the eigenvalues? If possible I would appreciate a concrete piece of code, as I haven't been able to gleam further understanding from the javadocs. Thanks, Kieran |
From: Anders P. <an...@op...> - 2013-11-06 19:02:37
|
Not with the MarkowitzModel class. You'd have to implement your own model using ExpressionsBasedModel. http://ojalgo.org/generated/org/ojalgo/optimisation/ExpressionsBasedModel.html /Andes On 5 nov 2013, at 18:18, Anthony Edwards <ant...@al...> wrote: > Hi > > Is there a way to add a constraint such that the sum of the absolute values of the weights cannot exceed a specified value? > > I know i can set an upper and lower bound on each weight, but can I control the sum of the absolute value of the weights? > > Thanks > > Tony > ------------------------------------------------------------------------------ > November Webinars for C, C++, Fortran Developers > Accelerate application performance with scalable programming models. Explore > techniques for threading, error checking, porting, and tuning. Get the most > from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk_______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Anthony E. <ant...@al...> - 2013-11-05 17:17:47
|
Hi Is there a way to add a constraint such that the sum of the absolute values of the weights cannot exceed a specified value? I know i can set an upper and lower bound on each weight, but can I control the sum of the absolute value of the weights? Thanks Tony |
From: Zahar C. <no...@ma...> - 2013-11-04 22:34:54
|
Hi Anders, At the end as you proposed I compiled LP_Solve for Android and it works quite well. The small problem is solved in 0.0s (no typo) and the big one with limitation of 30 is solved in 2.1s. This is good for my needs, I will stick with it. Thank you very much for your support. Regards, Zahar On 11/4/2013 11:28 PM, Anders Peterson wrote: > Looked briefly at your model. Nor sure what you're modeling, but I didn't see any obvious problem. > > When I ran that SimpleTest as you packaged it (masteries_mip3.txt) I got several exceptions like this one: > > Caused by: java.lang.IllegalArgumentException: ValidationException: 2 <= a4: 1.5 <= 1 The lower limit (if it exists) must be smaller than or equal to the upper limit (if it exists)! > at org.ojalgo.optimisation.ExpressionsBasedModel.getDefaultSolver(ExpressionsBasedModel.java:331) > at org.ojalgo.optimisation.integer.IntegerSolver.solve(IntegerSolver.java:66) > > The solver did finish, but I wouldn't trust the results after those exceptions. Switching to the latest version of ojAlgo they disappeared. (No code changes necessary to switch versions.) > > The larger model takes less than 5s. > > /Anders > > > > On 2 nov 2013, at 02:02, Zahar Chikishev <no...@ma...> wrote: > >> Hi Anders, >> >> I have created a self contained test case of my MIP problem. You can find the test project attached to this mail. >> Input file "masteries_mip1.txt" is the small problem (34 variables) and file "masteries_mip3.txt" is the full problem (110 variables). >> >> Below is the list of my observations >> >> 1. The small problem takes 20s on Android Samsung Galaxy S2 and only 0.38s on my notebook with processor i7-3740QM. This is on version 33. I am not sure that the disparity can be assigned purely to the processors calculation power difference... >> >> 2. The small problem takes approximately the same time on v33 and v34.8 on the notebook (0.38s against 0.42s). >> >> 3. The full problem fails on v33 and finishes in 1.66s on v34.8 on the notebook. However changing the constraint "maxc" upper limit from 23 to 30 increases the time to around 90s (30 is the real value and 23 was for tests). This last test shows that even in the optimal environment (notebook + v34.8) my full problem takes too much time. >> >> I think I will switch my attention to alternative 2... but first of all I will check that my problem can be solved fast at least on cplex. >> >> Anders, if you have some spare time, could you please check the attached project. It might be that I have misused ojAlgo in some way. >> >> Thanks, >> Zahar >> >> >> On 10/31/2013 4:00 PM, Anders Peterson wrote: >>> I'd be interested in seeing what the performance difference between v33 and the current/latest version is for your problem. Do you have a (self contained) test case that I can try? >>> >>> Alt. 1 (ojAlgo) >>> >>> Test your problem on a desktop computer using ojAlgo v33 AND v34.8 to see if the improvements in any way make it a feasible alternative. >>> >>> I believe the fork-join-framework existed as a separate download before java 7 was released. Maybe you can use that. Alternatively maybe you can fake the api entirely and just execute everything sequentially (simplest possible implementation). ..or fake the api delegating to the v33 version of the org.ojalgo.concurrent package. >>> >>> There are still improvements to be made regarding how each lp-node is started, and probably other things as well. >>> >>> >>> Alt. 2 (native) >>> >>> I have no experience here, but I've seen other people do interesting things with mixing in native code. The threshold for when it's advantageous (performance) to switch to native code seems to have come down lately. How many native platforms would have to support? If it's just 1 I would try this alternative. >>> >>> http://lpsolve.sourceforge.net/5.5/Java/README.html >>> >>> >>> /Anders >>> >>> >>> >>> On 31 okt 2013, at 11:52, Zahar Chikishev <no...@ma...> wrote: >>> >>>> Hi Anders, >>>> >>>> Excuse me for writing in a new thread, I haven't got your reply in a mail but can see it on sourceforge. For convenience, I am pasting my original mail with your reply at the end of this letter. >>>> >>>> Thank you for the CVS link, I was able to reach the source code. I used "v33" branch for my tests. >>>> >>>> MIP solver required java.lang.management API, and it is not present in Android, so I removed the corresponding function call in file VirtualMachine.java. >>>> >>>> After that I successfully modeled and run my MIP problem in my Android app. The results are as expected, but the performance is low. My test problem took 20 seconds to run (Samsung Galaxy S2, physical device) and it is only a third of my full-size problem. The full-size problem did not finish in 30 minutes. So it looks like my problem is not that small. The problem that took 20 seconds was around 50 integer variables and 150 constraints. Unfortunately, it is not useful for me. I need at least 20 times faster. >>>> >>>> However, I was happy that I was able run MIP on Android at all. I searched a lot for how to do it, and there are only a few options available. Pure java solver is the best way, but ojAlgo is the only pure java MIP solver I have found. The second way is to compile some open-source C/C++ libraries with JNI (like GLPK or lp_solve), but this has its own problems, and I can't find testimonies of anyone who has actually done that. >>>> >>>> Please tell me if you have any words of advice for my situation. >>>> >>>> Thanks a lot, >>>> Zahar >>>> >>>> >>>> >>>> -------------------------------------------------------------------------------------------------------------------------- >>>> >>>> Re: [ojAlgo-user] ojAlgo v34 on Android >>>> From: Anders Peterson <anders@op...> - 2013-10-28 18:20:53 >>>> The source code is definitely available. Where did you get that link? >>>> >>>> ojAlgo uses CVS, not SVN: >>>> >>>> >>>> https://sourceforge.net/p/ojalgo/code/ >>>> >>>> >>>> v34 cannot be compiled using java 5 or 6 without re-coding. One of the things that changed with v34 is the use of the fork-join framework (ForkJoinPool and ForkJoinTask). The MIP solver is (now) highly integrated with these classes - that redesign was part of the improvements that came with v34. >>>> >>>> Java 6 was never a target. Switching back to Java 5 should be roughly the same amount of work. >>>> >>>> My guess is that you'll find this to be too much work... >>>> >>>> /Anders >>>> >>>> >>>> On 28 okt 2013, at 18:10, Zahar Chikishev >>>> <nosound@...> >>>> wrote: >>>> >>>>> Hello, >>>>> >>>>> I wish to use ojAlgo to solve small MIP problems in my Android >>>>> application. The problem is that Android does not support Java 7 >>>>> compiled libraries. Version 33 of ojAlgo seems to work OK in my app, but >>>>> I prefer to use 34 since, as far as I understand, it includes major >>>>> improvements to MIP solver. >>>>> >>>>> So my question is, can version 34 be compiled on java 5 or 6? It is OK >>>>> if some functionality is lost, as long as simple MIP problems can be >>>>> solved. I tried to do it myself, but can't access the source code. I >>>>> understand that the following is SVN link: >>>>> >>>> https://ojalgo.svn.sourceforge.net/svnroot/ojalgo/ >>>> >>>>> but it gives errors. >>>>> >>>>> So my second question is how I can access the source code. Is it still >>>>> available? >>>>> >>>>> Thanks, >>>>> Zahar >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> October Webinars: Code for Performance >>>>> Free Intel webinars can help you accelerate application performance. >>>>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from >>>>> the latest Intel processors and coprocessors. See abstracts and register > >>>>> >>>> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk >>>> >>>>> _______________________________________________ >>>>> ojAlgo-user mailing list >>>>> ojAlgo-user@... >>>>> >>>> https://lists.sourceforge.net/lists/listinfo/ojalgo-user >>>> >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Android is increasing in popularity, but the open development platform that >>>> developers love is also attractive to malware creators. Download this white >>>> paper to learn more about secure code signing practices that can help keep >>>> Android apps secure. >>>> http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk_______________________________________________ >>>> ojAlgo-user mailing list >>>> ojA...@li... >>>> https://lists.sourceforge.net/lists/listinfo/ojalgo-user >>> ------------------------------------------------------------------------------ >>> Android is increasing in popularity, but the open development platform that >>> developers love is also attractive to malware creators. Download this white >>> paper to learn more about secure code signing practices that can help keep >>> Android apps secure. >>> http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk >>> _______________________________________________ >>> ojAlgo-user mailing list >>> ojA...@li... >>> https://lists.sourceforge.net/lists/listinfo/ojalgo-user >> <SimpleTest.rar>------------------------------------------------------------------------------ >> Android is increasing in popularity, but the open development platform that >> developers love is also attractive to malware creators. Download this white >> paper to learn more about secure code signing practices that can help keep >> Android apps secure. >> http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk_______________________________________________ >> ojAlgo-user mailing list >> ojA...@li... >> https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > ------------------------------------------------------------------------------ > Android is increasing in popularity, but the open development platform that > developers love is also attractive to malware creators. Download this white > paper to learn more about secure code signing practices that can help keep > Android apps secure. > http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Anders P. <an...@op...> - 2013-11-04 21:28:46
|
Looked briefly at your model. Nor sure what you're modeling, but I didn't see any obvious problem. When I ran that SimpleTest as you packaged it (masteries_mip3.txt) I got several exceptions like this one: Caused by: java.lang.IllegalArgumentException: ValidationException: 2 <= a4: 1.5 <= 1 The lower limit (if it exists) must be smaller than or equal to the upper limit (if it exists)! at org.ojalgo.optimisation.ExpressionsBasedModel.getDefaultSolver(ExpressionsBasedModel.java:331) at org.ojalgo.optimisation.integer.IntegerSolver.solve(IntegerSolver.java:66) The solver did finish, but I wouldn't trust the results after those exceptions. Switching to the latest version of ojAlgo they disappeared. (No code changes necessary to switch versions.) The larger model takes less than 5s. /Anders On 2 nov 2013, at 02:02, Zahar Chikishev <no...@ma...> wrote: > Hi Anders, > > I have created a self contained test case of my MIP problem. You can find the test project attached to this mail. > Input file "masteries_mip1.txt" is the small problem (34 variables) and file "masteries_mip3.txt" is the full problem (110 variables). > > Below is the list of my observations > > 1. The small problem takes 20s on Android Samsung Galaxy S2 and only 0.38s on my notebook with processor i7-3740QM. This is on version 33. I am not sure that the disparity can be assigned purely to the processors calculation power difference... > > 2. The small problem takes approximately the same time on v33 and v34.8 on the notebook (0.38s against 0.42s). > > 3. The full problem fails on v33 and finishes in 1.66s on v34.8 on the notebook. However changing the constraint "maxc" upper limit from 23 to 30 increases the time to around 90s (30 is the real value and 23 was for tests). This last test shows that even in the optimal environment (notebook + v34.8) my full problem takes too much time. > > I think I will switch my attention to alternative 2... but first of all I will check that my problem can be solved fast at least on cplex. > > Anders, if you have some spare time, could you please check the attached project. It might be that I have misused ojAlgo in some way. > > Thanks, > Zahar > > > On 10/31/2013 4:00 PM, Anders Peterson wrote: >> I'd be interested in seeing what the performance difference between v33 and the current/latest version is for your problem. Do you have a (self contained) test case that I can try? >> >> Alt. 1 (ojAlgo) >> >> Test your problem on a desktop computer using ojAlgo v33 AND v34.8 to see if the improvements in any way make it a feasible alternative. >> >> I believe the fork-join-framework existed as a separate download before java 7 was released. Maybe you can use that. Alternatively maybe you can fake the api entirely and just execute everything sequentially (simplest possible implementation). ..or fake the api delegating to the v33 version of the org.ojalgo.concurrent package. >> >> There are still improvements to be made regarding how each lp-node is started, and probably other things as well. >> >> >> Alt. 2 (native) >> >> I have no experience here, but I've seen other people do interesting things with mixing in native code. The threshold for when it's advantageous (performance) to switch to native code seems to have come down lately. How many native platforms would have to support? If it's just 1 I would try this alternative. >> >> http://lpsolve.sourceforge.net/5.5/Java/README.html >> >> >> /Anders >> >> >> >> On 31 okt 2013, at 11:52, Zahar Chikishev <no...@ma...> wrote: >> >>> Hi Anders, >>> >>> Excuse me for writing in a new thread, I haven't got your reply in a mail but can see it on sourceforge. For convenience, I am pasting my original mail with your reply at the end of this letter. >>> >>> Thank you for the CVS link, I was able to reach the source code. I used "v33" branch for my tests. >>> >>> MIP solver required java.lang.management API, and it is not present in Android, so I removed the corresponding function call in file VirtualMachine.java. >>> >>> After that I successfully modeled and run my MIP problem in my Android app. The results are as expected, but the performance is low. My test problem took 20 seconds to run (Samsung Galaxy S2, physical device) and it is only a third of my full-size problem. The full-size problem did not finish in 30 minutes. So it looks like my problem is not that small. The problem that took 20 seconds was around 50 integer variables and 150 constraints. Unfortunately, it is not useful for me. I need at least 20 times faster. >>> >>> However, I was happy that I was able run MIP on Android at all. I searched a lot for how to do it, and there are only a few options available. Pure java solver is the best way, but ojAlgo is the only pure java MIP solver I have found. The second way is to compile some open-source C/C++ libraries with JNI (like GLPK or lp_solve), but this has its own problems, and I can't find testimonies of anyone who has actually done that. >>> >>> Please tell me if you have any words of advice for my situation. >>> >>> Thanks a lot, >>> Zahar >>> >>> >>> >>> -------------------------------------------------------------------------------------------------------------------------- >>> >>> Re: [ojAlgo-user] ojAlgo v34 on Android >>> From: Anders Peterson <anders@op...> - 2013-10-28 18:20:53 >>> The source code is definitely available. Where did you get that link? >>> >>> ojAlgo uses CVS, not SVN: >>> >>> >>> https://sourceforge.net/p/ojalgo/code/ >>> >>> >>> v34 cannot be compiled using java 5 or 6 without re-coding. One of the things that changed with v34 is the use of the fork-join framework (ForkJoinPool and ForkJoinTask). The MIP solver is (now) highly integrated with these classes - that redesign was part of the improvements that came with v34. >>> >>> Java 6 was never a target. Switching back to Java 5 should be roughly the same amount of work. >>> >>> My guess is that you'll find this to be too much work... >>> >>> /Anders >>> >>> >>> On 28 okt 2013, at 18:10, Zahar Chikishev >>> <nosound@...> >>> wrote: >>> >>>> Hello, >>>> >>>> I wish to use ojAlgo to solve small MIP problems in my Android >>>> application. The problem is that Android does not support Java 7 >>>> compiled libraries. Version 33 of ojAlgo seems to work OK in my app, but >>>> I prefer to use 34 since, as far as I understand, it includes major >>>> improvements to MIP solver. >>>> >>>> So my question is, can version 34 be compiled on java 5 or 6? It is OK >>>> if some functionality is lost, as long as simple MIP problems can be >>>> solved. I tried to do it myself, but can't access the source code. I >>>> understand that the following is SVN link: >>>> >>> https://ojalgo.svn.sourceforge.net/svnroot/ojalgo/ >>> >>>> but it gives errors. >>>> >>>> So my second question is how I can access the source code. Is it still >>>> available? >>>> >>>> Thanks, >>>> Zahar >>>> >>>> ------------------------------------------------------------------------------ >>>> October Webinars: Code for Performance >>>> Free Intel webinars can help you accelerate application performance. >>>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from >>>> the latest Intel processors and coprocessors. See abstracts and register > >>>> >>> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk >>> >>>> _______________________________________________ >>>> ojAlgo-user mailing list >>>> ojAlgo-user@... >>>> >>> https://lists.sourceforge.net/lists/listinfo/ojalgo-user >>> >>>> >>> >>> >>> >>> ------------------------------------------------------------------------------ >>> Android is increasing in popularity, but the open development platform that >>> developers love is also attractive to malware creators. Download this white >>> paper to learn more about secure code signing practices that can help keep >>> Android apps secure. >>> http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk_______________________________________________ >>> ojAlgo-user mailing list >>> ojA...@li... >>> https://lists.sourceforge.net/lists/listinfo/ojalgo-user >> >> ------------------------------------------------------------------------------ >> Android is increasing in popularity, but the open development platform that >> developers love is also attractive to malware creators. Download this white >> paper to learn more about secure code signing practices that can help keep >> Android apps secure. >> http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk >> _______________________________________________ >> ojAlgo-user mailing list >> ojA...@li... >> https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > <SimpleTest.rar>------------------------------------------------------------------------------ > Android is increasing in popularity, but the open development platform that > developers love is also attractive to malware creators. Download this white > paper to learn more about secure code signing practices that can help keep > Android apps secure. > http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk_______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Zahar C. <no...@ma...> - 2013-11-02 01:07:25
|
Hi Anders, I have created a self contained test case of my MIP problem. You can find the test project attached to this mail. Input file "masteries_mip1.txt" is the small problem (34 variables) and file "masteries_mip3.txt" is the full problem (110 variables). Below is the list of my observations 1. The small problem takes 20s on Android Samsung Galaxy S2 and only 0.38s on my notebook with processor i7-3740QM. This is on version 33. I am not sure that the disparity can be assigned purely to the processors calculation power difference... 2. The small problem takes approximately the same time on v33 and v34.8 on the notebook (0.38s against 0.42s). 3. The full problem fails on v33 and finishes in 1.66s on v34.8 on the notebook. However changing the constraint "maxc" upper limit from 23 to 30 increases the time to around 90s (30 is the real value and 23 was for tests). This last test shows that even in the optimal environment (notebook + v34.8) my full problem takes too much time. I think I will switch my attention to alternative 2... but first of all I will check that my problem can be solved fast at least on cplex. Anders, if you have some spare time, could you please check the attached project. It might be that I have misused ojAlgo in some way. Thanks, Zahar On 10/31/2013 4:00 PM, Anders Peterson wrote: > I'd be interested in seeing what the performance difference between v33 and the current/latest version is for your problem. Do you have a (self contained) test case that I can try? > > Alt. 1 (ojAlgo) > > Test your problem on a desktop computer using ojAlgo v33 AND v34.8 to see if the improvements in any way make it a feasible alternative. > > I believe the fork-join-framework existed as a separate download before java 7 was released. Maybe you can use that. Alternatively maybe you can fake the api entirely and just execute everything sequentially (simplest possible implementation). ..or fake the api delegating to the v33 version of the org.ojalgo.concurrent package. > > There are still improvements to be made regarding how each lp-node is started, and probably other things as well. > > > Alt. 2 (native) > > I have no experience here, but I've seen other people do interesting things with mixing in native code. The threshold for when it's advantageous (performance) to switch to native code seems to have come down lately. How many native platforms would have to support? If it's just 1 I would try this alternative. > > http://lpsolve.sourceforge.net/5.5/Java/README.html > > > /Anders > > > > On 31 okt 2013, at 11:52, Zahar Chikishev <no...@ma...> wrote: > >> Hi Anders, >> >> Excuse me for writing in a new thread, I haven't got your reply in a mail but can see it on sourceforge. For convenience, I am pasting my original mail with your reply at the end of this letter. >> >> Thank you for the CVS link, I was able to reach the source code. I used "v33" branch for my tests. >> >> MIP solver required java.lang.management API, and it is not present in Android, so I removed the corresponding function call in file VirtualMachine.java. >> >> After that I successfully modeled and run my MIP problem in my Android app. The results are as expected, but the performance is low. My test problem took 20 seconds to run (Samsung Galaxy S2, physical device) and it is only a third of my full-size problem. The full-size problem did not finish in 30 minutes. So it looks like my problem is not that small. The problem that took 20 seconds was around 50 integer variables and 150 constraints. Unfortunately, it is not useful for me. I need at least 20 times faster. >> >> However, I was happy that I was able run MIP on Android at all. I searched a lot for how to do it, and there are only a few options available. Pure java solver is the best way, but ojAlgo is the only pure java MIP solver I have found. The second way is to compile some open-source C/C++ libraries with JNI (like GLPK or lp_solve), but this has its own problems, and I can't find testimonies of anyone who has actually done that. >> >> Please tell me if you have any words of advice for my situation. >> >> Thanks a lot, >> Zahar >> >> >> >> -------------------------------------------------------------------------------------------------------------------------- >> >> Re: [ojAlgo-user] ojAlgo v34 on Android >> From: Anders Peterson <anders@op...> - 2013-10-28 18:20:53 >> >> The source code is definitely available. Where did you get that link? >> >> ojAlgo uses CVS, not SVN: >> >> >> https://sourceforge.net/p/ojalgo/code/ >> >> >> v34 cannot be compiled using java 5 or 6 without re-coding. One of the things that changed with v34 is the use of the fork-join framework (ForkJoinPool and ForkJoinTask). The MIP solver is (now) highly integrated with these classes - that redesign was part of the improvements that came with v34. >> >> Java 6 was never a target. Switching back to Java 5 should be roughly the same amount of work. >> >> My guess is that you'll find this to be too much work... >> >> /Anders >> >> >> On 28 okt 2013, at 18:10, Zahar Chikishev >> <nosound@...> >> wrote: >> >>> Hello, >>> >>> I wish to use ojAlgo to solve small MIP problems in my Android >>> application. The problem is that Android does not support Java 7 >>> compiled libraries. Version 33 of ojAlgo seems to work OK in my app, but >>> I prefer to use 34 since, as far as I understand, it includes major >>> improvements to MIP solver. >>> >>> So my question is, can version 34 be compiled on java 5 or 6? It is OK >>> if some functionality is lost, as long as simple MIP problems can be >>> solved. I tried to do it myself, but can't access the source code. I >>> understand that the following is SVN link: >>> >> https://ojalgo.svn.sourceforge.net/svnroot/ojalgo/ >> >>> but it gives errors. >>> >>> So my second question is how I can access the source code. Is it still >>> available? >>> >>> Thanks, >>> Zahar >>> >>> ------------------------------------------------------------------------------ >>> October Webinars: Code for Performance >>> Free Intel webinars can help you accelerate application performance. >>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from >>> the latest Intel processors and coprocessors. See abstracts and register > >>> >> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk >> >>> _______________________________________________ >>> ojAlgo-user mailing list >>> ojAlgo-user@... >>> >> https://lists.sourceforge.net/lists/listinfo/ojalgo-user >> >>> >> >> >> >> ------------------------------------------------------------------------------ >> Android is increasing in popularity, but the open development platform that >> developers love is also attractive to malware creators. Download this white >> paper to learn more about secure code signing practices that can help keep >> Android apps secure. >> http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk_______________________________________________ >> ojAlgo-user mailing list >> ojA...@li... >> https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > ------------------------------------------------------------------------------ > Android is increasing in popularity, but the open development platform that > developers love is also attractive to malware creators. Download this white > paper to learn more about secure code signing practices that can help keep > Android apps secure. > http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Anders P. <an...@op...> - 2013-10-31 14:00:52
|
I'd be interested in seeing what the performance difference between v33 and the current/latest version is for your problem. Do you have a (self contained) test case that I can try? Alt. 1 (ojAlgo) Test your problem on a desktop computer using ojAlgo v33 AND v34.8 to see if the improvements in any way make it a feasible alternative. I believe the fork-join-framework existed as a separate download before java 7 was released. Maybe you can use that. Alternatively maybe you can fake the api entirely and just execute everything sequentially (simplest possible implementation). ..or fake the api delegating to the v33 version of the org.ojalgo.concurrent package. There are still improvements to be made regarding how each lp-node is started, and probably other things as well. Alt. 2 (native) I have no experience here, but I've seen other people do interesting things with mixing in native code. The threshold for when it's advantageous (performance) to switch to native code seems to have come down lately. How many native platforms would have to support? If it's just 1 I would try this alternative. http://lpsolve.sourceforge.net/5.5/Java/README.html /Anders On 31 okt 2013, at 11:52, Zahar Chikishev <no...@ma...> wrote: > Hi Anders, > > Excuse me for writing in a new thread, I haven't got your reply in a mail but can see it on sourceforge. For convenience, I am pasting my original mail with your reply at the end of this letter. > > Thank you for the CVS link, I was able to reach the source code. I used "v33" branch for my tests. > > MIP solver required java.lang.management API, and it is not present in Android, so I removed the corresponding function call in file VirtualMachine.java. > > After that I successfully modeled and run my MIP problem in my Android app. The results are as expected, but the performance is low. My test problem took 20 seconds to run (Samsung Galaxy S2, physical device) and it is only a third of my full-size problem. The full-size problem did not finish in 30 minutes. So it looks like my problem is not that small. The problem that took 20 seconds was around 50 integer variables and 150 constraints. Unfortunately, it is not useful for me. I need at least 20 times faster. > > However, I was happy that I was able run MIP on Android at all. I searched a lot for how to do it, and there are only a few options available. Pure java solver is the best way, but ojAlgo is the only pure java MIP solver I have found. The second way is to compile some open-source C/C++ libraries with JNI (like GLPK or lp_solve), but this has its own problems, and I can't find testimonies of anyone who has actually done that. > > Please tell me if you have any words of advice for my situation. > > Thanks a lot, > Zahar > > > > -------------------------------------------------------------------------------------------------------------------------- > > Re: [ojAlgo-user] ojAlgo v34 on Android > From: Anders Peterson <anders@op...> - 2013-10-28 18:20:53 > > The source code is definitely available. Where did you get that link? > > ojAlgo uses CVS, not SVN: > > > https://sourceforge.net/p/ojalgo/code/ > > > v34 cannot be compiled using java 5 or 6 without re-coding. One of the things that changed with v34 is the use of the fork-join framework (ForkJoinPool and ForkJoinTask). The MIP solver is (now) highly integrated with these classes - that redesign was part of the improvements that came with v34. > > Java 6 was never a target. Switching back to Java 5 should be roughly the same amount of work. > > My guess is that you'll find this to be too much work... > > /Anders > > > On 28 okt 2013, at 18:10, Zahar Chikishev > <nosound@...> > wrote: > > > Hello, > > > > I wish to use ojAlgo to solve small MIP problems in my Android > > application. The problem is that Android does not support Java 7 > > compiled libraries. Version 33 of ojAlgo seems to work OK in my app, but > > I prefer to use 34 since, as far as I understand, it includes major > > improvements to MIP solver. > > > > So my question is, can version 34 be compiled on java 5 or 6? It is OK > > if some functionality is lost, as long as simple MIP problems can be > > solved. I tried to do it myself, but can't access the source code. I > > understand that the following is SVN link: > > > https://ojalgo.svn.sourceforge.net/svnroot/ojalgo/ > > > but it gives errors. > > > > So my second question is how I can access the source code. Is it still > > available? > > > > Thanks, > > Zahar > > > > ------------------------------------------------------------------------------ > > October Webinars: Code for Performance > > Free Intel webinars can help you accelerate application performance. > > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > > the latest Intel processors and coprocessors. See abstracts and register > > > > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk > > > _______________________________________________ > > ojAlgo-user mailing list > > ojAlgo-user@... > > > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > > > > > > > > > ------------------------------------------------------------------------------ > Android is increasing in popularity, but the open development platform that > developers love is also attractive to malware creators. Download this white > paper to learn more about secure code signing practices that can help keep > Android apps secure. > http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk_______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Zahar C. <no...@ma...> - 2013-10-31 10:56:21
|
Hi Anders, Excuse me for writing in a new thread, I haven't got your reply in a mail but can see it on sourceforge. For convenience, I am pasting my original mail with your reply at the end of this letter. Thank you for the CVS link, I was able to reach the source code. I used "v33" branch for my tests. MIP solver required java.lang.management API, and it is not present in Android, so I removed the corresponding function call in file VirtualMachine.java. After that I successfully modeled and run my MIP problem in my Android app. The results are as expected, but the performance is low. My test problem took 20 seconds to run (Samsung Galaxy S2, physical device) and it is only a third of my full-size problem. The full-size problem did not finish in 30 minutes. So it looks like my problem is not that small. The problem that took 20 seconds was around 50 integer variables and 150 constraints. Unfortunately, it is not useful for me. I need at least 20 times faster. However, I was happy that I was able run MIP on Android at all. I searched a lot for how to do it, and there are only a few options available. Pure java solver is the best way, but ojAlgo is the only pure java MIP solver I have found. The second way is to compile some open-source C/C++ libraries with JNI (like GLPK or lp_solve), but this has its own problems, and I can't find testimonies of anyone who has actually done that. Please tell me if you have any words of advice for my situation. Thanks a lot, Zahar *-------------------------------------------------------------------------------------------------------------------------- Re: [ojAlgo-user] ojAlgo v34 on Android <http://sourceforge.net/p/ojalgo/mailman/message/31572265/>* From: Anders Peterson <anders@op...> - 2013-10-28 18:20:53 The source code is definitely available. Where did you get that link? ojAlgo uses CVS, not SVN: https://sourceforge.net/p/ojalgo/code/ v34 cannot be compiled using java 5 or 6 without re-coding. One of the things that changed with v34 is the use of the fork-join framework (ForkJoinPool and ForkJoinTask). The MIP solver is (now) highly integrated with these classes - that redesign was part of the improvements that came with v34. Java 6 was never a target. Switching back to Java 5 should be roughly the same amount of work. My guess is that you'll find this to be too much work... /Anders On 28 okt 2013, at 18:10, Zahar Chikishev<nosound@...> wrote: > Hello, > > I wish to use ojAlgo to solve small MIP problems in my Android > application. The problem is that Android does not support Java 7 > compiled libraries. Version 33 of ojAlgo seems to work OK in my app, but > I prefer to use 34 since, as far as I understand, it includes major > improvements to MIP solver. > > So my question is, can version 34 be compiled on java 5 or 6? It is OK > if some functionality is lost, as long as simple MIP problems can be > solved. I tried to do it myself, but can't access the source code. I > understand that the following is SVN link: >https://ojalgo.svn.sourceforge.net/svnroot/ojalgo/ > but it gives errors. > > So my second question is how I can access the source code. Is it still > available? > > Thanks, > Zahar > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > the latest Intel processors and coprocessors. See abstracts and register > >http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk > _______________________________________________ > ojAlgo-user mailing list > ojAlgo-user@... >https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > |
From: Anders P. <an...@op...> - 2013-10-28 18:20:53
|
The source code is definitely available. Where did you get that link? ojAlgo uses CVS, not SVN: https://sourceforge.net/p/ojalgo/code/ v34 cannot be compiled using java 5 or 6 without re-coding. One of the things that changed with v34 is the use of the fork-join framework (ForkJoinPool and ForkJoinTask). The MIP solver is (now) highly integrated with these classes - that redesign was part of the improvements that came with v34. Java 6 was never a target. Switching back to Java 5 should be roughly the same amount of work. My guess is that you'll find this to be too much work... /Anders On 28 okt 2013, at 18:10, Zahar Chikishev <no...@ma...> wrote: > Hello, > > I wish to use ojAlgo to solve small MIP problems in my Android > application. The problem is that Android does not support Java 7 > compiled libraries. Version 33 of ojAlgo seems to work OK in my app, but > I prefer to use 34 since, as far as I understand, it includes major > improvements to MIP solver. > > So my question is, can version 34 be compiled on java 5 or 6? It is OK > if some functionality is lost, as long as simple MIP problems can be > solved. I tried to do it myself, but can't access the source code. I > understand that the following is SVN link: > https://ojalgo.svn.sourceforge.net/svnroot/ojalgo/ > but it gives errors. > > So my second question is how I can access the source code. Is it still > available? > > Thanks, > Zahar > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > |
From: Zahar C. <no...@ma...> - 2013-10-28 17:11:05
|
Hello, I wish to use ojAlgo to solve small MIP problems in my Android application. The problem is that Android does not support Java 7 compiled libraries. Version 33 of ojAlgo seems to work OK in my app, but I prefer to use 34 since, as far as I understand, it includes major improvements to MIP solver. So my question is, can version 34 be compiled on java 5 or 6? It is OK if some functionality is lost, as long as simple MIP problems can be solved. I tried to do it myself, but can't access the source code. I understand that the following is SVN link: https://ojalgo.svn.sourceforge.net/svnroot/ojalgo/ but it gives errors. So my second question is how I can access the source code. Is it still available? Thanks, Zahar |
From: Anthony E. <ant...@al...> - 2013-10-26 08:43:19
|
Ahhh ..... Wise words. Thanks for looking into this. I begin the walk of shame .... thanks for your help -----Original Message----- From: Anders Peterson Sent: Friday, October 25, 2013 7:27 PM To: ojAlgo ojAlgo Subject: Re: [ojAlgo-user] MarkowitzModel - what is optimal? If you change MatrixStore<Double> erms = cvs.builder().build(); into MatrixStore<Double> erms = ers; everything works fine! If you want a BasicMatrix (PrimitiveMatrix) instance, why do you first create a PrimitiveDenseStore? ..and if you want to create a PrimitiveDenseStore, then why set all values in a double[] first? Just call PrimitiveMatrix.getBuilder(int, int) or PrimitiveMatrix.getBuilder(int), set your values, and the call build(); http://code.google.com/p/ojalgo/wiki/GettingStartedLinearAlgebra I've modified ojAlgo to throw an IllegalArgumentException if the dimensions of the covariance matrix and the returns vector don't match. /Anders On 25 okt 2013, at 11:38, Anthony Edwards <ant...@al...> wrote: > Hi Anders > > Test.java attached. > > Thanks - really appreciate your help. > > Tony > > -----Original Message----- >> From: Anders Peterson > Sent: Friday, October 25, 2013 8:15 AM > To: ojAlgo ojAlgo > Subject: Re: [ojAlgo-user] MarkowitzModel - what is optimal? > > Please attach a *.java file that I can use to run the test/example without > any modifications. /Anders > > On 25 okt 2013, at 08:45, Anthony Edwards > <ant...@al...> wrote: > >> Hi Anders >> >> Ive setup a simple example and extracted the data and code that I am >> using >> (see below). Is there any chance you can take a look to see what I am >> doing >> wrong please? >> Thanks - appreciate your help. >> >> Tony >> >> -------------- JAVA Code >> >> public double [] getWeights(double [] er, double [][] cv, double [] >> minWgt, >> double [] maxWgt, boolean shortingAllowed, double targetReturn) { >> int row = er.length; >> int col = er.length; >> >> if (_dbg) System.out.println("AlgoMarkowitz.getWeights() - >> row="+row); >> >> PrimitiveDenseStore cvs = >> PrimitiveDenseStore.FACTORY.makeZero(row,col); >> for (int i = 0; i < row; i++) { >> for (int j = 0; j < col; j++) { >> cvs.set(i, j, cv[i][j]); >> if (_dbg) System.out.println("cv["+i+"]["+j+"] --> >> "+cv[i][j]); >> } >> } >> >> if (_dbg) { >> System.out.println("Covar()"); >> for (int r=0; r<row; r++) { >> StringBuilder sb = new StringBuilder(); >> for (int c=0; c<col; c++) { >> sb.append(Utils.formatp(cv[r][c]*100.0,2)+"% "); >> } >> System.out.println(sb.toString()); >> } >> } >> if (_dbg) System.out.println("AlgoMarkowitz.getWeights() - Covar >> Set"); >> >> PrimitiveDenseStore ers = >> PrimitiveDenseStore.FACTORY.makeZero(1,col); >> >> System.out.println(ers.countColumns()+" cols, "+ers.countRows()+" >> rows. "); >> for (int i = 0; i < row; i++) { >> if (_dbg) System.out.println("er["+i+"] --> "+er[i]); >> ers.set(0,i,er[i]); >> } >> if (_dbg) System.out.println("AlgoMarkowitz.getWeights() - >> Expeected >> Returns set"); >> System.out.println(""+ers.toString()); >> >> MatrixStore<Double> cvms = cvs.builder().build(); >> MatrixStore<Double> erms = cvs.builder().build(); >> >> BasicMatrix cvm = PrimitiveMatrix.FACTORY.copy(cvms); >> BasicMatrix erm = PrimitiveMatrix.FACTORY.copy(erms); >> >> MarkowitzModel markowitzModel = new MarkowitzModel(cvm, erm); >> >> markowitzModel.setTargetReturn(new BigDecimal(targetReturn)); >> >> System.out.println("Target Return = "+targetReturn); >> >> markowitzModel.setShortingAllowed(shortingAllowed); // False >> >> for (int i=0; i<er.length; i++) { >> markowitzModel.setLowerLimit(i, new BigDecimal(minWgt[i])); // >> 0.0 >> markowitzModel.setUpperLimit(i, new BigDecimal(maxWgt[i])); // >> 0.5 >> } >> >> double [] weights = new double[er.length]; >> final List<BigDecimal> re = markowitzModel.getWeights(); >> >> for (int nn = 0; nn < re.size(); nn++) { >> System.out.println("WGT["+nn+"] -->"+re.get(nn)+" --> >> "+re.get(nn).doubleValue() ); >> weights[nn] = re.get(nn).doubleValue(); >> } >> >> if (_dbg) { >> _meanReturn = markowitzModel.getMeanReturn(); >> _sharpeRatio = markowitzModel.getSharpeRatio(); >> _returnVariance = markowitzModel.getReturnVariance(); >> _lossProbability = markowitzModel.getLossProbability(); >> _volatility = markowitzModel.getVolatility(); >> _riskAversion = markowitzModel.getRiskAversion().doubleValue(); >> _resultSuccess = >> markowitzModel.getOptimisationState().isSuccess(); >> _resultFailure = >> markowitzModel.getOptimisationState().isFailure(); >> _resultOptimal = >> markowitzModel.getOptimisationState().isOptimal(); >> _resultValid = markowitzModel.getOptimisationState().isValid(); >> _resultDistinct = >> markowitzModel.getOptimisationState().isDistinct(); >> _resultFeasible = >> markowitzModel.getOptimisationState().isFeasible(); >> _resultUnexplored = >> markowitzModel.getOptimisationState().isUnexplored(); >> System.out.println("Model : Mean Return = "+_meanReturn); >> System.out.println("Model : Sharpe Ratio = "+_sharpeRatio); >> System.out.println("Model : Return Variance = >> "+_returnVariance); >> System.out.println("Model : Loss Probability = >> "+_lossProbability); >> System.out.println("Model : Volatility = "+_volatility); >> System.out.println("Model : Optimal Result = "+_resultOptimal); >> >> } >> return weights; >> } >> >> -------------- Input Data & Debugging Output >> >> AlgoMarkowitz.getWeights() - row=5 >> cv[0][0] --> 0.07843955354726917 >> cv[0][1] --> 0.010917730527180272 >> cv[0][2] --> 0.002617703304568447 >> cv[0][3] --> 0.0015367718256236922 >> cv[0][4] --> -0.007527000582038881 >> cv[1][0] --> 0.010917730527180272 >> cv[1][1] --> 0.010564384563013356 >> cv[1][2] --> 0.009059249805530113 >> cv[1][3] --> 0.007582121464911981 >> cv[1][4] --> -7.085933099370378E-4 >> cv[2][0] --> 0.002617703304568447 >> cv[2][1] --> 0.009059249805530113 >> cv[2][2] --> 0.019431716713640173 >> cv[2][3] --> 0.009759425136794966 >> cv[2][4] --> 0.0018625781574573416 >> cv[3][0] --> 0.0015367718256236922 >> cv[3][1] --> 0.007582121464911981 >> cv[3][2] --> 0.009759425136794966 >> cv[3][3] --> 0.008011558847885328 >> cv[3][4] --> -7.456016323607308E-4 >> cv[4][0] --> -0.007527000582038881 >> cv[4][1] --> -7.085933099370378E-4 >> cv[4][2] --> 0.0018625781574573416 >> cv[4][3] --> -7.456016323607308E-4 >> cv[4][4] --> 0.021224468167287004 >> Covar() >> 7.84% 1.09% 0.26% 0.15% -0.75% >> 1.09% 1.06% 0.91% 0.76% -0.07% >> 0.26% 0.91% 1.94% 0.98% 0.19% >> 0.15% 0.76% 0.98% 0.80% -0.07% >> -0.75% -0.07% 0.19% -0.07% 2.12% >> AlgoMarkowitz.getWeights() - Covar Set >> 5 cols, 1 rows. >> er[0] --> 0.08468993625647991 >> er[1] --> 0.05571192270463743 >> er[2] --> -0.053384899277547415 >> er[3] --> 0.0363486250229359 >> er[4] --> -0.10226497575724715 >> AlgoMarkowitz.getWeights() - Expeected Returns set >> org.ojalgo.matrix.store.PrimitiveDenseStore < 1 x 5 > >> { { 0.08468993625647991, >> 0.05571192270463743, -0.053384899277547415, >> 0.0363486250229359, -0.10226497575724715 } } >> Target Return = 0.05 >> WGT[0] -->0.5814 --> 0.5814 >> WGT[1] -->0.5 --> 0.5 >> WGT[2] -->0.0 --> 0.0 >> WGT[3] -->-0.1848 --> -0.1848 >> WGT[4] -->0.1034 --> 0.1034 >> Model : Mean Return = 0.05000133440241435 >> Model : Sharpe Ratio = 0.2739126173775806 >> Model : Return Variance = 0.03332261792985292 >> Model : Loss Probability = 0.42212046844930723 >> Model : Volatility = 0.18254483813532751 >> Model : Optimal Result = false >> >> >> >> >> >> -------------- HTML Output >> Run Strategy 'Narrow Test Strategy' >> Expected Returns >> 0 AAPL US Equity 0.08469 >> 1 QQQ US Equity 0.05571 >> 2 RWX US Equity -0.05338 >> 3 SPY US Equity 0.03635 >> 4 TLT US Equity -0.10226 >> Efficient Frontier >> Id Freeze Date Calculation Time TARGET_RETURN MEAN_RETURN >> SHARPE_RATIO LOSS_PROBABILITY RETURN_VARIANCE VOLATILITY >> RISK_AVERSION RESULT_SUCCESS RESULT_FAILURE RESULT_OPTIMAL >> RESULT_DISTINCT RESULT_FEASIBLE RESULT_UNEXPLORED WEIGHT_DELTA >> CALCULATION_FAILED >> 1382682291161 2013-09-30 2013-10-25 6:24:51 0.0500 0.0500 >> 0.2739 0.4221 0.0333 0.1825 1.0000 1.0000 0.0000 0.0000 >> 0.0000 0.0000 0.0000 0.0000 0.0000 AAPL US Equity / 0.581 >> QQQ US Equity / 0.500 RWX US Equity / 0.000 SPY US Equity / -0.185 >> TLT US Equity / 0.103 >> (Key point is that the RESULT_OPTIMAL is zero, and clearly the weights >> are >> outside the limits, but as this is also an infeasible result that that is >> fine) >> >> >> -----Original Message----- >>> From: Anders Peterson >> Sent: Thursday, October 24, 2013 8:39 PM >> To: ojAlgo ojAlgo >> Subject: Re: [ojAlgo-user] MarkowitzModel - what is optimal? >> >> Have you read the javadoc for the MarkowitzModel class and its methods? I >> think it does specify how it optimizes. >> >> The results you describe seems "wrong" but without a test case where I >> can >> see exactly what you do I cannot comment. >> >> If you don't like the MarkowitzModel class you can build your own >> optimization models directly using ExpressionsBasedModel >> >> http://ojalgo.org/generated/org/ojalgo/optimisation/ExpressionsBasedModel.html >> >> /Anders >> >> >> On 24 okt 2013, at 11:09, Anthony Edwards >> <ant...@al...> wrote: >> >>> Hi >>> >>> I’m still no nearer in understanding from any of the documentation or >>> javadocs what is optimal. When I specify a target return, I get a set >>> of >>> weights and various stats like ShapreRatio, Variance etc. What is the >>> optimiser maximising/minimising to arrive at this portfolio? Is it >>> maximising the sharp? or maximising mean return / variance? >>> >>> We are trying (with no joy at all) to compare an excel based solver with >>> ojalgo, but cant get anywhere near the same results for the same inputs >>> ..... >>> >>> Below is the covar and expected returns >>> >>> Covar() >>> 7.84% 1.09% 0.26% 0.15% -0.75% >>> 1.09% 1.06% 0.91% 0.76% -0.07% >>> 0.26% 0.91% 1.94% 0.98% 0.19% >>> 0.15% 0.76% 0.98% 0.80% -0.07% >>> -0.75% -0.07% 0.19% -0.07% 2.12% >>> er[0] --> 0.08468993625647991 >>> er[1] --> 0.05571192270463743 >>> er[2] --> -0.053384899277547415 >>> er[3] --> 0.0363486250229359 >>> er[4] --> -0.10226497575724715 >>> >>> The highest mean return solution we get is 4.4% with limits set at 0 to >>> 0.5 for all 5 assets. Clearly that is wrong. There is obviously a >>> solution at the mean of 8.4% and 5.5% with 50% in assets 1 and 2 and the >>> other weights at zero. When I run for a higher target return there is >>> no >>> optimal solution (and weights that outside limits then). The covar >>> looks >>> ok, the expected returns look ok, all assets are limited weights from 0 >>> to >>> 0.5 and the only variable I can control is the targetReturn(), so I’m at >>> a >>> loss here to know what else I can do. >>> >>> Any ideas? Thanks in advance ... >>> >>> Tony >>> ------------------------------------------------------------------------------ >>> October Webinars: Code for Performance >>> Free Intel webinars can help you accelerate application performance. >>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most >>> from >>> the latest Intel processors and coprocessors. See abstracts and register >>> > >>> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk_______________________________________________ >>> ojAlgo-user mailing list >>> ojA...@li... >>> https://lists.sourceforge.net/lists/listinfo/ojalgo-user >> >> >> ------------------------------------------------------------------------------ >> October Webinars: Code for Performance >> Free Intel webinars can help you accelerate application performance. >> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most >> from >> the latest Intel processors and coprocessors. See abstracts and register >> > >> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk >> _______________________________________________ >> ojAlgo-user mailing list >> ojA...@li... >> https://lists.sourceforge.net/lists/listinfo/ojalgo-user >> >> >> ------------------------------------------------------------------------------ >> October Webinars: Code for Performance >> Free Intel webinars can help you accelerate application performance. >> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most >> from >> the latest Intel processors and coprocessors. See abstracts and register >> > >> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk >> _______________________________________________ >> ojAlgo-user mailing list >> ojA...@li... >> https://lists.sourceforge.net/lists/listinfo/ojalgo-user >> >> > > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most > from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > <Test.java>------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most > from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk_______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk _______________________________________________ ojAlgo-user mailing list ojA...@li... https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Anders P. <an...@op...> - 2013-10-25 18:27:25
|
If you change MatrixStore<Double> erms = cvs.builder().build(); into MatrixStore<Double> erms = ers; everything works fine! If you want a BasicMatrix (PrimitiveMatrix) instance, why do you first create a PrimitiveDenseStore? ..and if you want to create a PrimitiveDenseStore, then why set all values in a double[] first? Just call PrimitiveMatrix.getBuilder(int, int) or PrimitiveMatrix.getBuilder(int), set your values, and the call build(); http://code.google.com/p/ojalgo/wiki/GettingStartedLinearAlgebra I've modified ojAlgo to throw an IllegalArgumentException if the dimensions of the covariance matrix and the returns vector don't match. /Anders On 25 okt 2013, at 11:38, Anthony Edwards <ant...@al...> wrote: > Hi Anders > > Test.java attached. > > Thanks - really appreciate your help. > > Tony > > -----Original Message----- >> From: Anders Peterson > Sent: Friday, October 25, 2013 8:15 AM > To: ojAlgo ojAlgo > Subject: Re: [ojAlgo-user] MarkowitzModel - what is optimal? > > Please attach a *.java file that I can use to run the test/example without any modifications. /Anders > > On 25 okt 2013, at 08:45, Anthony Edwards <ant...@al...> wrote: > >> Hi Anders >> >> Ive setup a simple example and extracted the data and code that I am using >> (see below). Is there any chance you can take a look to see what I am doing >> wrong please? >> Thanks - appreciate your help. >> >> Tony >> >> -------------- JAVA Code >> >> public double [] getWeights(double [] er, double [][] cv, double [] minWgt, >> double [] maxWgt, boolean shortingAllowed, double targetReturn) { >> int row = er.length; >> int col = er.length; >> >> if (_dbg) System.out.println("AlgoMarkowitz.getWeights() - >> row="+row); >> >> PrimitiveDenseStore cvs = >> PrimitiveDenseStore.FACTORY.makeZero(row,col); >> for (int i = 0; i < row; i++) { >> for (int j = 0; j < col; j++) { >> cvs.set(i, j, cv[i][j]); >> if (_dbg) System.out.println("cv["+i+"]["+j+"] --> >> "+cv[i][j]); >> } >> } >> >> if (_dbg) { >> System.out.println("Covar()"); >> for (int r=0; r<row; r++) { >> StringBuilder sb = new StringBuilder(); >> for (int c=0; c<col; c++) { >> sb.append(Utils.formatp(cv[r][c]*100.0,2)+"% "); >> } >> System.out.println(sb.toString()); >> } >> } >> if (_dbg) System.out.println("AlgoMarkowitz.getWeights() - Covar >> Set"); >> >> PrimitiveDenseStore ers = >> PrimitiveDenseStore.FACTORY.makeZero(1,col); >> >> System.out.println(ers.countColumns()+" cols, "+ers.countRows()+" >> rows. "); >> for (int i = 0; i < row; i++) { >> if (_dbg) System.out.println("er["+i+"] --> "+er[i]); >> ers.set(0,i,er[i]); >> } >> if (_dbg) System.out.println("AlgoMarkowitz.getWeights() - Expeected >> Returns set"); >> System.out.println(""+ers.toString()); >> >> MatrixStore<Double> cvms = cvs.builder().build(); >> MatrixStore<Double> erms = cvs.builder().build(); >> >> BasicMatrix cvm = PrimitiveMatrix.FACTORY.copy(cvms); >> BasicMatrix erm = PrimitiveMatrix.FACTORY.copy(erms); >> >> MarkowitzModel markowitzModel = new MarkowitzModel(cvm, erm); >> >> markowitzModel.setTargetReturn(new BigDecimal(targetReturn)); >> >> System.out.println("Target Return = "+targetReturn); >> >> markowitzModel.setShortingAllowed(shortingAllowed); // False >> >> for (int i=0; i<er.length; i++) { >> markowitzModel.setLowerLimit(i, new BigDecimal(minWgt[i])); // >> 0.0 >> markowitzModel.setUpperLimit(i, new BigDecimal(maxWgt[i])); // >> 0.5 >> } >> >> double [] weights = new double[er.length]; >> final List<BigDecimal> re = markowitzModel.getWeights(); >> >> for (int nn = 0; nn < re.size(); nn++) { >> System.out.println("WGT["+nn+"] -->"+re.get(nn)+" --> >> "+re.get(nn).doubleValue() ); >> weights[nn] = re.get(nn).doubleValue(); >> } >> >> if (_dbg) { >> _meanReturn = markowitzModel.getMeanReturn(); >> _sharpeRatio = markowitzModel.getSharpeRatio(); >> _returnVariance = markowitzModel.getReturnVariance(); >> _lossProbability = markowitzModel.getLossProbability(); >> _volatility = markowitzModel.getVolatility(); >> _riskAversion = markowitzModel.getRiskAversion().doubleValue(); >> _resultSuccess = >> markowitzModel.getOptimisationState().isSuccess(); >> _resultFailure = >> markowitzModel.getOptimisationState().isFailure(); >> _resultOptimal = >> markowitzModel.getOptimisationState().isOptimal(); >> _resultValid = markowitzModel.getOptimisationState().isValid(); >> _resultDistinct = >> markowitzModel.getOptimisationState().isDistinct(); >> _resultFeasible = >> markowitzModel.getOptimisationState().isFeasible(); >> _resultUnexplored = >> markowitzModel.getOptimisationState().isUnexplored(); >> System.out.println("Model : Mean Return = "+_meanReturn); >> System.out.println("Model : Sharpe Ratio = "+_sharpeRatio); >> System.out.println("Model : Return Variance = >> "+_returnVariance); >> System.out.println("Model : Loss Probability = >> "+_lossProbability); >> System.out.println("Model : Volatility = "+_volatility); >> System.out.println("Model : Optimal Result = "+_resultOptimal); >> >> } >> return weights; >> } >> >> -------------- Input Data & Debugging Output >> >> AlgoMarkowitz.getWeights() - row=5 >> cv[0][0] --> 0.07843955354726917 >> cv[0][1] --> 0.010917730527180272 >> cv[0][2] --> 0.002617703304568447 >> cv[0][3] --> 0.0015367718256236922 >> cv[0][4] --> -0.007527000582038881 >> cv[1][0] --> 0.010917730527180272 >> cv[1][1] --> 0.010564384563013356 >> cv[1][2] --> 0.009059249805530113 >> cv[1][3] --> 0.007582121464911981 >> cv[1][4] --> -7.085933099370378E-4 >> cv[2][0] --> 0.002617703304568447 >> cv[2][1] --> 0.009059249805530113 >> cv[2][2] --> 0.019431716713640173 >> cv[2][3] --> 0.009759425136794966 >> cv[2][4] --> 0.0018625781574573416 >> cv[3][0] --> 0.0015367718256236922 >> cv[3][1] --> 0.007582121464911981 >> cv[3][2] --> 0.009759425136794966 >> cv[3][3] --> 0.008011558847885328 >> cv[3][4] --> -7.456016323607308E-4 >> cv[4][0] --> -0.007527000582038881 >> cv[4][1] --> -7.085933099370378E-4 >> cv[4][2] --> 0.0018625781574573416 >> cv[4][3] --> -7.456016323607308E-4 >> cv[4][4] --> 0.021224468167287004 >> Covar() >> 7.84% 1.09% 0.26% 0.15% -0.75% >> 1.09% 1.06% 0.91% 0.76% -0.07% >> 0.26% 0.91% 1.94% 0.98% 0.19% >> 0.15% 0.76% 0.98% 0.80% -0.07% >> -0.75% -0.07% 0.19% -0.07% 2.12% >> AlgoMarkowitz.getWeights() - Covar Set >> 5 cols, 1 rows. >> er[0] --> 0.08468993625647991 >> er[1] --> 0.05571192270463743 >> er[2] --> -0.053384899277547415 >> er[3] --> 0.0363486250229359 >> er[4] --> -0.10226497575724715 >> AlgoMarkowitz.getWeights() - Expeected Returns set >> org.ojalgo.matrix.store.PrimitiveDenseStore < 1 x 5 > >> { { 0.08468993625647991, 0.05571192270463743, -0.053384899277547415, >> 0.0363486250229359, -0.10226497575724715 } } >> Target Return = 0.05 >> WGT[0] -->0.5814 --> 0.5814 >> WGT[1] -->0.5 --> 0.5 >> WGT[2] -->0.0 --> 0.0 >> WGT[3] -->-0.1848 --> -0.1848 >> WGT[4] -->0.1034 --> 0.1034 >> Model : Mean Return = 0.05000133440241435 >> Model : Sharpe Ratio = 0.2739126173775806 >> Model : Return Variance = 0.03332261792985292 >> Model : Loss Probability = 0.42212046844930723 >> Model : Volatility = 0.18254483813532751 >> Model : Optimal Result = false >> >> >> >> >> >> -------------- HTML Output >> Run Strategy 'Narrow Test Strategy' >> Expected Returns >> 0 AAPL US Equity 0.08469 >> 1 QQQ US Equity 0.05571 >> 2 RWX US Equity -0.05338 >> 3 SPY US Equity 0.03635 >> 4 TLT US Equity -0.10226 >> Efficient Frontier >> Id Freeze Date Calculation Time TARGET_RETURN MEAN_RETURN >> SHARPE_RATIO LOSS_PROBABILITY RETURN_VARIANCE VOLATILITY >> RISK_AVERSION RESULT_SUCCESS RESULT_FAILURE RESULT_OPTIMAL >> RESULT_DISTINCT RESULT_FEASIBLE RESULT_UNEXPLORED WEIGHT_DELTA >> CALCULATION_FAILED >> 1382682291161 2013-09-30 2013-10-25 6:24:51 0.0500 0.0500 >> 0.2739 0.4221 0.0333 0.1825 1.0000 1.0000 0.0000 0.0000 >> 0.0000 0.0000 0.0000 0.0000 0.0000 AAPL US Equity / 0.581 >> QQQ US Equity / 0.500 RWX US Equity / 0.000 SPY US Equity / -0.185 >> TLT US Equity / 0.103 >> (Key point is that the RESULT_OPTIMAL is zero, and clearly the weights are >> outside the limits, but as this is also an infeasible result that that is >> fine) >> >> >> -----Original Message----- >>> From: Anders Peterson >> Sent: Thursday, October 24, 2013 8:39 PM >> To: ojAlgo ojAlgo >> Subject: Re: [ojAlgo-user] MarkowitzModel - what is optimal? >> >> Have you read the javadoc for the MarkowitzModel class and its methods? I >> think it does specify how it optimizes. >> >> The results you describe seems "wrong" but without a test case where I can >> see exactly what you do I cannot comment. >> >> If you don't like the MarkowitzModel class you can build your own >> optimization models directly using ExpressionsBasedModel >> >> http://ojalgo.org/generated/org/ojalgo/optimisation/ExpressionsBasedModel.html >> >> /Anders >> >> >> On 24 okt 2013, at 11:09, Anthony Edwards >> <ant...@al...> wrote: >> >>> Hi >>> >>> I’m still no nearer in understanding from any of the documentation or >>> javadocs what is optimal. When I specify a target return, I get a set of >>> weights and various stats like ShapreRatio, Variance etc. What is the >>> optimiser maximising/minimising to arrive at this portfolio? Is it >>> maximising the sharp? or maximising mean return / variance? >>> >>> We are trying (with no joy at all) to compare an excel based solver with >>> ojalgo, but cant get anywhere near the same results for the same inputs >>> ..... >>> >>> Below is the covar and expected returns >>> >>> Covar() >>> 7.84% 1.09% 0.26% 0.15% -0.75% >>> 1.09% 1.06% 0.91% 0.76% -0.07% >>> 0.26% 0.91% 1.94% 0.98% 0.19% >>> 0.15% 0.76% 0.98% 0.80% -0.07% >>> -0.75% -0.07% 0.19% -0.07% 2.12% >>> er[0] --> 0.08468993625647991 >>> er[1] --> 0.05571192270463743 >>> er[2] --> -0.053384899277547415 >>> er[3] --> 0.0363486250229359 >>> er[4] --> -0.10226497575724715 >>> >>> The highest mean return solution we get is 4.4% with limits set at 0 to >>> 0.5 for all 5 assets. Clearly that is wrong. There is obviously a >>> solution at the mean of 8.4% and 5.5% with 50% in assets 1 and 2 and the >>> other weights at zero. When I run for a higher target return there is no >>> optimal solution (and weights that outside limits then). The covar looks >>> ok, the expected returns look ok, all assets are limited weights from 0 to >>> 0.5 and the only variable I can control is the targetReturn(), so I’m at a >>> loss here to know what else I can do. >>> >>> Any ideas? Thanks in advance ... >>> >>> Tony >>> ------------------------------------------------------------------------------ >>> October Webinars: Code for Performance >>> Free Intel webinars can help you accelerate application performance. >>> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most >>> from >>> the latest Intel processors and coprocessors. See abstracts and register > >>> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk_______________________________________________ >>> ojAlgo-user mailing list >>> ojA...@li... >>> https://lists.sourceforge.net/lists/listinfo/ojalgo-user >> >> >> ------------------------------------------------------------------------------ >> October Webinars: Code for Performance >> Free Intel webinars can help you accelerate application performance. >> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most >> from >> the latest Intel processors and coprocessors. See abstracts and register > >> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk >> _______________________________________________ >> ojAlgo-user mailing list >> ojA...@li... >> https://lists.sourceforge.net/lists/listinfo/ojalgo-user >> >> >> ------------------------------------------------------------------------------ >> October Webinars: Code for Performance >> Free Intel webinars can help you accelerate application performance. >> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from >> the latest Intel processors and coprocessors. See abstracts and register > >> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk >> _______________________________________________ >> ojAlgo-user mailing list >> ojA...@li... >> https://lists.sourceforge.net/lists/listinfo/ojalgo-user >> >> > > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > <Test.java>------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk_______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Anthony E. <ant...@al...> - 2013-10-25 09:38:31
|
Hi Anders Test.java attached. Thanks - really appreciate your help. Tony -----Original Message----- From: Anders Peterson Sent: Friday, October 25, 2013 8:15 AM To: ojAlgo ojAlgo Subject: Re: [ojAlgo-user] MarkowitzModel - what is optimal? Please attach a *.java file that I can use to run the test/example without any modifications. /Anders On 25 okt 2013, at 08:45, Anthony Edwards <ant...@al...> wrote: > Hi Anders > > Ive setup a simple example and extracted the data and code that I am using > (see below). Is there any chance you can take a look to see what I am > doing > wrong please? > Thanks - appreciate your help. > > Tony > > -------------- JAVA Code > > public double [] getWeights(double [] er, double [][] cv, double [] > minWgt, > double [] maxWgt, boolean shortingAllowed, double targetReturn) { > int row = er.length; > int col = er.length; > > if (_dbg) System.out.println("AlgoMarkowitz.getWeights() - > row="+row); > > PrimitiveDenseStore cvs = > PrimitiveDenseStore.FACTORY.makeZero(row,col); > for (int i = 0; i < row; i++) { > for (int j = 0; j < col; j++) { > cvs.set(i, j, cv[i][j]); > if (_dbg) System.out.println("cv["+i+"]["+j+"] --> > "+cv[i][j]); > } > } > > if (_dbg) { > System.out.println("Covar()"); > for (int r=0; r<row; r++) { > StringBuilder sb = new StringBuilder(); > for (int c=0; c<col; c++) { > sb.append(Utils.formatp(cv[r][c]*100.0,2)+"% "); > } > System.out.println(sb.toString()); > } > } > if (_dbg) System.out.println("AlgoMarkowitz.getWeights() - Covar > Set"); > > PrimitiveDenseStore ers = > PrimitiveDenseStore.FACTORY.makeZero(1,col); > > System.out.println(ers.countColumns()+" cols, "+ers.countRows()+" > rows. "); > for (int i = 0; i < row; i++) { > if (_dbg) System.out.println("er["+i+"] --> "+er[i]); > ers.set(0,i,er[i]); > } > if (_dbg) System.out.println("AlgoMarkowitz.getWeights() - > Expeected > Returns set"); > System.out.println(""+ers.toString()); > > MatrixStore<Double> cvms = cvs.builder().build(); > MatrixStore<Double> erms = cvs.builder().build(); > > BasicMatrix cvm = PrimitiveMatrix.FACTORY.copy(cvms); > BasicMatrix erm = PrimitiveMatrix.FACTORY.copy(erms); > > MarkowitzModel markowitzModel = new MarkowitzModel(cvm, erm); > > markowitzModel.setTargetReturn(new BigDecimal(targetReturn)); > > System.out.println("Target Return = "+targetReturn); > > markowitzModel.setShortingAllowed(shortingAllowed); // False > > for (int i=0; i<er.length; i++) { > markowitzModel.setLowerLimit(i, new BigDecimal(minWgt[i])); // > 0.0 > markowitzModel.setUpperLimit(i, new BigDecimal(maxWgt[i])); // > 0.5 > } > > double [] weights = new double[er.length]; > final List<BigDecimal> re = markowitzModel.getWeights(); > > for (int nn = 0; nn < re.size(); nn++) { > System.out.println("WGT["+nn+"] -->"+re.get(nn)+" --> > "+re.get(nn).doubleValue() ); > weights[nn] = re.get(nn).doubleValue(); > } > > if (_dbg) { > _meanReturn = markowitzModel.getMeanReturn(); > _sharpeRatio = markowitzModel.getSharpeRatio(); > _returnVariance = markowitzModel.getReturnVariance(); > _lossProbability = markowitzModel.getLossProbability(); > _volatility = markowitzModel.getVolatility(); > _riskAversion = markowitzModel.getRiskAversion().doubleValue(); > _resultSuccess = > markowitzModel.getOptimisationState().isSuccess(); > _resultFailure = > markowitzModel.getOptimisationState().isFailure(); > _resultOptimal = > markowitzModel.getOptimisationState().isOptimal(); > _resultValid = markowitzModel.getOptimisationState().isValid(); > _resultDistinct = > markowitzModel.getOptimisationState().isDistinct(); > _resultFeasible = > markowitzModel.getOptimisationState().isFeasible(); > _resultUnexplored = > markowitzModel.getOptimisationState().isUnexplored(); > System.out.println("Model : Mean Return = "+_meanReturn); > System.out.println("Model : Sharpe Ratio = "+_sharpeRatio); > System.out.println("Model : Return Variance = > "+_returnVariance); > System.out.println("Model : Loss Probability = > "+_lossProbability); > System.out.println("Model : Volatility = "+_volatility); > System.out.println("Model : Optimal Result = "+_resultOptimal); > > } > return weights; > } > > -------------- Input Data & Debugging Output > > AlgoMarkowitz.getWeights() - row=5 > cv[0][0] --> 0.07843955354726917 > cv[0][1] --> 0.010917730527180272 > cv[0][2] --> 0.002617703304568447 > cv[0][3] --> 0.0015367718256236922 > cv[0][4] --> -0.007527000582038881 > cv[1][0] --> 0.010917730527180272 > cv[1][1] --> 0.010564384563013356 > cv[1][2] --> 0.009059249805530113 > cv[1][3] --> 0.007582121464911981 > cv[1][4] --> -7.085933099370378E-4 > cv[2][0] --> 0.002617703304568447 > cv[2][1] --> 0.009059249805530113 > cv[2][2] --> 0.019431716713640173 > cv[2][3] --> 0.009759425136794966 > cv[2][4] --> 0.0018625781574573416 > cv[3][0] --> 0.0015367718256236922 > cv[3][1] --> 0.007582121464911981 > cv[3][2] --> 0.009759425136794966 > cv[3][3] --> 0.008011558847885328 > cv[3][4] --> -7.456016323607308E-4 > cv[4][0] --> -0.007527000582038881 > cv[4][1] --> -7.085933099370378E-4 > cv[4][2] --> 0.0018625781574573416 > cv[4][3] --> -7.456016323607308E-4 > cv[4][4] --> 0.021224468167287004 > Covar() > 7.84% 1.09% 0.26% 0.15% -0.75% > 1.09% 1.06% 0.91% 0.76% -0.07% > 0.26% 0.91% 1.94% 0.98% 0.19% > 0.15% 0.76% 0.98% 0.80% -0.07% > -0.75% -0.07% 0.19% -0.07% 2.12% > AlgoMarkowitz.getWeights() - Covar Set > 5 cols, 1 rows. > er[0] --> 0.08468993625647991 > er[1] --> 0.05571192270463743 > er[2] --> -0.053384899277547415 > er[3] --> 0.0363486250229359 > er[4] --> -0.10226497575724715 > AlgoMarkowitz.getWeights() - Expeected Returns set > org.ojalgo.matrix.store.PrimitiveDenseStore < 1 x 5 > > { { 0.08468993625647991, 0.05571192270463743, -0.053384899277547415, > 0.0363486250229359, -0.10226497575724715 } } > Target Return = 0.05 > WGT[0] -->0.5814 --> 0.5814 > WGT[1] -->0.5 --> 0.5 > WGT[2] -->0.0 --> 0.0 > WGT[3] -->-0.1848 --> -0.1848 > WGT[4] -->0.1034 --> 0.1034 > Model : Mean Return = 0.05000133440241435 > Model : Sharpe Ratio = 0.2739126173775806 > Model : Return Variance = 0.03332261792985292 > Model : Loss Probability = 0.42212046844930723 > Model : Volatility = 0.18254483813532751 > Model : Optimal Result = false > > > > > > -------------- HTML Output > Run Strategy 'Narrow Test Strategy' > Expected Returns > 0 AAPL US Equity 0.08469 > 1 QQQ US Equity 0.05571 > 2 RWX US Equity -0.05338 > 3 SPY US Equity 0.03635 > 4 TLT US Equity -0.10226 > Efficient Frontier > Id Freeze Date Calculation Time TARGET_RETURN MEAN_RETURN > SHARPE_RATIO LOSS_PROBABILITY RETURN_VARIANCE VOLATILITY > RISK_AVERSION RESULT_SUCCESS RESULT_FAILURE RESULT_OPTIMAL > RESULT_DISTINCT RESULT_FEASIBLE RESULT_UNEXPLORED WEIGHT_DELTA > CALCULATION_FAILED > 1382682291161 2013-09-30 2013-10-25 6:24:51 0.0500 0.0500 > 0.2739 0.4221 0.0333 0.1825 1.0000 1.0000 0.0000 > 0.0000 > 0.0000 0.0000 0.0000 0.0000 0.0000 AAPL US Equity / 0.581 > QQQ US Equity / 0.500 RWX US Equity / 0.000 SPY US Equity / -0.185 > TLT US Equity / 0.103 > (Key point is that the RESULT_OPTIMAL is zero, and clearly the weights > are > outside the limits, but as this is also an infeasible result that that is > fine) > > > -----Original Message----- >> From: Anders Peterson > Sent: Thursday, October 24, 2013 8:39 PM > To: ojAlgo ojAlgo > Subject: Re: [ojAlgo-user] MarkowitzModel - what is optimal? > > Have you read the javadoc for the MarkowitzModel class and its methods? I > think it does specify how it optimizes. > > The results you describe seems "wrong" but without a test case where I can > see exactly what you do I cannot comment. > > If you don't like the MarkowitzModel class you can build your own > optimization models directly using ExpressionsBasedModel > > http://ojalgo.org/generated/org/ojalgo/optimisation/ExpressionsBasedModel.html > > /Anders > > > On 24 okt 2013, at 11:09, Anthony Edwards > <ant...@al...> wrote: > >> Hi >> >> I’m still no nearer in understanding from any of the documentation or >> javadocs what is optimal. When I specify a target return, I get a set of >> weights and various stats like ShapreRatio, Variance etc. What is the >> optimiser maximising/minimising to arrive at this portfolio? Is it >> maximising the sharp? or maximising mean return / variance? >> >> We are trying (with no joy at all) to compare an excel based solver with >> ojalgo, but cant get anywhere near the same results for the same inputs >> ..... >> >> Below is the covar and expected returns >> >> Covar() >> 7.84% 1.09% 0.26% 0.15% -0.75% >> 1.09% 1.06% 0.91% 0.76% -0.07% >> 0.26% 0.91% 1.94% 0.98% 0.19% >> 0.15% 0.76% 0.98% 0.80% -0.07% >> -0.75% -0.07% 0.19% -0.07% 2.12% >> er[0] --> 0.08468993625647991 >> er[1] --> 0.05571192270463743 >> er[2] --> -0.053384899277547415 >> er[3] --> 0.0363486250229359 >> er[4] --> -0.10226497575724715 >> >> The highest mean return solution we get is 4.4% with limits set at 0 to >> 0.5 for all 5 assets. Clearly that is wrong. There is obviously a >> solution at the mean of 8.4% and 5.5% with 50% in assets 1 and 2 and the >> other weights at zero. When I run for a higher target return there is no >> optimal solution (and weights that outside limits then). The covar looks >> ok, the expected returns look ok, all assets are limited weights from 0 >> to >> 0.5 and the only variable I can control is the targetReturn(), so I’m at >> a >> loss here to know what else I can do. >> >> Any ideas? Thanks in advance ... >> >> Tony >> ------------------------------------------------------------------------------ >> October Webinars: Code for Performance >> Free Intel webinars can help you accelerate application performance. >> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most >> from >> the latest Intel processors and coprocessors. See abstracts and register >> > >> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk_______________________________________________ >> ojAlgo-user mailing list >> ojA...@li... >> https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most > from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most > from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk _______________________________________________ ojAlgo-user mailing list ojA...@li... https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Anders P. <an...@op...> - 2013-10-25 07:16:25
|
Please attach a *.java file that I can use to run the test/example without any modifications. /Anders On 25 okt 2013, at 08:45, Anthony Edwards <ant...@al...> wrote: > Hi Anders > > Ive setup a simple example and extracted the data and code that I am using > (see below). Is there any chance you can take a look to see what I am doing > wrong please? > Thanks - appreciate your help. > > Tony > > -------------- JAVA Code > > public double [] getWeights(double [] er, double [][] cv, double [] minWgt, > double [] maxWgt, boolean shortingAllowed, double targetReturn) { > int row = er.length; > int col = er.length; > > if (_dbg) System.out.println("AlgoMarkowitz.getWeights() - > row="+row); > > PrimitiveDenseStore cvs = > PrimitiveDenseStore.FACTORY.makeZero(row,col); > for (int i = 0; i < row; i++) { > for (int j = 0; j < col; j++) { > cvs.set(i, j, cv[i][j]); > if (_dbg) System.out.println("cv["+i+"]["+j+"] --> > "+cv[i][j]); > } > } > > if (_dbg) { > System.out.println("Covar()"); > for (int r=0; r<row; r++) { > StringBuilder sb = new StringBuilder(); > for (int c=0; c<col; c++) { > sb.append(Utils.formatp(cv[r][c]*100.0,2)+"% "); > } > System.out.println(sb.toString()); > } > } > if (_dbg) System.out.println("AlgoMarkowitz.getWeights() - Covar > Set"); > > PrimitiveDenseStore ers = > PrimitiveDenseStore.FACTORY.makeZero(1,col); > > System.out.println(ers.countColumns()+" cols, "+ers.countRows()+" > rows. "); > for (int i = 0; i < row; i++) { > if (_dbg) System.out.println("er["+i+"] --> "+er[i]); > ers.set(0,i,er[i]); > } > if (_dbg) System.out.println("AlgoMarkowitz.getWeights() - Expeected > Returns set"); > System.out.println(""+ers.toString()); > > MatrixStore<Double> cvms = cvs.builder().build(); > MatrixStore<Double> erms = cvs.builder().build(); > > BasicMatrix cvm = PrimitiveMatrix.FACTORY.copy(cvms); > BasicMatrix erm = PrimitiveMatrix.FACTORY.copy(erms); > > MarkowitzModel markowitzModel = new MarkowitzModel(cvm, erm); > > markowitzModel.setTargetReturn(new BigDecimal(targetReturn)); > > System.out.println("Target Return = "+targetReturn); > > markowitzModel.setShortingAllowed(shortingAllowed); // False > > for (int i=0; i<er.length; i++) { > markowitzModel.setLowerLimit(i, new BigDecimal(minWgt[i])); // > 0.0 > markowitzModel.setUpperLimit(i, new BigDecimal(maxWgt[i])); // > 0.5 > } > > double [] weights = new double[er.length]; > final List<BigDecimal> re = markowitzModel.getWeights(); > > for (int nn = 0; nn < re.size(); nn++) { > System.out.println("WGT["+nn+"] -->"+re.get(nn)+" --> > "+re.get(nn).doubleValue() ); > weights[nn] = re.get(nn).doubleValue(); > } > > if (_dbg) { > _meanReturn = markowitzModel.getMeanReturn(); > _sharpeRatio = markowitzModel.getSharpeRatio(); > _returnVariance = markowitzModel.getReturnVariance(); > _lossProbability = markowitzModel.getLossProbability(); > _volatility = markowitzModel.getVolatility(); > _riskAversion = markowitzModel.getRiskAversion().doubleValue(); > _resultSuccess = > markowitzModel.getOptimisationState().isSuccess(); > _resultFailure = > markowitzModel.getOptimisationState().isFailure(); > _resultOptimal = > markowitzModel.getOptimisationState().isOptimal(); > _resultValid = markowitzModel.getOptimisationState().isValid(); > _resultDistinct = > markowitzModel.getOptimisationState().isDistinct(); > _resultFeasible = > markowitzModel.getOptimisationState().isFeasible(); > _resultUnexplored = > markowitzModel.getOptimisationState().isUnexplored(); > System.out.println("Model : Mean Return = "+_meanReturn); > System.out.println("Model : Sharpe Ratio = "+_sharpeRatio); > System.out.println("Model : Return Variance = > "+_returnVariance); > System.out.println("Model : Loss Probability = > "+_lossProbability); > System.out.println("Model : Volatility = "+_volatility); > System.out.println("Model : Optimal Result = "+_resultOptimal); > > } > return weights; > } > > -------------- Input Data & Debugging Output > > AlgoMarkowitz.getWeights() - row=5 > cv[0][0] --> 0.07843955354726917 > cv[0][1] --> 0.010917730527180272 > cv[0][2] --> 0.002617703304568447 > cv[0][3] --> 0.0015367718256236922 > cv[0][4] --> -0.007527000582038881 > cv[1][0] --> 0.010917730527180272 > cv[1][1] --> 0.010564384563013356 > cv[1][2] --> 0.009059249805530113 > cv[1][3] --> 0.007582121464911981 > cv[1][4] --> -7.085933099370378E-4 > cv[2][0] --> 0.002617703304568447 > cv[2][1] --> 0.009059249805530113 > cv[2][2] --> 0.019431716713640173 > cv[2][3] --> 0.009759425136794966 > cv[2][4] --> 0.0018625781574573416 > cv[3][0] --> 0.0015367718256236922 > cv[3][1] --> 0.007582121464911981 > cv[3][2] --> 0.009759425136794966 > cv[3][3] --> 0.008011558847885328 > cv[3][4] --> -7.456016323607308E-4 > cv[4][0] --> -0.007527000582038881 > cv[4][1] --> -7.085933099370378E-4 > cv[4][2] --> 0.0018625781574573416 > cv[4][3] --> -7.456016323607308E-4 > cv[4][4] --> 0.021224468167287004 > Covar() > 7.84% 1.09% 0.26% 0.15% -0.75% > 1.09% 1.06% 0.91% 0.76% -0.07% > 0.26% 0.91% 1.94% 0.98% 0.19% > 0.15% 0.76% 0.98% 0.80% -0.07% > -0.75% -0.07% 0.19% -0.07% 2.12% > AlgoMarkowitz.getWeights() - Covar Set > 5 cols, 1 rows. > er[0] --> 0.08468993625647991 > er[1] --> 0.05571192270463743 > er[2] --> -0.053384899277547415 > er[3] --> 0.0363486250229359 > er[4] --> -0.10226497575724715 > AlgoMarkowitz.getWeights() - Expeected Returns set > org.ojalgo.matrix.store.PrimitiveDenseStore < 1 x 5 > > { { 0.08468993625647991, 0.05571192270463743, -0.053384899277547415, > 0.0363486250229359, -0.10226497575724715 } } > Target Return = 0.05 > WGT[0] -->0.5814 --> 0.5814 > WGT[1] -->0.5 --> 0.5 > WGT[2] -->0.0 --> 0.0 > WGT[3] -->-0.1848 --> -0.1848 > WGT[4] -->0.1034 --> 0.1034 > Model : Mean Return = 0.05000133440241435 > Model : Sharpe Ratio = 0.2739126173775806 > Model : Return Variance = 0.03332261792985292 > Model : Loss Probability = 0.42212046844930723 > Model : Volatility = 0.18254483813532751 > Model : Optimal Result = false > > > > > > -------------- HTML Output > Run Strategy 'Narrow Test Strategy' > Expected Returns > 0 AAPL US Equity 0.08469 > 1 QQQ US Equity 0.05571 > 2 RWX US Equity -0.05338 > 3 SPY US Equity 0.03635 > 4 TLT US Equity -0.10226 > Efficient Frontier > Id Freeze Date Calculation Time TARGET_RETURN MEAN_RETURN > SHARPE_RATIO LOSS_PROBABILITY RETURN_VARIANCE VOLATILITY > RISK_AVERSION RESULT_SUCCESS RESULT_FAILURE RESULT_OPTIMAL > RESULT_DISTINCT RESULT_FEASIBLE RESULT_UNEXPLORED WEIGHT_DELTA > CALCULATION_FAILED > 1382682291161 2013-09-30 2013-10-25 6:24:51 0.0500 0.0500 > 0.2739 0.4221 0.0333 0.1825 1.0000 1.0000 0.0000 0.0000 > 0.0000 0.0000 0.0000 0.0000 0.0000 AAPL US Equity / 0.581 > QQQ US Equity / 0.500 RWX US Equity / 0.000 SPY US Equity / -0.185 > TLT US Equity / 0.103 > (Key point is that the RESULT_OPTIMAL is zero, and clearly the weights are > outside the limits, but as this is also an infeasible result that that is > fine) > > > -----Original Message----- >> From: Anders Peterson > Sent: Thursday, October 24, 2013 8:39 PM > To: ojAlgo ojAlgo > Subject: Re: [ojAlgo-user] MarkowitzModel - what is optimal? > > Have you read the javadoc for the MarkowitzModel class and its methods? I > think it does specify how it optimizes. > > The results you describe seems "wrong" but without a test case where I can > see exactly what you do I cannot comment. > > If you don't like the MarkowitzModel class you can build your own > optimization models directly using ExpressionsBasedModel > > http://ojalgo.org/generated/org/ojalgo/optimisation/ExpressionsBasedModel.html > > /Anders > > > On 24 okt 2013, at 11:09, Anthony Edwards > <ant...@al...> wrote: > >> Hi >> >> I’m still no nearer in understanding from any of the documentation or >> javadocs what is optimal. When I specify a target return, I get a set of >> weights and various stats like ShapreRatio, Variance etc. What is the >> optimiser maximising/minimising to arrive at this portfolio? Is it >> maximising the sharp? or maximising mean return / variance? >> >> We are trying (with no joy at all) to compare an excel based solver with >> ojalgo, but cant get anywhere near the same results for the same inputs >> ..... >> >> Below is the covar and expected returns >> >> Covar() >> 7.84% 1.09% 0.26% 0.15% -0.75% >> 1.09% 1.06% 0.91% 0.76% -0.07% >> 0.26% 0.91% 1.94% 0.98% 0.19% >> 0.15% 0.76% 0.98% 0.80% -0.07% >> -0.75% -0.07% 0.19% -0.07% 2.12% >> er[0] --> 0.08468993625647991 >> er[1] --> 0.05571192270463743 >> er[2] --> -0.053384899277547415 >> er[3] --> 0.0363486250229359 >> er[4] --> -0.10226497575724715 >> >> The highest mean return solution we get is 4.4% with limits set at 0 to >> 0.5 for all 5 assets. Clearly that is wrong. There is obviously a >> solution at the mean of 8.4% and 5.5% with 50% in assets 1 and 2 and the >> other weights at zero. When I run for a higher target return there is no >> optimal solution (and weights that outside limits then). The covar looks >> ok, the expected returns look ok, all assets are limited weights from 0 to >> 0.5 and the only variable I can control is the targetReturn(), so I’m at a >> loss here to know what else I can do. >> >> Any ideas? Thanks in advance ... >> >> Tony >> ------------------------------------------------------------------------------ >> October Webinars: Code for Performance >> Free Intel webinars can help you accelerate application performance. >> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most >> from >> the latest Intel processors and coprocessors. See abstracts and register > >> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk_______________________________________________ >> ojAlgo-user mailing list >> ojA...@li... >> https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most > from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > |
From: Anthony E. <ant...@al...> - 2013-10-25 06:45:12
|
Hi Anders Ive setup a simple example and extracted the data and code that I am using (see below). Is there any chance you can take a look to see what I am doing wrong please? Thanks - appreciate your help. Tony -------------- JAVA Code public double [] getWeights(double [] er, double [][] cv, double [] minWgt, double [] maxWgt, boolean shortingAllowed, double targetReturn) { int row = er.length; int col = er.length; if (_dbg) System.out.println("AlgoMarkowitz.getWeights() - row="+row); PrimitiveDenseStore cvs = PrimitiveDenseStore.FACTORY.makeZero(row,col); for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { cvs.set(i, j, cv[i][j]); if (_dbg) System.out.println("cv["+i+"]["+j+"] --> "+cv[i][j]); } } if (_dbg) { System.out.println("Covar()"); for (int r=0; r<row; r++) { StringBuilder sb = new StringBuilder(); for (int c=0; c<col; c++) { sb.append(Utils.formatp(cv[r][c]*100.0,2)+"% "); } System.out.println(sb.toString()); } } if (_dbg) System.out.println("AlgoMarkowitz.getWeights() - Covar Set"); PrimitiveDenseStore ers = PrimitiveDenseStore.FACTORY.makeZero(1,col); System.out.println(ers.countColumns()+" cols, "+ers.countRows()+" rows. "); for (int i = 0; i < row; i++) { if (_dbg) System.out.println("er["+i+"] --> "+er[i]); ers.set(0,i,er[i]); } if (_dbg) System.out.println("AlgoMarkowitz.getWeights() - Expeected Returns set"); System.out.println(""+ers.toString()); MatrixStore<Double> cvms = cvs.builder().build(); MatrixStore<Double> erms = cvs.builder().build(); BasicMatrix cvm = PrimitiveMatrix.FACTORY.copy(cvms); BasicMatrix erm = PrimitiveMatrix.FACTORY.copy(erms); MarkowitzModel markowitzModel = new MarkowitzModel(cvm, erm); markowitzModel.setTargetReturn(new BigDecimal(targetReturn)); System.out.println("Target Return = "+targetReturn); markowitzModel.setShortingAllowed(shortingAllowed); // False for (int i=0; i<er.length; i++) { markowitzModel.setLowerLimit(i, new BigDecimal(minWgt[i])); // 0.0 markowitzModel.setUpperLimit(i, new BigDecimal(maxWgt[i])); // 0.5 } double [] weights = new double[er.length]; final List<BigDecimal> re = markowitzModel.getWeights(); for (int nn = 0; nn < re.size(); nn++) { System.out.println("WGT["+nn+"] -->"+re.get(nn)+" --> "+re.get(nn).doubleValue() ); weights[nn] = re.get(nn).doubleValue(); } if (_dbg) { _meanReturn = markowitzModel.getMeanReturn(); _sharpeRatio = markowitzModel.getSharpeRatio(); _returnVariance = markowitzModel.getReturnVariance(); _lossProbability = markowitzModel.getLossProbability(); _volatility = markowitzModel.getVolatility(); _riskAversion = markowitzModel.getRiskAversion().doubleValue(); _resultSuccess = markowitzModel.getOptimisationState().isSuccess(); _resultFailure = markowitzModel.getOptimisationState().isFailure(); _resultOptimal = markowitzModel.getOptimisationState().isOptimal(); _resultValid = markowitzModel.getOptimisationState().isValid(); _resultDistinct = markowitzModel.getOptimisationState().isDistinct(); _resultFeasible = markowitzModel.getOptimisationState().isFeasible(); _resultUnexplored = markowitzModel.getOptimisationState().isUnexplored(); System.out.println("Model : Mean Return = "+_meanReturn); System.out.println("Model : Sharpe Ratio = "+_sharpeRatio); System.out.println("Model : Return Variance = "+_returnVariance); System.out.println("Model : Loss Probability = "+_lossProbability); System.out.println("Model : Volatility = "+_volatility); System.out.println("Model : Optimal Result = "+_resultOptimal); } return weights; } -------------- Input Data & Debugging Output AlgoMarkowitz.getWeights() - row=5 cv[0][0] --> 0.07843955354726917 cv[0][1] --> 0.010917730527180272 cv[0][2] --> 0.002617703304568447 cv[0][3] --> 0.0015367718256236922 cv[0][4] --> -0.007527000582038881 cv[1][0] --> 0.010917730527180272 cv[1][1] --> 0.010564384563013356 cv[1][2] --> 0.009059249805530113 cv[1][3] --> 0.007582121464911981 cv[1][4] --> -7.085933099370378E-4 cv[2][0] --> 0.002617703304568447 cv[2][1] --> 0.009059249805530113 cv[2][2] --> 0.019431716713640173 cv[2][3] --> 0.009759425136794966 cv[2][4] --> 0.0018625781574573416 cv[3][0] --> 0.0015367718256236922 cv[3][1] --> 0.007582121464911981 cv[3][2] --> 0.009759425136794966 cv[3][3] --> 0.008011558847885328 cv[3][4] --> -7.456016323607308E-4 cv[4][0] --> -0.007527000582038881 cv[4][1] --> -7.085933099370378E-4 cv[4][2] --> 0.0018625781574573416 cv[4][3] --> -7.456016323607308E-4 cv[4][4] --> 0.021224468167287004 Covar() 7.84% 1.09% 0.26% 0.15% -0.75% 1.09% 1.06% 0.91% 0.76% -0.07% 0.26% 0.91% 1.94% 0.98% 0.19% 0.15% 0.76% 0.98% 0.80% -0.07% -0.75% -0.07% 0.19% -0.07% 2.12% AlgoMarkowitz.getWeights() - Covar Set 5 cols, 1 rows. er[0] --> 0.08468993625647991 er[1] --> 0.05571192270463743 er[2] --> -0.053384899277547415 er[3] --> 0.0363486250229359 er[4] --> -0.10226497575724715 AlgoMarkowitz.getWeights() - Expeected Returns set org.ojalgo.matrix.store.PrimitiveDenseStore < 1 x 5 > { { 0.08468993625647991, 0.05571192270463743, -0.053384899277547415, 0.0363486250229359, -0.10226497575724715 } } Target Return = 0.05 WGT[0] -->0.5814 --> 0.5814 WGT[1] -->0.5 --> 0.5 WGT[2] -->0.0 --> 0.0 WGT[3] -->-0.1848 --> -0.1848 WGT[4] -->0.1034 --> 0.1034 Model : Mean Return = 0.05000133440241435 Model : Sharpe Ratio = 0.2739126173775806 Model : Return Variance = 0.03332261792985292 Model : Loss Probability = 0.42212046844930723 Model : Volatility = 0.18254483813532751 Model : Optimal Result = false -------------- HTML Output Run Strategy 'Narrow Test Strategy' Expected Returns 0 AAPL US Equity 0.08469 1 QQQ US Equity 0.05571 2 RWX US Equity -0.05338 3 SPY US Equity 0.03635 4 TLT US Equity -0.10226 Efficient Frontier Id Freeze Date Calculation Time TARGET_RETURN MEAN_RETURN SHARPE_RATIO LOSS_PROBABILITY RETURN_VARIANCE VOLATILITY RISK_AVERSION RESULT_SUCCESS RESULT_FAILURE RESULT_OPTIMAL RESULT_DISTINCT RESULT_FEASIBLE RESULT_UNEXPLORED WEIGHT_DELTA CALCULATION_FAILED 1382682291161 2013-09-30 2013-10-25 6:24:51 0.0500 0.0500 0.2739 0.4221 0.0333 0.1825 1.0000 1.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 AAPL US Equity / 0.581 QQQ US Equity / 0.500 RWX US Equity / 0.000 SPY US Equity / -0.185 TLT US Equity / 0.103 (Key point is that the RESULT_OPTIMAL is zero, and clearly the weights are outside the limits, but as this is also an infeasible result that that is fine) -----Original Message----- From: Anders Peterson Sent: Thursday, October 24, 2013 8:39 PM To: ojAlgo ojAlgo Subject: Re: [ojAlgo-user] MarkowitzModel - what is optimal? Have you read the javadoc for the MarkowitzModel class and its methods? I think it does specify how it optimizes. The results you describe seems "wrong" but without a test case where I can see exactly what you do I cannot comment. If you don't like the MarkowitzModel class you can build your own optimization models directly using ExpressionsBasedModel http://ojalgo.org/generated/org/ojalgo/optimisation/ExpressionsBasedModel.html /Anders On 24 okt 2013, at 11:09, Anthony Edwards <ant...@al...> wrote: > Hi > > I’m still no nearer in understanding from any of the documentation or > javadocs what is optimal. When I specify a target return, I get a set of > weights and various stats like ShapreRatio, Variance etc. What is the > optimiser maximising/minimising to arrive at this portfolio? Is it > maximising the sharp? or maximising mean return / variance? > > We are trying (with no joy at all) to compare an excel based solver with > ojalgo, but cant get anywhere near the same results for the same inputs > ..... > > Below is the covar and expected returns > > Covar() > 7.84% 1.09% 0.26% 0.15% -0.75% > 1.09% 1.06% 0.91% 0.76% -0.07% > 0.26% 0.91% 1.94% 0.98% 0.19% > 0.15% 0.76% 0.98% 0.80% -0.07% > -0.75% -0.07% 0.19% -0.07% 2.12% > er[0] --> 0.08468993625647991 > er[1] --> 0.05571192270463743 > er[2] --> -0.053384899277547415 > er[3] --> 0.0363486250229359 > er[4] --> -0.10226497575724715 > > The highest mean return solution we get is 4.4% with limits set at 0 to > 0.5 for all 5 assets. Clearly that is wrong. There is obviously a > solution at the mean of 8.4% and 5.5% with 50% in assets 1 and 2 and the > other weights at zero. When I run for a higher target return there is no > optimal solution (and weights that outside limits then). The covar looks > ok, the expected returns look ok, all assets are limited weights from 0 to > 0.5 and the only variable I can control is the targetReturn(), so I’m at a > loss here to know what else I can do. > > Any ideas? Thanks in advance ... > > Tony > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most > from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk_______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk _______________________________________________ ojAlgo-user mailing list ojA...@li... https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Anders P. <an...@op...> - 2013-10-24 19:40:03
|
Have you read the javadoc for the MarkowitzModel class and its methods? I think it does specify how it optimizes. The results you describe seems "wrong" but without a test case where I can see exactly what you do I cannot comment. If you don't like the MarkowitzModel class you can build your own optimization models directly using ExpressionsBasedModel http://ojalgo.org/generated/org/ojalgo/optimisation/ExpressionsBasedModel.html /Anders On 24 okt 2013, at 11:09, Anthony Edwards <ant...@al...> wrote: > Hi > > I’m still no nearer in understanding from any of the documentation or javadocs what is optimal. When I specify a target return, I get a set of weights and various stats like ShapreRatio, Variance etc. What is the optimiser maximising/minimising to arrive at this portfolio? Is it maximising the sharp? or maximising mean return / variance? > > We are trying (with no joy at all) to compare an excel based solver with ojalgo, but cant get anywhere near the same results for the same inputs ..... > > Below is the covar and expected returns > > Covar() > 7.84% 1.09% 0.26% 0.15% -0.75% > 1.09% 1.06% 0.91% 0.76% -0.07% > 0.26% 0.91% 1.94% 0.98% 0.19% > 0.15% 0.76% 0.98% 0.80% -0.07% > -0.75% -0.07% 0.19% -0.07% 2.12% > er[0] --> 0.08468993625647991 > er[1] --> 0.05571192270463743 > er[2] --> -0.053384899277547415 > er[3] --> 0.0363486250229359 > er[4] --> -0.10226497575724715 > > The highest mean return solution we get is 4.4% with limits set at 0 to 0.5 for all 5 assets. Clearly that is wrong. There is obviously a solution at the mean of 8.4% and 5.5% with 50% in assets 1 and 2 and the other weights at zero. When I run for a higher target return there is no optimal solution (and weights that outside limits then). The covar looks ok, the expected returns look ok, all assets are limited weights from 0 to 0.5 and the only variable I can control is the targetReturn(), so I’m at a loss here to know what else I can do. > > Any ideas? Thanks in advance ... > > Tony > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk_______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Anthony E. <ant...@al...> - 2013-10-24 09:09:22
|
Hi I’m still no nearer in understanding from any of the documentation or javadocs what is optimal. When I specify a target return, I get a set of weights and various stats like ShapreRatio, Variance etc. What is the optimiser maximising/minimising to arrive at this portfolio? Is it maximising the sharp? or maximising mean return / variance? We are trying (with no joy at all) to compare an excel based solver with ojalgo, but cant get anywhere near the same results for the same inputs .... Below is the covar and expected returns Covar() 7.84% 1.09% 0.26% 0.15% -0.75% 1.09% 1.06% 0.91% 0.76% -0.07% 0.26% 0.91% 1.94% 0.98% 0.19% 0.15% 0.76% 0.98% 0.80% -0.07% -0.75% -0.07% 0.19% -0.07% 2.12% er[0] --> 0.08468993625647991 er[1] --> 0.05571192270463743 er[2] --> -0.053384899277547415 er[3] --> 0.0363486250229359 er[4] --> -0.10226497575724715 The highest mean return solution we get is 4.4% with limits set at 0 to 0.5 for all 5 assets. Clearly that is wrong. There is obviously a solution at the mean of 8.4% and 5.5% with 50% in assets 1 and 2 and the other weights at zero. When I run for a higher target return there is no optimal solution (and weights that outside limits then). The covar looks ok, the expected returns look ok, all assets are limited weights from 0 to 0.5 and the only variable I can control is the targetReturn(), so I’m at a loss here to know what else I can do. Any ideas? Thanks in advance ... Tony |
From: Anthony E. <ant...@al...> - 2013-10-23 13:44:17
|
Hi When i use MarkowitzModel and create a portfolio via setTargetReturn() I get back a set of ‘optimal’ weights. is there any documentation that defines exactly what optimal is in this case? is it the maximum SharpeRatio or max (mean return / variance) etc. Is there any way we can specify the formula for optimality? There doesnt seem to be any documentation on this anywhere .... Any pointers gratefully appreciated. Thanks Tony |
From: Anders P. <an...@op...> - 2013-10-21 20:24:33
|
Most likely there is no feasible solution. What does markowitzModel.getOptimisationState(); return? /Anders On 21 okt 2013, at 18:11, Anthony Edwards <ant...@al...> wrote: > Hi > > I was under the impression that if I create a MarkowitzModel, then set setShortingAllowed to false and setTargetReturn then the weights should always be positive or zero? > > MarkowitzModel markowitzModel = new MarkowitzModel(cvm, erm); > markowitzModel.setShortingAllowed(false); > markowitzModel.setTargetReturn(new BigDecimal(targetReturn)); > > > for (int i=0; i<er.length; i++) { > markowitzModel.setLowerLimit(i, new BigDecimal(minWgt[i])); > markowitzModel.setUpperLimit(i, new BigDecimal(maxWgt[i])); > > System.out.println("Limits["+i+"] --> "+minWgt[i]+" to "+maxWgt[i]); > } > > final List<BigDecimal> re = markowitzModel.getWeights(); > for (int nn = 0; nn < re.size(); nn++) { > //System.out.println( re.get(nn) ); > weights[nn] = re.get(nn).doubleValue(); > } > > This gives me some negative weights with my covariance (cvm) and expected returns (erm). > > Any idea what am I doing wrong? Ive tried all sorts of combinations but it doesnt seem to help. > > Interestingly, if I do setRiskAversion() instead of setTargetReturn() then the weight limits seem to be respected. > > Basically, I am trying to plot out the efficient frontier but calling the above for a rage of target returns ... > > Any help gratefully appraciated. > > Thanks > > Tony > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk_______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Anthony E. <ant...@al...> - 2013-10-21 16:11:27
|
Hi I was under the impression that if I create a MarkowitzModel, then set setShortingAllowed to false and setTargetReturn then the weights should always be positive or zero? MarkowitzModel markowitzModel = new MarkowitzModel(cvm, erm); markowitzModel.setShortingAllowed(false); markowitzModel.setTargetReturn(new BigDecimal(targetReturn)); for (int i=0; i<er.length; i++) { markowitzModel.setLowerLimit(i, new BigDecimal(minWgt[i])); markowitzModel.setUpperLimit(i, new BigDecimal(maxWgt[i])); System.out.println("Limits["+i+"] --> "+minWgt[i]+" to "+maxWgt[i]); } final List<BigDecimal> re = markowitzModel.getWeights(); for (int nn = 0; nn < re.size(); nn++) { //System.out.println( re.get(nn) ); weights[nn] = re.get(nn).doubleValue(); } This gives me some negative weights with my covariance (cvm) and expected returns (erm). Any idea what am I doing wrong? Ive tried all sorts of combinations but it doesnt seem to help. Interestingly, if I do setRiskAversion() instead of setTargetReturn() then the weight limits seem to be respected. Basically, I am trying to plot out the efficient frontier but calling the above for a rage of target returns ... Any help gratefully appraciated. Thanks Tony |
From: Anders P. <an...@op...> - 2013-10-09 05:03:29
|
The MarkowitzModel has a constructor that takes two arguments - the covariance matrix and the expected returns - both typed as BasicMatrix. Here you can read about how to create matrices: http://code.google.com/p/ojalgo/wiki/GettingStartedLinearAlgebra Then you read the javadoc: http://ojalgo.org/generated/org/ojalgo/finance/portfolio/MarkowitzModel.html /Anders On 8 okt 2013, at 17:50, "Anthony Edwards" <ant...@al...> wrote: > Hi > > Ive spent all afternoon looking at this mailing list just to find a basic example of Markowitz optimisation so I can see how to do things properly (especially creating the covar matrics etc). Does anyone have a basic example to point me in the right direction please? > > A lot of the code fragments in the list seem to be from older versions and dont even compile now ... > > Any help would be really appreciated – I have seen the little documentation there is, but just want a simple example if possibe where i supply an expected returns and covar and get back the weights ... > > Thanks everyone > > Anthony > ------------------------------------------------------------------------------ > October Webinars: Code for Performance > Free Intel webinars can help you accelerate application performance. > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from > the latest Intel processors and coprocessors. See abstracts and register > > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk_______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |