ojalgo-user Mailing List for oj! Algorithms (Page 24)
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: Andreas R. <a....@tu...> - 2008-04-17 07:22:03
|
Hello all, does someone has example code for matrix calculations? I used the standard JAMA package before and now want to calculate this: Basis are the Matrices A and B 1) CholeskyDecomposition of Matrix A 2) Extract Upper Matrix U from CholeskyDecomposition 3) Transpose the extracted Matrix U and store it in Ut 4) calculate Matrix Ut . C . Ut I would need a clue about what Classes to use and what Methods to call. Thank you |
From: Anders P. <an...@op...> - 2008-04-16 19:31:10
|
Please direct questions like these to the ojalgo-user mailing list. On 16 apr 2008, at 16.57, Andreas Reim wrote: > > Dear ojAlgo Team, > > I found your website while searching a java Package for > optimization and linear algebra. The package sound really > interesting. I was already able to get some basic calculations done > using the JamaMatrix Class. > I don't recommend using specific implementations that way, and don't call the constructors directly. > My recent problem is how to get a CholeskyDecomposition of > JamaMatrix as a JamaMatrix. Since the .getU() from JamaCholesky > “only” returns a MatrixStore Object, I am wondering how to get a > JamaMatrix from this MatrixStore Object to be able to perform > further calculations. > Short answer is you cannot... (Maybe you should be able to. I'll think about that.) There are two different levels at which you can use the linear algebra parts of ojAlgp - BasicMatrix and MatrixStore. BasicMatrix is for higher level calculations, and MatrixStore is for lower level (better control). The various MatrixDecomposition implementations are at the MatrixStore level. It seems to me that you should try to use what you find in the org.ojalgo.matrix.store and org.ojalgo.matrix.decomposition packages instead of org.ojalgo.matrix.jama. > In the online JavaDoc I can find a constructor JamaMatrix > (MatrixStore aStore) which is not present in any of the online > Packages Version 22 and 21. Perhaps you can give me a reason why > the JavaDoc is not representing the package content and where I can > find the latest Package. > I update the online javadoc now and then. When I do it is updated to match the current cvs head. The constructor you mention has been added after v22 was released (and all the other public constructors have been deprecated). http://ojalgo.org/change_log.html Version 22 is the latest release. If you want to be even more up to date you need to get the code from cvs. /Anders |
From: Anders P. <an...@op...> - 2008-03-31 17:33:31
|
On 31 mar 2008, at 18.41, Cluchier wrote: > Hello, > > > > When I run the ojalgo-22.0.jar file on the Java virtual machine, I > get the following error. > > > > “Failed to load Main-Class Manifest attribute from “h:\….\oljalgo > directory…”. > ojAlgo is not an application. It's a Java code library. The Black- Litterman Application (BLApp) is not Open Source. It's an example/ prototype application built using ojAlgo, but the source code is not available to you. > > > Is there another way to run the Jar files to see the Black- > Litterman application running? As I am not a Java user, I will need > > to convert to VB.NET and then recompile the project. I only need > the Black-Litterman part. Do I need to convert all namespaces? > The BlackLittermanModel class needs large parts of ojAlgo - you need everything. Don't know anything about converting Java to VB. If you attempt such a thing please make sure the copyright statement and license agreement is maintained as part of the source code. /Anders > > > Thanks for your help, > > > > Regards, > > > > Jean-Marie > > > > > > ---------------------------------------------------------------------- > --- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/ > marketplace_______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Cluchier <mu...@wa...> - 2008-03-31 16:41:32
|
Hello, When I run the ojalgo-22.0.jar file on the Java virtual machine, I get the following error. "Failed to load Main-Class Manifest attribute from "h:\..\oljalgo directory.". Is there another way to run the Jar files to see the Black-Litterman application running? As I am not a Java user, I will need to convert to VB.NET and then recompile the project. I only need the Black-Litterman part. Do I need to convert all namespaces? Thanks for your help, Regards, Jean-Marie |
From: Anders P. <an...@op...> - 2008-02-08 20:55:14
|
There's a fix in CVS. There seems to always be a way to end up in a pattern repeating loop. This time I introduced an element of randomness in the (de)activation strategy (gave up on being clever). /Anders On 8 feb 2008, at 15.12, Arthur McGibbon wrote: > Hi Anders, > > Sorry - but I've got another example of a NullPointerException. > > Thanks for patching all of these - it's taken a while to get > another one. I'd give you all the examples at once but they're > dependent on previous optimisation results. > > regards > Arthur > > public void testojAlgo6() > { > // create expected returns matrix > PrimitiveMatrix expectedReturnsMatrix = new PrimitiveMatrix(new > double[][] { {9.997829}, {10.008909}, {10.010849}, {9.998919}, > {10.055549}, {9.999127}, {9.999720}, {10.049002}, {9.988769}, > {9.990095}}); > // create covariance matrix > PrimitiveMatrix covarianceMatrix = new PrimitiveMatrix(new double > [][] {{0.014661954677318977, 3.459112088561122E-4, > 0.007798752920910871, 0.0020921425081866503, 0.001846944297640248, > 1.0531906931335766E-4, -2.7515614291198E-4, 0.0034083900074454894, > 1.1859491261103433E-4, -0.0027421673864628264}, > {3.459112088561122E-4, 0.008695862475003915, > 0.004154360841751649, -2.661685231819661E-4, -0.0015999007544258263, 3 > .590680217774603E-4, -0.00186976624370318, > 0.0010975416828213752, -5.512038393911129E-4, -0.0010605923775744853}, > {0.007798752920910871, 0.004154360841751649, > 0.032945930970836965, > 0.0037716078815399324, -2.2919474365382624E-4, > 3.3938035033219876E-4, -0.0015613122026082874, > 0.0010975697179894332, 2.296422665244149E-4, -0.001709517941787044}, > {0.0020921425081866503, -2.661685231819661E-4, > 0.0037716078815399324, 0.0057162979859706736, 5.573137056500744E-4, > 4.91132887765294E-4, -9.94830474250937E-4, > 8.331708084069932E-4, -6.595917138470072E-4, -0.0018693519327569541}, > > {0.001846944297640248, -0.0015999007544258263, -2.2919474365382624E-4, > 5.573137056500744E-4, > 0.03230071314144326, -2.2320789666419312E-4, -2.2639506820057415E-4, 0 > .010695663287043154, 0.0014569847730040847, 0.002160537177809949}, > {1.0531906931335766E-4, 3.590680217774603E-4, > 3.3938035033219876E-4, 4.91132887765294E-4, -2.2320789666419312E-4, > 0.0017540170708301957, 5.153195618913916E-5, > 7.339825618468765E-4, -9.309096233432093E-6, -1.814362059740286E-4}, > > {-2.7515614291198E-4, -0.00186976624370318, -0.0015613122026082874, -9 > .94830474250937E-4, -2.2639506820057415E-4, 5.153195618913916E-5, > 0.00809348822665732, -0.0017672866424053742, 3.058672988166145E-4, > 0.001201578905822851}, > {0.0034083900074454894, 0.0010975416828213752, > 0.0010975697179894332, 8.331708084069932E-4, 0.010695663287043154, > 7.339825618468765E-4, -0.0017672866424053742, 0.013913761913235494, > 0.0012785124957521252, 5.298368056593439E-4}, > {1.1859491261103433E-4, -5.512038393911129E-4, > 2.296422665244149E-4, -6.595917138470072E-4, > 0.0014569847730040847, -9.309096233432093E-6, 3.058672988166145E-4, > 0.0012785124957521252, 0.004650801896027841, 5.437156659657787E-4}, > > {-0.0027421673864628264, -0.0010605923775744853, -0.001709517941787044 > , -0.0018693519327569541, > 0.002160537177809949, -1.814362059740286E-4, 0.001201578905822851, > 5.298368056593439E-4, 5.437156659657787E-4, 0.007359495478781133}}); > > // create asset variables - cost and weighting constraints > Variable[] tmpVariables = new Variable > [expectedReturnsMatrix.getRowDim()]; > for (int i = 0; i < tmpVariables.length; i++) > { > tmpVariables[i] = new Variable(""); > tmpVariables[i].setContribution > (expectedReturnsMatrix.toBigDecimal(i, 0).negate()); > // set the constraints on the asset weights > // require at least a 8% allocation to each asset > tmpVariables[i].setLowerLimit(new BigDecimal("0.08")); > // require no more than 12% allocation to each asset > tmpVariables[i].setUpperLimit(new BigDecimal("0.12")); > } > > QuadraticModel quadModel = new QuadraticModel(tmpVariables); > > Expression tmpExpr = quadModel.addCorrelationExpression > ("Variance", covarianceMatrix.toBigStore().toArray()); > BigDecimal riskAversion = BigMath.PI.multiply(BigMath.E); > tmpExpr.setContribution(riskAversion.multiply(BigMath.HALF)); > > // set balance expression > tmpExpr = quadModel.addSimpleWeightExpression("Balance"); > tmpExpr.setLowerLimit(BigMath.ONE); > tmpExpr.setUpperLimit(BigMath.ONE); > > // exception here... > BasicMatrix bm = BigMatrix.FACTORY.buildColumnVector > (quadModel.getDefaultSolver().getSolution()); > > System.out.print(bm.toString()); > } > > > ******************************************************************** > This message and any attachment are confidential. If you are not > the intended recipient please contact the sender, delete this > message and any attachment from your system and do not disclose, > copy or distribute the contents to any other person. Beach Horizon > LLP (Beach Horizon) is not responsible for any information > contained in this email. Beach Horizon reserves the right to > monitor all email messages passing through its network. > ******************************************************************** > > > ---------------------------------------------------------------------- > --- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > |
From: Arthur M. <art...@be...> - 2008-02-08 15:23:38
|
Hi Anders, Sorry - but I've got another example of a NullPointerException. Thanks for patching all of these - it's taken a while to get another one. I'd give you all the examples at once but they're dependent on previous optimisation results. regards Arthur public void testojAlgo6() { // create expected returns matrix PrimitiveMatrix expectedReturnsMatrix = new PrimitiveMatrix(new double[][] { {9.997829}, {10.008909}, {10.010849}, {9.998919}, {10.055549}, {9.999127}, {9.999720}, {10.049002}, {9.988769}, {9.990095}}); // create covariance matrix PrimitiveMatrix covarianceMatrix = new PrimitiveMatrix(new double[][] {{0.014661954677318977, 3.459112088561122E-4, 0.007798752920910871, 0.0020921425081866503, 0.001846944297640248, 1.0531906931335766E-4, -2.7515614291198E-4, 0.0034083900074454894, 1.1859491261103433E-4, -0.0027421673864628264}, {3.459112088561122E-4, 0.008695862475003915, 0.004154360841751649, -2.661685231819661E-4, -0.0015999007544258263, 3.590680217774603E-4, -0.00186976624370318, 0.0010975416828213752, -5.512038393911129E-4, -0.0010605923775744853}, {0.007798752920910871, 0.004154360841751649, 0.032945930970836965, 0.0037716078815399324, -2.2919474365382624E-4, 3.3938035033219876E-4, -0.0015613122026082874, 0.0010975697179894332, 2.296422665244149E-4, -0.001709517941787044}, {0.0020921425081866503, -2.661685231819661E-4, 0.0037716078815399324, 0.0057162979859706736, 5.573137056500744E-4, 4.91132887765294E-4, -9.94830474250937E-4, 8.331708084069932E-4, -6.595917138470072E-4, -0.0018693519327569541}, {0.001846944297640248, -0.0015999007544258263, -2.2919474365382624E-4, 5.573137056500744E-4, 0.03230071314144326, -2.2320789666419312E-4, -2.2639506820057415E-4, 0.010695663287043154, 0.0014569847730040847, 0.002160537177809949}, {1.0531906931335766E-4, 3.590680217774603E-4, 3.3938035033219876E-4, 4.91132887765294E-4, -2.2320789666419312E-4, 0.0017540170708301957, 5.153195618913916E-5, 7.339825618468765E-4, -9.309096233432093E-6, -1.814362059740286E-4}, {-2.7515614291198E-4, -0.00186976624370318, -0.0015613122026082874, -9.94830474250937E-4, -2.2639506820057415E-4, 5.153195618913916E-5, 0.00809348822665732, -0.0017672866424053742, 3.058672988166145E-4, 0.001201578905822851}, {0.0034083900074454894, 0.0010975416828213752, 0.0010975697179894332, 8.331708084069932E-4, 0.010695663287043154, 7.339825618468765E-4, -0.0017672866424053742, 0.013913761913235494, 0.0012785124957521252, 5.298368056593439E-4}, {1.1859491261103433E-4, -5.512038393911129E-4, 2.296422665244149E-4, -6.595917138470072E-4, 0.0014569847730040847, -9.309096233432093E-6, 3.058672988166145E-4, 0.0012785124957521252, 0.004650801896027841, 5.437156659657787E-4}, {-0.0027421673864628264, -0.0010605923775744853, -0.001709517941787044, -0.0018693519327569541, 0.002160537177809949, -1.814362059740286E-4, 0.001201578905822851, 5.298368056593439E-4, 5.437156659657787E-4, 0.007359495478781133}}); // create asset variables - cost and weighting constraints Variable[] tmpVariables = new Variable[expectedReturnsMatrix.getRowDim()]; for (int i = 0; i < tmpVariables.length; i++) { tmpVariables[i] = new Variable(""); tmpVariables[i].setContribution(expectedReturnsMatrix.toBigDecimal(i, 0).negate()); // set the constraints on the asset weights // require at least a 8% allocation to each asset tmpVariables[i].setLowerLimit(new BigDecimal("0.08")); // require no more than 12% allocation to each asset tmpVariables[i].setUpperLimit(new BigDecimal("0.12")); } QuadraticModel quadModel = new QuadraticModel(tmpVariables); Expression tmpExpr = quadModel.addCorrelationExpression("Variance", covarianceMatrix.toBigStore().toArray()); BigDecimal riskAversion = BigMath.PI.multiply(BigMath.E); tmpExpr.setContribution(riskAversion.multiply(BigMath.HALF)); // set balance expression tmpExpr = quadModel.addSimpleWeightExpression("Balance"); tmpExpr.setLowerLimit(BigMath.ONE); tmpExpr.setUpperLimit(BigMath.ONE); // exception here... BasicMatrix bm = BigMatrix.FACTORY.buildColumnVector(quadModel.getDefaultSolver().getSolution()); System.out.print(bm.toString()); } ******************************************************************** This message and any attachment are confidential. If you are not the intended recipient please contact the sender, delete this message and any attachment from your system and do not disclose, copy or distribute the contents to any other person. Beach Horizon LLP (Beach Horizon) is not responsible for any information contained in this email. Beach Horizon reserves the right to monitor all email messages passing through its network. ******************************************************************** |
From: Anders P. <an...@op...> - 2008-02-04 16:19:25
|
I've patched the ActiveSetSolver, again... Please verify that that you get correct solutions (at least that they seem reasonable). /Anders On 4 feb 2008, at 12.57, Arthur McGibbon wrote: > Hi Anders, > > I've been using the new version for a while and it has been working > well on many different constraints - thanks for all the work you've > put in here. > > Unfortunately I've got another issue with NullPointerExceptions. > I'd run through the code myself but I don't understand the maths > behind the constraints - hence my use of your library. > > Could you have another look please > > regards > Arthur > > > > > > public void testojAlgo() > { > // create expected returns matrix > PrimitiveMatrix expectedReturnsMatrix = new PrimitiveMatrix(new > double[][] { {9.994620}, {10.011389}, {10.004353}, {9.998293}, > {10.056851}, {9.997920}, {9.999011}, {10.050971}, {9.989124}, > {9.989912}}); > // create covariance matrix > PrimitiveMatrix covarianceMatrix = new PrimitiveMatrix(new double > [][] {{0.014531344652473037, 4.444675045533674E-4, > 0.007234717654072837, -9.455312097865225E-4, 0.0016345464996349748, > 1.5256808879495097E-4, 0.00226325818749439, > 0.003534367267672946, -4.2669306842991344E-5, 6.902267133060073E-5}, > {4.444675045533674E-4, 0.008511422662647488, > 0.0039821105759899845, > 5.543408872612397E-4, -0.0015797828516888929, > 1.3505400134130176E-4, -1.5215492836142527E-4, > 9.381119889780555E-4, -4.5861204247023084E-4, -2.4226694503921645E-5}, > {0.007234717654072837, 0.0039821105759899845, > 0.031037646466036784, -0.0022701157440735394, -3.187028053841407E-4, 5 > .182461519304137E-4, -3.681340242039795E-4, 0.001526984686166616, > 1.603885118040309E-4, -1.359858314115312E-4}, > {-9.455312097865225E-4, > 5.543408872612397E-4, -0.0022701157440735394, 0.005637141895898889, > 7.89377521930992E-4, > 5.004781934410127E-4, -9.79221967172284E-4, -2.912861228906251E-4, > 7.842012412867984E-4, 0.0010866808807429532}, > > {0.0016345464996349748, -0.0015797828516888929, -3.187028053841407E-4, > 7.89377521930992E-4, 0.03263062480163135, 6.041130577612135E-5, > 6.883489096710362E-4, 0.010830183513887228, 0.0016425608963272292, > 0.002481787652249504}, > {1.5256808879495097E-4, 1.3505400134130176E-4, > 5.182461519304137E-4, 5.004781934410127E-4, 6.041130577612135E-5, > 0.001733612375709255, 2.8742157640452992E-5, -3.654534740999083E-4, > 9.896178753749563E-5, -1.703972415991329E-5}, > > {0.00226325818749439, -1.5215492836142527E-4, -3.681340242039795E-4, - > 9.79221967172284E-4, 6.883489096710362E-4, 2.8742157640452992E-5, > 0.008167191690212253, -0.0010075092076978207, -4.293010139199468E-4, - > 6.615640978331292E-4}, > {0.003534367267672946, 9.381119889780555E-4, > 0.001526984686166616, -2.912861228906251E-4, > 0.010830183513887228, -3.654534740999083E-4, -0.0010075092076978207, 0 > .013796198054188104, 0.0013541164478127973, -2.2401086720669167E-5}, > {-4.2669306842991344E-5, -4.5861204247023084E-4, > 1.603885118040309E-4, 7.842012412867984E-4, 0.0016425608963272292, > 9.896178753749563E-5, -4.293010139199468E-4, 0.0013541164478127973, > 0.004743485149287524, 0.0011464293217708277}, > > {6.902267133060073E-5, -2.4226694503921645E-5, -1.359858314115312E-4, > 0.0010866808807429532, > 0.002481787652249504, -1.703972415991329E-5, -6.615640978331292E-4, -2 > .2401086720669167E-5, 0.0011464293217708277, 0.007398229661528494}}); > > // create asset variables - cost and weighting constraints > Variable[] tmpVariables = new Variable > [expectedReturnsMatrix.getRowDim()]; > for (int i = 0; i < tmpVariables.length; i++) > { > tmpVariables[i] = new Variable(""); > tmpVariables[i].setCost(expectedReturnsMatrix.toBigDecimal(i, > 0).negate()); > // set the constraints on the asset weights > // require at least a 8% allocation to each asset > tmpVariables[i].setLowerLimit(new BigDecimal("0.08")); > // require no more than 12% allocation to each asset > tmpVariables[i].setUpperLimit(new BigDecimal("0.12")); > } > > QuadraticModel quadModel = new QuadraticModel(tmpVariables); > > Expression tmpExpr = quadModel.addCorrelationExpression > ("Variance", covarianceMatrix.toBigStore().toArray()); > BigDecimal riskAversion = BigMath.PI.multiply(BigMath.E); > tmpExpr.setCost(riskAversion.multiply(BigMath.HALF)); > > // set balance expression > tmpExpr = quadModel.addSimpleWeightExpression("Balance"); > tmpExpr.setLowerLimit(BigMath.ONE); > tmpExpr.setUpperLimit(BigMath.ONE); > > // exception here... > BasicMatrix bm = BigMatrix.FACTORY.buildColumnVector > (quadModel.getDefaultSolver().getSolution()); > > System.out.print(bm.toString()); > } > > > ******************************************************************** > This message and any attachment are confidential. If you are not > the intended recipient please contact the sender, delete this > message and any attachment from your system and do not disclose, > copy or distribute the contents to any other person. Beach Horizon > LLP (Beach Horizon) is not responsible for any information > contained in this email. Beach Horizon reserves the right to > monitor all email messages passing through its network. > ******************************************************************** > > > ---------------------------------------------------------------------- > --- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > |
From: Arthur M. <art...@be...> - 2008-02-04 12:02:48
|
Hi Anders, I've been using the new version for a while and it has been working well on= many different constraints - thanks for all the work you've put in here. Unfortunately I've got another issue with NullPointerExceptions. I'd run t= hrough the code myself but I don't understand the maths behind the constrai= nts - hence my use of your library. Could you have another look please regards Arthur public void testojAlgo() { // create expected returns matrix PrimitiveMatrix expectedReturnsMatrix =3D new PrimitiveMatrix(new double[= ][] { {9.994620}, {10.011389}, {10.004353}, {9.998293}, {10.056851}, {9.997= 920}, {9.999011}, {10.050971}, {9.989124}, {9.989912}}); // create covariance matrix PrimitiveMatrix covarianceMatrix =3D new PrimitiveMatrix(new double[][] {= {0.014531344652473037, 4.444675045533674E-4, 0.007234717654072837, -9.45531= 2097865225E-4, 0.0016345464996349748, 1.5256808879495097E-4, 0.002263258187= 49439, 0.003534367267672946, -4.2669306842991344E-5, 6.902267133060073E-5}, {4.444675045533674E-4, 0.008511422662647488, 0.0039821105759899845, 5.54= 3408872612397E-4, -0.0015797828516888929, 1.3505400134130176E-4, -1.5215492= 836142527E-4, 9.381119889780555E-4, -4.5861204247023084E-4, -2.422669450392= 1645E-5}, {0.007234717654072837, 0.0039821105759899845, 0.031037646466036784, -0.0= 022701157440735394, -3.187028053841407E-4, 5.182461519304137E-4, -3.6813402= 42039795E-4, 0.001526984686166616, 1.603885118040309E-4, -1.359858314115312= E-4}, {-9.455312097865225E-4, 5.543408872612397E-4, -0.0022701157440735394, 0.= 005637141895898889, 7.89377521930992E-4, 5.004781934410127E-4, -9.792219671= 72284E-4, -2.912861228906251E-4, 7.842012412867984E-4, 0.001086680880742953= 2}, {0.0016345464996349748, -0.0015797828516888929, -3.187028053841407E-4, 7= .89377521930992E-4, 0.03263062480163135, 6.041130577612135E-5, 6.8834890967= 10362E-4, 0.010830183513887228, 0.0016425608963272292, 0.002481787652249504= }, {1.5256808879495097E-4, 1.3505400134130176E-4, 5.182461519304137E-4, 5.0= 04781934410127E-4, 6.041130577612135E-5, 0.001733612375709255, 2.8742157640= 452992E-5, -3.654534740999083E-4, 9.896178753749563E-5, -1.703972415991329E= -5}, {0.00226325818749439, -1.5215492836142527E-4, -3.681340242039795E-4, -9.= 79221967172284E-4, 6.883489096710362E-4, 2.8742157640452992E-5, 0.008167191= 690212253, -0.0010075092076978207, -4.293010139199468E-4, -6.61564097833129= 2E-4}, {0.003534367267672946, 9.381119889780555E-4, 0.001526984686166616, -2.91= 2861228906251E-4, 0.010830183513887228, -3.654534740999083E-4, -0.001007509= 2076978207, 0.013796198054188104, 0.0013541164478127973, -2.240108672066916= 7E-5}, {-4.2669306842991344E-5, -4.5861204247023084E-4, 1.603885118040309E-4, 7= .842012412867984E-4, 0.0016425608963272292, 9.896178753749563E-5, -4.293010= 139199468E-4, 0.0013541164478127973, 0.004743485149287524, 0.00114642932177= 08277}, {6.902267133060073E-5, -2.4226694503921645E-5, -1.359858314115312E-4, 0.= 0010866808807429532, 0.002481787652249504, -1.703972415991329E-5, -6.615640= 978331292E-4, -2.2401086720669167E-5, 0.0011464293217708277, 0.007398229661= 528494}}); // create asset variables - cost and weighting constraints Variable[] tmpVariables =3D new Variable[expectedReturnsMatrix.getRowDim(= )]; for (int i =3D 0; i < tmpVariables.length; i++) { tmpVariables[i] =3D new Variable(""); tmpVariables[i].setCost(expectedReturnsMatrix.toBigDecimal(i, 0).negate(= )); // set the constraints on the asset weights // require at least a 8% allocation to each asset tmpVariables[i].setLowerLimit(new BigDecimal("0.08")); // require no more than 12% allocation to each asset tmpVariables[i].setUpperLimit(new BigDecimal("0.12")); } QuadraticModel quadModel =3D new QuadraticModel(tmpVariables); Expression tmpExpr =3D quadModel.addCorrelationExpression("Variance", cov= arianceMatrix.toBigStore().toArray()); BigDecimal riskAversion =3D BigMath.PI.multiply(BigMath.E); tmpExpr.setCost(riskAversion.multiply(BigMath.HALF)); // set balance expression tmpExpr =3D quadModel.addSimpleWeightExpression("Balance"); tmpExpr.setLowerLimit(BigMath.ONE); tmpExpr.setUpperLimit(BigMath.ONE); // exception here... BasicMatrix bm =3D BigMatrix.FACTORY.buildColumnVector(quadModel.getDefau= ltSolver().getSolution()); =09 System.out.print(bm.toString()); } ******************************************************************** This message and any attachment are confidential. If you are not the inten= ded recipient please contact the sender, delete this message and any attach= ment from your system and do not disclose, copy or distribute the contents = to any other person. Beach Horizon LLP (Beach Horizon) is not responsible = for any information contained in this email. Beach Horizon reserves the ri= ght to monitor all email messages passing through its network. ******************************************************************** |
From: Anders P. <an...@op...> - 2008-01-28 13:01:49
|
http://ojalgo.org/change_log.html https://sourceforge.net/project/showfiles.php?group_id=79000 /Anders SourceForge.net wrote: > Project: ojAlgo (ojalgo) > Package: ojAlgo > Date : 2008-01-27 11:48 > > Project "ojAlgo" ('ojalgo') has released the new version of package > 'ojAlgo'. > You can download it from SourceForge.net by following this link: > <https://sourceforge.net/project/showfiles.php?group_id=79000&release_id=571706> > > or browse Release Notes and ChangeLog by visiting this link: > <https://sourceforge.net/project/shownotes.php?release_id=571706> > You receive this email because you requested to be notified when new > versions > of this package were released. If you don't wish to be notified in the > future, > please login to SourceForge.net and click this link: > <https://sourceforge.net/project/filemodule_unmonitor.php?filemodule_id=80289> > > If you lost your SourceForge.net login name or password, refer to this > document: > <https://sourceforge.net/docman/display_doc.php?docid=760&group_id=1> > > Note that you may receive this message indirectly via one of your > mailing list > subscriptions. Please review message headers before reporting unsolicited > mailings. |
From: Anders P. <an...@op...> - 2008-01-24 12:59:19
|
Sorry for all the problems you're having. There is a fix in CVS. It's the ActiveSetSolver's strategy for constraint (de)activation that is problematic. Maybe I should read a book on the subject. ;-) /Anders ############################################ 0.050 <= : 0.317 (-10.012) <= 0.350 0.050 <= : 0.050 (-9.996) <= 0.350 0.050 <= : 0.050 (-10.001) <= 0.350 0.050 <= : 0.050 (-9.991) <= 0.350 0.050 <= : 0.050 (-9.998) <= 0.350 0.050 <= : 0.050 (-9.997) <= 0.350 0.050 <= : 0.083 (-10.011) <= 0.350 0.050 <= : 0.050 (-10.001) <= 0.350 0.050 <= : 0.050 (-9.997) <= 0.350 0.050 <= : 0.050 (-9.994) <= 0.350 0.050 <= : 0.050 (-9.999) <= 0.350 0.050 <= : 0.050 (-9.996) <= 0.350 0.050 <= : 0.050 (-9.987) <= 0.350 0.050 <= : 0.050 (-9.992) <= 0.350 Variance: 0.001 (4.270) 1.000 <= Balance: 1.000 <= 1.000 ############################################ On 24 jan 2008, at 13.10, Arthur McGibbon wrote: > Hi Anders, > > I've run some more tests and I get a different NullPointerException > on different data. > > If I set the variable upper bounds to "1.00" then it works but if I > set them to "0.35" as in this example then I get an error. Could > you have a look please. The underlying code seems to set the upper > bounds to "0.30" when passing in "1.00" but leaves as is with > "0.35" which I think is the max possible upper bounds. > > regards > Arthur > > > public void testojAlgo3() > { > // create expected returns matrix > PrimitiveMatrix expectedReturnsMatrix = new PrimitiveMatrix(new > double[][] { {10.012158}, {9.996046}, {10.000744}, {9.990585}, > {9.998392}, {9.996614}, {10.010531}, {10.001401}, {9.997447}, > {9.993817}, {9.998537}, {9.995741}, {9.987224}, {9.992392}}); > // create covariance matrix > PrimitiveMatrix covarianceMatrix = new PrimitiveMatrix(new double > [][] {{0.0013191354374342357, > 7.786471466322114E-5, -3.810886655309235E-5, -2.28102405899103E-4, -1. > 2589115740653127E-4, -1.3247692268411991E-5, > 1.422624656557158E-4, -2.7176361887359125E-5, > 8.675127894495302E-5, -8.116577287090551E-5, -8.468380774247271E-6, > 4.930080166695193E-5, -2.774138231533918E-4, -3.148322898570031E-5}, > {7.786471466322114E-5, 0.001028250547816086, > 8.986425197170406E-4, -1.0341435238579975E-5, 6.472902968147139E-4, > 2.9014435841747375E-4, 1.0640414444602855E-4, 5.638694128451113E-4, > 6.024515366195699E-4, -1.094867665517237E-4, > 6.177221606260711E-6, -5.682215091954099E-5, 2.7178074500896235E-4, > 0.0010146062950574643}, > {-3.810886655309235E-5, 8.986425197170406E-4, > 0.0012477403456464075, -1.8104847201530489E-4, > 9.299199981666304E-4, 3.486383951982303E-4, 1.0246402606579107E-4, > 7.009722990366382E-4, 6.545695073447614E-4, -1.1680969171500155E-4, > 7.123493385355658E-5, 1.559414390174896E-5, 1.972605480880284E-4, > 9.368808845809186E-4}, > > {-2.28102405899103E-4, -1.0341435238579975E-5, -1.8104847201530489E-4, > 6.250793590180099E-4, -5.4721911720097E-6, > 1.3081826023829458E-4, -5.644046856412501E-5, -1.1282043806099452E-5, > -6.729835202722053E-5, 1.3929681542737307E-4, 3.698155248637573E-6, > 5.0269944317023966E-5, 5.344931460074395E-4, -1.1654882792112444E-4}, > {-1.2589115740653127E-4, 6.472902968147139E-4, > 9.299199981666304E-4, -5.4721911720097E-6, 0.001181357476541527, > 3.0334522038028824E-4, 2.6983840497611894E-4, 6.983493701701867E-4, > 5.68816790613126E-4, -7.899505299987754E-5, 1.05074262063586E-5, > 1.137295188785598E-4, 1.9732025136606058E-4, 6.631330613471645E-4}, > {-1.3247692268411991E-5, 2.9014435841747375E-4, > 3.486383951982303E-4, 1.3081826023829458E-4, 3.0334522038028824E-4, > 3.372068413122505E-4, 1.1067468759384309E-4, 2.6589126866881173E-4, > 2.1364931019670806E-4, -4.201239472520589E-5, 2.32769639721745E-5, > 5.847559594073046E-6, 1.9925897592339058E-4, 1.9671375386540353E-4}, > {1.422624656557158E-4, 1.0640414444602855E-4, > 1.0246402606579107E-4, -5.644046856412501E-5, > 2.6983840497611894E-4, 1.1067468759384309E-4, 0.001484755064835215, > 1.2295961703024863E-4, > 1.0843198781689372E-4, -2.1292328294313923E-5, -4.152686600769749E-6, > 1.163599038579726E-4, -3.14739599261259E-4, 2.4519847977412686E-4}, > {-2.7176361887359125E-5, 5.638694128451113E-4, > 7.009722990366382E-4, -1.1282043806099452E-5, 6.983493701701867E-4, > 2.6589126866881173E-4, 1.2295961703024863E-4, 5.563328439145604E-4, > 4.4816730200338125E-4, -3.4729832814007256E-5, -6.028818604193519E-7, > 3.192976987126335E-5, 1.7402262469809026E-4, 5.182632389125651E-4}, > {8.675127894495302E-5, 6.024515366195699E-4, > 6.545695073447614E-4, -6.729835202722053E-5, 5.68816790613126E-4, > 2.1364931019670806E-4, 1.0843198781689372E-4, > 4.4816730200338125E-4, > 6.277134808325468E-4, -4.988229718603287E-5, -5.5018781802344255E-6, - > 1.3231260300518203E-5, 8.214207901880769E-5, 5.841470978796527E-4}, > > {-8.116577287090551E-5, -1.094867665517237E-4, -1.1680969171500155E-4, > > 1.3929681542737307E-4, -7.899505299987754E-5, -4.201239472520589E-5, - > 2.1292328294313923E-5, -3.4729832814007256E-5, -4.988229718603287E-5, > 3.5152692612068785E-4, -9.358092257358399E-6, 4.962216896551324E-6, > 1.291957229930161E-4, -1.5046975508620905E-4}, > {-8.468380774247271E-6, 6.177221606260711E-6, > 7.123493385355658E-5, 3.698155248637573E-6, 1.05074262063586E-5, > 2.32769639721745E-5, -4.152686600769749E-6, -6.028818604193519E-7, -5. > 5018781802344255E-6, -9.358092257358399E-6, 4.8495980378967104E-5, > 1.1704645004909169E-5, 1.814918597253607E-5, 1.2448218299234062E-5}, > {4.930080166695193E-5, -5.682215091954099E-5, > 1.559414390174896E-5, 5.0269944317023966E-5, 1.137295188785598E-4, > 5.847559594073046E-6, 1.163599038579726E-4, > 3.192976987126335E-5, -1.3231260300518203E-5, 4.962216896551324E-6, > 1.1704645004909169E-5, 1.802684481609152E-4, > 1.0475986793792914E-5, -4.113641419540392E-5}, > {-2.774138231533918E-4, 2.7178074500896235E-4, > 1.972605480880284E-4, 5.344931460074395E-4, 1.9732025136606058E-4, > 1.9925897592339058E-4, -3.14739599261259E-4, 1.7402262469809026E-4, > 8.214207901880769E-5, 1.291957229930161E-4, 1.814918597253607E-5, > 1.0475986793792914E-5, 7.843917688960864E-4, 1.231995848356005E-4}, > {-3.148322898570031E-5, 0.0010146062950574643, > 9.368808845809186E-4, -1.1654882792112444E-4, 6.631330613471645E-4, > 1.9671375386540353E-4, 2.4519847977412686E-4, 5.182632389125651E-4, > 5.841470978796527E-4, -1.5046975508620905E-4, > 1.2448218299234062E-5, -4.113641419540392E-5, 1.231995848356005E-4, > 0.0011885193322126312}}); > > // create asset variables - cost and weighting constraints > Variable[] tmpVariables = new Variable > [expectedReturnsMatrix.getRowDim()]; > for (int i = 0; i < tmpVariables.length; i++) > { > tmpVariables[i] = new Variable(""); > tmpVariables[i].setCost(expectedReturnsMatrix.toBigDecimal(i, > 0).negate()); > // set the constraints on the asset weights > // require at least a 2% allocation to each asset > tmpVariables[i].setLowerLimit(new BigDecimal("0.05")); > // require no more than 80% allocation to each asset > tmpVariables[i].setUpperLimit(new BigDecimal("0.35")); > // tmpVariables[i].setUpperLimit(new BigDecimal("1.00")); > } > > QuadraticModel quadModel = new QuadraticModel(tmpVariables); > > Expression tmpExpr = quadModel.addCorrelationExpression > ("Variance", covarianceMatrix.toBigStore().toArray()); > BigDecimal riskAversion = BigMath.PI.multiply(BigMath.E); > tmpExpr.setCost(riskAversion.multiply(BigMath.HALF)); > > // set balance expression > tmpExpr = quadModel.addSimpleWeightExpression("Balance"); > tmpExpr.setLowerLimit(BigMath.ONE); > tmpExpr.setUpperLimit(BigMath.ONE); > > // exception here... > BasicMatrix bm = BigMatrix.FACTORY.buildColumnVector > (quadModel.getDefaultSolver().getSolution()); > > System.out.print(bm.toString()); > } > > > ******************************************************************** > This message and any attachment are confidential. If you are not > the intended recipient please contact the sender, delete this > message and any attachment from your system and do not disclose, > copy or distribute the contents to any other person. Beach Horizon > LLP (Beach Horizon) is not responsible for any information > contained in this email. Beach Horizon reserves the right to > monitor all email messages passing through its network. > ******************************************************************** > > > ---------------------------------------------------------------------- > --- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > |
From: Arthur M. <art...@be...> - 2008-01-24 12:11:08
|
Hi Anders, I've run some more tests and I get a different NullPointerException on diff= erent data. If I set the variable upper bounds to "1.00" then it works but if I set the= m to "0.35" as in this example then I get an error. Could you have a look = please. The underlying code seems to set the upper bounds to "0.30" when p= assing in "1.00" but leaves as is with "0.35" which I think is the max poss= ible upper bounds. regards Arthur public void testojAlgo3() { // create expected returns matrix PrimitiveMatrix expectedReturnsMatrix =3D new PrimitiveMatrix(new double[= ][] { {10.012158}, {9.996046}, {10.000744}, {9.990585}, {9.998392}, {9.9966= 14}, {10.010531}, {10.001401}, {9.997447}, {9.993817}, {9.998537}, {9.99574= 1}, {9.987224}, {9.992392}}); // create covariance matrix PrimitiveMatrix covarianceMatrix =3D new PrimitiveMatrix(new double[][] {= {0.0013191354374342357, 7.786471466322114E-5, -3.810886655309235E-5, -2.281= 02405899103E-4, -1.2589115740653127E-4, -1.3247692268411991E-5, 1.422624656= 557158E-4, -2.7176361887359125E-5, 8.675127894495302E-5, -8.116577287090551= E-5, -8.468380774247271E-6, 4.930080166695193E-5, -2.774138231533918E-4, -3= .148322898570031E-5}, {7.786471466322114E-5, 0.001028250547816086, 8.986425197170406E-4, -1.0= 341435238579975E-5, 6.472902968147139E-4, 2.9014435841747375E-4, 1.06404144= 44602855E-4, 5.638694128451113E-4, 6.024515366195699E-4, -1.094867665517237= E-4, 6.177221606260711E-6, -5.682215091954099E-5, 2.7178074500896235E-4, 0.= 0010146062950574643}, {-3.810886655309235E-5, 8.986425197170406E-4, 0.0012477403456464075, -1= .8104847201530489E-4, 9.299199981666304E-4, 3.486383951982303E-4, 1.0246402= 606579107E-4, 7.009722990366382E-4, 6.545695073447614E-4, -1.16809691715001= 55E-4, 7.123493385355658E-5, 1.559414390174896E-5, 1.972605480880284E-4, 9.= 368808845809186E-4}, {-2.28102405899103E-4, -1.0341435238579975E-5, -1.8104847201530489E-4, = 6.250793590180099E-4, -5.4721911720097E-6, 1.3081826023829458E-4, -5.644046= 856412501E-5, -1.1282043806099452E-5, -6.729835202722053E-5, 1.392968154273= 7307E-4, 3.698155248637573E-6, 5.0269944317023966E-5, 5.344931460074395E-4,= -1.1654882792112444E-4}, {-1.2589115740653127E-4, 6.472902968147139E-4, 9.299199981666304E-4, -5= .4721911720097E-6, 0.001181357476541527, 3.0334522038028824E-4, 2.698384049= 7611894E-4, 6.983493701701867E-4, 5.68816790613126E-4, -7.899505299987754E-= 5, 1.05074262063586E-5, 1.137295188785598E-4, 1.9732025136606058E-4, 6.6313= 30613471645E-4}, {-1.3247692268411991E-5, 2.9014435841747375E-4, 3.486383951982303E-4, 1= .3081826023829458E-4, 3.0334522038028824E-4, 3.372068413122505E-4, 1.106746= 8759384309E-4, 2.6589126866881173E-4, 2.1364931019670806E-4, -4.20123947252= 0589E-5, 2.32769639721745E-5, 5.847559594073046E-6, 1.9925897592339058E-4, = 1.9671375386540353E-4}, {1.422624656557158E-4, 1.0640414444602855E-4, 1.0246402606579107E-4, -5= .644046856412501E-5, 2.6983840497611894E-4, 1.1067468759384309E-4, 0.001484= 755064835215, 1.2295961703024863E-4, 1.0843198781689372E-4, -2.129232829431= 3923E-5, -4.152686600769749E-6, 1.163599038579726E-4, -3.14739599261259E-4,= 2.4519847977412686E-4}, {-2.7176361887359125E-5, 5.638694128451113E-4, 7.009722990366382E-4, -1= .1282043806099452E-5, 6.983493701701867E-4, 2.6589126866881173E-4, 1.229596= 1703024863E-4, 5.563328439145604E-4, 4.4816730200338125E-4, -3.472983281400= 7256E-5, -6.028818604193519E-7, 3.192976987126335E-5, 1.7402262469809026E-4= , 5.182632389125651E-4}, {8.675127894495302E-5, 6.024515366195699E-4, 6.545695073447614E-4, -6.7= 29835202722053E-5, 5.68816790613126E-4, 2.1364931019670806E-4, 1.0843198781= 689372E-4, 4.4816730200338125E-4, 6.277134808325468E-4, -4.988229718603287E= -5, -5.5018781802344255E-6, -1.3231260300518203E-5, 8.214207901880769E-5, 5= .841470978796527E-4}, {-8.116577287090551E-5, -1.094867665517237E-4, -1.1680969171500155E-4, = 1.3929681542737307E-4, -7.899505299987754E-5, -4.201239472520589E-5, -2.129= 2328294313923E-5, -3.4729832814007256E-5, -4.988229718603287E-5, 3.51526926= 12068785E-4, -9.358092257358399E-6, 4.962216896551324E-6, 1.291957229930161= E-4, -1.5046975508620905E-4}, {-8.468380774247271E-6, 6.177221606260711E-6, 7.123493385355658E-5, 3.6= 98155248637573E-6, 1.05074262063586E-5, 2.32769639721745E-5, -4.15268660076= 9749E-6, -6.028818604193519E-7, -5.5018781802344255E-6, -9.358092257358399E= -6, 4.8495980378967104E-5, 1.1704645004909169E-5, 1.814918597253607E-5, 1.2= 448218299234062E-5}, {4.930080166695193E-5, -5.682215091954099E-5, 1.559414390174896E-5, 5.0= 269944317023966E-5, 1.137295188785598E-4, 5.847559594073046E-6, 1.163599038= 579726E-4, 3.192976987126335E-5, -1.3231260300518203E-5, 4.962216896551324E= -6, 1.1704645004909169E-5, 1.802684481609152E-4, 1.0475986793792914E-5, -4.= 113641419540392E-5}, {-2.774138231533918E-4, 2.7178074500896235E-4, 1.972605480880284E-4, 5.= 344931460074395E-4, 1.9732025136606058E-4, 1.9925897592339058E-4, -3.147395= 99261259E-4, 1.7402262469809026E-4, 8.214207901880769E-5, 1.291957229930161= E-4, 1.814918597253607E-5, 1.0475986793792914E-5, 7.843917688960864E-4, 1.2= 31995848356005E-4}, {-3.148322898570031E-5, 0.0010146062950574643, 9.368808845809186E-4, -1= .1654882792112444E-4, 6.631330613471645E-4, 1.9671375386540353E-4, 2.451984= 7977412686E-4, 5.182632389125651E-4, 5.841470978796527E-4, -1.5046975508620= 905E-4, 1.2448218299234062E-5, -4.113641419540392E-5, 1.231995848356005E-4,= 0.0011885193322126312}}); // create asset variables - cost and weighting constraints Variable[] tmpVariables =3D new Variable[expectedReturnsMatrix.getRowDim(= )]; for (int i =3D 0; i < tmpVariables.length; i++) { tmpVariables[i] =3D new Variable(""); tmpVariables[i].setCost(expectedReturnsMatrix.toBigDecimal(i, 0).negate(= )); // set the constraints on the asset weights // require at least a 2% allocation to each asset tmpVariables[i].setLowerLimit(new BigDecimal("0.05")); // require no more than 80% allocation to each asset tmpVariables[i].setUpperLimit(new BigDecimal("0.35")); // tmpVariables[i].setUpperLimit(new BigDecimal("1.00")); } QuadraticModel quadModel =3D new QuadraticModel(tmpVariables); Expression tmpExpr =3D quadModel.addCorrelationExpression("Variance", cov= arianceMatrix.toBigStore().toArray()); BigDecimal riskAversion =3D BigMath.PI.multiply(BigMath.E); tmpExpr.setCost(riskAversion.multiply(BigMath.HALF)); // set balance expression tmpExpr =3D quadModel.addSimpleWeightExpression("Balance"); tmpExpr.setLowerLimit(BigMath.ONE); tmpExpr.setUpperLimit(BigMath.ONE); // exception here... BasicMatrix bm =3D BigMatrix.FACTORY.buildColumnVector(quadModel.getDefau= ltSolver().getSolution()); =09 System.out.print(bm.toString()); } ******************************************************************** This message and any attachment are confidential. If you are not the inten= ded recipient please contact the sender, delete this message and any attach= ment from your system and do not disclose, copy or distribute the contents = to any other person. Beach Horizon LLP (Beach Horizon) is not responsible = for any information contained in this email. Beach Horizon reserves the ri= ght to monitor all email messages passing through its network. ******************************************************************** |
From: Anders P. <an...@op...> - 2008-01-23 13:34:04
|
I've updated the performance comparison page to include additions and changes for the upcoming version 22. http://ojalgo.org/matrix_compare.html /Anders |
From: Anders P. <an...@op...> - 2008-01-19 01:22:51
|
Works now. /Anders ############################################ 0.050 <= : 0.350 (-10.003) <= 0.350 0.050 <= : 0.050 (-9.990) <= 0.350 0.050 <= : 0.050 (-9.988) <= 0.350 0.050 <= : 0.050 (-9.988) <= 0.350 0.050 <= : 0.250 (-9.997) <= 0.350 0.050 <= : 0.050 (-9.991) <= 0.350 0.050 <= : 0.050 (-9.995) <= 0.350 0.050 <= : 0.050 (-9.995) <= 0.350 0.050 <= : 0.050 (-9.984) <= 0.350 0.050 <= : 0.050 (-9.988) <= 0.350 Variance: 0.001 (4.270) 1.000 <= Balance: 1.000 <= 1.000 ############################################ On 18 jan 2008, at 17.31, Arthur McGibbon wrote: > Hi Anders, > > Here's the test case for zero weightings at default risk aversion > factor. > Changing the RAF to "1" works although I'm wondering whether a > better solution would be with the 0.35% and 0.25% weights swapped > round. All other assets get a 0.05% weight. > > regards > Arthur > > public void testEfficientFrontier2() > { > // create expected returns matrix > PrimitiveMatrix expectedReturnsMatrix = new PrimitiveMatrix(new > double[][] { {10.003264}, {9.989771}, {9.987513}, {9.988449}, > {9.996579}, {9.990690}, {9.994904}, {9.994514}, {9.984064}, > {9.987534}}); > // create covariance matrix > PrimitiveMatrix covarianceMatrix = new PrimitiveMatrix(new double > [][] > {{6.483565230120298E-4, -1.3344603795915894E-4, -4.610345510893708E-4, > -7.334405624030001E-4, > 1.1551383115707195E-5, -0.00104145662863434, -1.0725896685568462E-4, - > 1.221384153392056E-4, -4.173413644389791E-4, -2.4861043894946935E-4}, > {-1.3344603795915894E-4, 0.0026045957224784455, > 0.0012394355327235707, 9.243919166568456E-4, -8.653805945112411E-5, > 8.100239312410631E-4, 4.215960274481846E-4, 5.243272007211247E-4, > 0.0013062718630332956, 1.4766450293395405E-4}, > {-4.610345510893708E-4, 0.0012394355327235707, > 0.002361436913752224, > 0.0020101714731002238, -1.4236763916609785E-5, > 0.002120395905829043, 5.399158658928662E-4, 5.048790842067473E-4, > 0.0014855261720730444, 4.841458106181396E-4}, > {-7.334405624030001E-4, 9.243919166568456E-4, > 0.0020101714731002238, > 0.0028542819089926895, -4.311102526746861E-6, > 0.0028465650900869476, 6.242643883624462E-4, 4.086484048798765E-4, > 0.001647437646316569, 7.58419663970477E-4}, > > {1.1551383115707195E-5, -8.653805945112411E-5, -1.4236763916609785E-5, > -4.311102526746861E-6, > 1.213366124417227E-4, -9.027529241741836E-5, > 7.241389994693716E-6, -3.166855950737129E-5, -1.2445276374560802E-5, - > 5.3976919759028745E-5}, > {-0.00104145662863434, 8.100239312410631E-4, > 0.002120395905829043, 0.0028465650900869476, -9.027529241741836E-5, > 0.0064756879298965295, 2.8076277564885113E-4, > 3.6082073553997553E-4, 0.001945238279500792, 0.0012421132342988626}, > {-1.0725896685568462E-4, 4.215960274481846E-4, > 5.399158658928662E-4, 6.242643883624462E-4, 7.241389994693716E-6, > 2.8076277564885113E-4, 0.0010121500024739688, 8.206099676659543E-5, > 1.6129237403855146E-4, 7.550465994733837E-4}, > {-1.221384153392056E-4, 5.243272007211247E-4, > 5.048790842067473E-4, 4.086484048798765E-4, -3.166855950737129E-5, > 3.6082073553997553E-4, 8.206099676659543E-5, 4.504461842318998E-4, > 4.7980942831718363E-4, -4.763223568683059E-5}, > {-4.173413644389791E-4, 0.0013062718630332956, > 0.0014855261720730444, > 0.001647437646316569, -1.2445276374560802E-5, 0.001945238279500792, > 1.6129237403855146E-4, 4.7980942831718363E-4, 0.002228245076175045, > 3.2083564921169634E-4}, > {-2.4861043894946935E-4, 1.4766450293395405E-4, > 4.841458106181396E-4, 7.58419663970477E-4, -5.3976919759028745E-5, > 0.0012421132342988626, 7.550465994733837E-4, -4.763223568683059E-5, > 3.2083564921169634E-4, 0.0017093327832123186}}); > > MarketEquilibrium myMarket = new MarketEquilibrium > (covarianceMatrix); > > // create asset variables - cost and weighting constraints > Variable[] tmpVariables = new Variable > [expectedReturnsMatrix.getRowDim()]; > for (int i = 0; i < tmpVariables.length; i++) > { > tmpVariables[i] = new Variable(""); > tmpVariables[i].setCost(expectedReturnsMatrix.toBigDecimal(i, > 0).negate()); > // set the constraints on the asset weights > // require at least a 2% allocation to each asset > tmpVariables[i].setLowerLimit(new BigDecimal("0.05")); > // require no more than 80% allocation to each asset > tmpVariables[i].setUpperLimit(new BigDecimal("0.35")); > } > > QuadraticModel quadModel = new QuadraticModel(tmpVariables); > > Expression tmpExpr = quadModel.addCorrelationExpression > ("Variance", covarianceMatrix.toBigStore().toArray()); > BigDecimal tmpRiskAversion = myMarket.getRiskAversion(); > tmpExpr.setCost(tmpRiskAversion.multiply(BigMath.HALF)); > > // set balance expression > tmpExpr = quadModel.addSimpleWeightExpression("Balance"); > tmpExpr.setLowerLimit(BigMath.ONE); > tmpExpr.setUpperLimit(BigMath.ONE); > > // exception here... > BasicMatrix bm = BigMatrix.FACTORY.buildColumnVector > (quadModel.getDefaultSolver().getSolution()); > > System.out.print(bm.toString()); > } > > > ******************************************************************** > This message and any attachment are confidential. If you are not > the intended recipient please contact the sender, delete this > message and any attachment from your system and do not disclose, > copy or distribute the contents to any other person. Beach Horizon > LLP (Beach Horizon) is not responsible for any information > contained in this email. Beach Horizon reserves the right to > monitor all email messages passing through its network. > ******************************************************************** > > > ---------------------------------------------------------------------- > --- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > |
From: Arthur M. <art...@be...> - 2008-01-18 16:34:40
|
Hi Anders, Here's the test case for zero weightings at default risk aversion factor. Changing the RAF to "1" works although I'm wondering whether a better solut= ion would be with the 0.35% and 0.25% weights swapped round. All other ass= ets get a 0.05% weight. regards Arthur public void testEfficientFrontier2() { // create expected returns matrix PrimitiveMatrix expectedReturnsMatrix =3D new PrimitiveMatrix(new double[= ][] { {10.003264}, {9.989771}, {9.987513}, {9.988449}, {9.996579}, {9.99069= 0}, {9.994904}, {9.994514}, {9.984064}, {9.987534}}); // create covariance matrix PrimitiveMatrix covarianceMatrix =3D new PrimitiveMatrix(new double[][] {= {6.483565230120298E-4, -1.3344603795915894E-4, -4.610345510893708E-4, -7.33= 4405624030001E-4, 1.1551383115707195E-5, -0.00104145662863434, -1.072589668= 5568462E-4, -1.221384153392056E-4, -4.173413644389791E-4, -2.48610438949469= 35E-4}, {-1.3344603795915894E-4, 0.0026045957224784455, 0.0012394355327235707, = 9.243919166568456E-4, -8.653805945112411E-5, 8.100239312410631E-4, 4.215960= 274481846E-4, 5.243272007211247E-4, 0.0013062718630332956, 1.47664502933954= 05E-4}, {-4.610345510893708E-4, 0.0012394355327235707, 0.002361436913752224, 0.= 0020101714731002238, -1.4236763916609785E-5, 0.002120395905829043, 5.399158= 658928662E-4, 5.048790842067473E-4, 0.0014855261720730444, 4.84145810618139= 6E-4}, {-7.334405624030001E-4, 9.243919166568456E-4, 0.0020101714731002238, 0.= 0028542819089926895, -4.311102526746861E-6, 0.0028465650900869476, 6.242643= 883624462E-4, 4.086484048798765E-4, 0.001647437646316569, 7.58419663970477E= -4}, {1.1551383115707195E-5, -8.653805945112411E-5, -1.4236763916609785E-5, = -4.311102526746861E-6, 1.213366124417227E-4, -9.027529241741836E-5, 7.24138= 9994693716E-6, -3.166855950737129E-5, -1.2445276374560802E-5, -5.3976919759= 028745E-5}, {-0.00104145662863434, 8.100239312410631E-4, 0.002120395905829043, 0.00= 28465650900869476, -9.027529241741836E-5, 0.0064756879298965295, 2.80762775= 64885113E-4, 3.6082073553997553E-4, 0.001945238279500792, 0.001242113234298= 8626}, {-1.0725896685568462E-4, 4.215960274481846E-4, 5.399158658928662E-4, 6.= 242643883624462E-4, 7.241389994693716E-6, 2.8076277564885113E-4, 0.00101215= 00024739688, 8.206099676659543E-5, 1.6129237403855146E-4, 7.550465994733837= E-4}, {-1.221384153392056E-4, 5.243272007211247E-4, 5.048790842067473E-4, 4.0= 86484048798765E-4, -3.166855950737129E-5, 3.6082073553997553E-4, 8.20609967= 6659543E-5, 4.504461842318998E-4, 4.7980942831718363E-4, -4.763223568683059= E-5}, {-4.173413644389791E-4, 0.0013062718630332956, 0.0014855261720730444, 0= .001647437646316569, -1.2445276374560802E-5, 0.001945238279500792, 1.612923= 7403855146E-4, 4.7980942831718363E-4, 0.002228245076175045, 3.2083564921169= 634E-4}, {-2.4861043894946935E-4, 1.4766450293395405E-4, 4.841458106181396E-4, 7= .58419663970477E-4, -5.3976919759028745E-5, 0.0012421132342988626, 7.550465= 994733837E-4, -4.763223568683059E-5, 3.2083564921169634E-4, 0.0017093327832= 123186}}); MarketEquilibrium myMarket =3D new MarketEquilibrium(covarianceMatrix); // create asset variables - cost and weighting constraints Variable[] tmpVariables =3D new Variable[expectedReturnsMatrix.getRowDim(= )]; for (int i =3D 0; i < tmpVariables.length; i++) { tmpVariables[i] =3D new Variable(""); tmpVariables[i].setCost(expectedReturnsMatrix.toBigDecimal(i, 0).negate(= )); // set the constraints on the asset weights // require at least a 2% allocation to each asset tmpVariables[i].setLowerLimit(new BigDecimal("0.05")); // require no more than 80% allocation to each asset tmpVariables[i].setUpperLimit(new BigDecimal("0.35")); } QuadraticModel quadModel =3D new QuadraticModel(tmpVariables); Expression tmpExpr =3D quadModel.addCorrelationExpression("Variance", cov= arianceMatrix.toBigStore().toArray()); BigDecimal tmpRiskAversion =3D myMarket.getRiskAversion(); tmpExpr.setCost(tmpRiskAversion.multiply(BigMath.HALF)); // set balance expression tmpExpr =3D quadModel.addSimpleWeightExpression("Balance"); tmpExpr.setLowerLimit(BigMath.ONE); tmpExpr.setUpperLimit(BigMath.ONE); // exception here... BasicMatrix bm =3D BigMatrix.FACTORY.buildColumnVector(quadModel.getDefau= ltSolver().getSolution()); =09 System.out.print(bm.toString()); } ******************************************************************** This message and any attachment are confidential. If you are not the inten= ded recipient please contact the sender, delete this message and any attach= ment from your system and do not disclose, copy or distribute the contents = to any other person. Beach Horizon LLP (Beach Horizon) is not responsible = for any information contained in this email. Beach Horizon reserves the ri= ght to monitor all email messages passing through its network. ******************************************************************** |
From: Anders P. <an...@op...> - 2008-01-18 16:22:15
|
On 18 jan 2008, at 15.39, Arthur McGibbon wrote: > Hi Anders, > > I've tested the new ActiveSetSolver version and it works with the > test dataset I sent through and many others I was having problems > with. > > I'm having some different problems now though. No more exceptions > but with some datasets I get a matrix of zeros as the weightings > but if I change the risk aversion factor from the default to 1 or > to 99 I get weightings approximating what I'd expect. ? Send me a test case, and include the "correct" result. > I also have another instance where if I increase the RAF to > something very large e.g. 99999999 the weightings matrix has > weightings that violate the bounds I have set in fact some weights > are negative when all my lower bounds are 5%. > > Is this an issue with the code or just the nature of the RAF I'm > setting? I'm guessing this is a numerical problem that is not handled/reported correctly. Send me a test case for this as well. > I can provide a code sample if you require. It's similar to before > but with different bounds and input data. Please do so, /Anders > ******************************************************************** > This message and any attachment are confidential. If you are not > the intended recipient please contact the sender, delete this > message and any attachment from your system and do not disclose, > copy or distribute the contents to any other person. Beach Horizon > LLP (Beach Horizon) is not responsible for any information > contained in this email. Beach Horizon reserves the right to > monitor all email messages passing through its network. > ******************************************************************** > > > ---------------------------------------------------------------------- > --- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Arthur M. <art...@be...> - 2008-01-18 14:39:38
|
Hi Anders, I've tested the new ActiveSetSolver version and it works with the test data= set I sent through and many others I was having problems with. I'm having some different problems now though. No more exceptions but with= some datasets I get a matrix of zeros as the weightings but if I change th= e risk aversion factor from the default to 1 or to 99 I get weightings appr= oximating what I'd expect. I also have another instance where if I increase the RAF to something very = large e.g. 99999999 the weightings matrix has weightings that violate the b= ounds I have set in fact some weights are negative when all my lower bounds= are 5%. Is this an issue with the code or just the nature of the RAF I'm setting? I can provide a code sample if you require. It's similar to before but wit= h different bounds and input data. regards Arthur ******************************************************************** This message and any attachment are confidential. If you are not the inten= ded recipient please contact the sender, delete this message and any attach= ment from your system and do not disclose, copy or distribute the contents = to any other person. Beach Horizon LLP (Beach Horizon) is not responsible = for any information contained in this email. Beach Horizon reserves the ri= ght to monitor all email messages passing through its network. ******************************************************************** |
From: Arthur M. <art...@be...> - 2008-01-17 17:54:09
|
Hi Anders, That's exactly what I want thanks a lot for the swift replies and fix regards Arthur -----Original Message----- From: oja...@li... [mailto:oja...@li...]On Behalf Of Anders Peterson Sent: 17 January 2008 17:22 To: oja...@li... Subject: Re: [ojAlgo-user] Markowitz optimisation I assume this is the solution you want: ******************************************************************** This message and any attachment are confidential. If you are not the inten= ded recipient please contact the sender, delete this message and any attach= ment from your system and do not disclose, copy or distribute the contents = to any other person. Beach Horizon LLP (Beach Horizon) is not responsible = for any information contained in this email. Beach Horizon reserves the ri= ght to monitor all email messages passing through its network. ******************************************************************** |
From: Anders P. <an...@op...> - 2008-01-17 17:22:10
|
I assume this is the solution you want: ############################################ 0.020 <= : 0.020 (0.007) <= 0.800 0.020 <= : 0.020 (0.004) <= 0.800 0.020 <= : 0.020 (0.004) <= 0.800 0.020 <= : 0.020 (0.006) <= 0.800 0.020 <= : 0.800 (-0.001) <= 0.800 0.020 <= : 0.060 (0.000) <= 0.800 0.020 <= : 0.020 (0.006) <= 0.800 0.020 <= : 0.020 (0.004) <= 0.800 0.020 <= : 0.020 (0.002) <= 0.800 Variance: 0.000 (4.270) 1.000 <= Balance: 1.000 <= 1.000 ############################################ There was a problem with the ActiveSetSolver that I've fixed now. You'll have to wait some days for a new release (or get the source from CVS). /Anders On 17 jan 2008, at 15.58, Arthur McGibbon wrote: > Hi Anders, > > Here's an example that gives an exception. Hopefully this code > will retain a semblance of formatting on emailing. > > public class TestStats extends TestCase > { > public void testEfficientFrontier() > { > // create expected returns matrix > PrimitiveMatrix expectedReturnsMatrix = new PrimitiveMatrix(new > double[][] { { -0.007155942261937039 }, > { -0.003665887902733331 }, { -0.004130184341000032 }, > { -0.005639860515211043 }, > { 0.0007211966666666817 }, { 0.0003258225000000077 }, > { -0.005754291666666666 }, > { -0.004264291666666667 }, { -0.0017500000000000003 } }); > // create covariance matrix > PrimitiveMatrix covarianceMatrix = new PrimitiveMatrix(new double > [][] { > { 0.001561410465201063, 0.00006366128201274021, > -0.0001323096896759724, 0.0000909074052724909, > 0.00003172000033558704, 0.00001955483223848944, > -0.00013771504482647386, -0.00004858457275314645, > -0.000012954723060403266 }, > { 0.00006366128201274021, 0.00016419786524761803, > -0.00001566288911558343, -0.00008688646089751923, > 0.0000027349925543017186, 0.0000012356159598500247, > -0.000024367796639005863, -0.000017576048221096555, > -0.0000070052245518771815 }, > { -0.0001323096896759724, -0.00001566288911558343, > 0.0001430155985985913, 0.00007675339168559199, > -0.00007600590426518823, 0.000032976538909267937, > 0.00009520305608240259, 0.00007373075639042642, > -0.000007477057858706954 }, > { 0.0000909074052724909, -0.00008688646089751923, > 0.00007675339168559199, 0.000967519991100896, > -0.0000533460293834595, 0.00008665760416026126, > 0.00014591175388747613, 0.0001232364989586903, > 0.00011097998789484925 }, > { 0.00003172000033558704, 0.0000027349925543017186, > -0.00007600590426518823, -0.0000533460293834595, > 0.000025267064307337795, -0.00003089584520279407, > -0.00005593123237578969, -0.000017013960349712132, > 0.0000013056146551724419 }, > { 0.00001955483223848944, 0.0000012356159598500247, > 0.000032976538909267937, 0.00008665760416026126, > -0.00003089584520279407, 0.0001625499447274783, > 0.00008242949058588471, 0.00010276895784859992, > 0.0000005898510775862205 }, > { -0.00013771504482647386, -0.000024367796639005863, > 0.00009520305608240259, 0.00014591175388747613, > -0.00005593123237578969, 0.00008242949058588471, > 0.000560956958802083, 0.0002838794236862429, > 0.00009143821659482758 }, > { -0.00004858457275314645, -0.000017576048221096555, > 0.00007373075639042642, 0.0001232364989586903, > -0.000017013960349712132, 0.00010276895784859992, > 0.0002838794236862429, 0.00021068964250359204, > 0.00004461044181034483 }, > { -0.000012954723060403266, -0.0000070052245518771815, > -0.000007477057858706954, 0.00011097998789484925, > 0.0000013056146551724419, 0.0000005898510775862205, > 0.00009143821659482758, 0.00004461044181034483, > 0.00006761920797413792 } }); > > MarketEquilibrium myMarket = new MarketEquilibrium > (covarianceMatrix); > > // create asset variables - cost and weighting constraints > Variable[] tmpVariables = new Variable > [expectedReturnsMatrix.getRowDim()]; > for (int i = 0; i < tmpVariables.length; i++) > { > tmpVariables[i] = new Variable(""); > tmpVariables[i].setCost(expectedReturnsMatrix.toBigDecimal(i, > 0).negate()); > // set the constraints on the asset weights > // require at least a 2% allocation to each asset > tmpVariables[i].setLowerLimit(new BigDecimal("0.02")); > // require no more than 80% allocation to each asset > tmpVariables[i].setUpperLimit(new BigDecimal("0.80")); > } > > QuadraticModel quadModel = new QuadraticModel(tmpVariables); > > Expression tmpExpr = quadModel.addCorrelationExpression > ("Variance", covarianceMatrix.toBigStore().toArray()); > BigDecimal tmpRiskAversion = myMarket.getRiskAversion(); > tmpExpr.setCost(tmpRiskAversion.multiply(BigMath.HALF)); > > // set balance expression > tmpExpr = quadModel.addSimpleWeightExpression("Balance"); > tmpExpr.setLowerLimit(BigMath.ONE); > tmpExpr.setUpperLimit(BigMath.ONE); > > // exception here... > BigMatrix.FACTORY.buildColumnVector(quadModel.getDefaultSolver > ().getSolution()); > } > } > > > ******************************************************************** > This message and any attachment are confidential. If you are not > the intended recipient please contact the sender, delete this > message and any attachment from your system and do not disclose, > copy or distribute the contents to any other person. Beach Horizon > LLP (Beach Horizon) is not responsible for any information > contained in this email. Beach Horizon reserves the right to > monitor all email messages passing through its network. > ******************************************************************** > > > ---------------------------------------------------------------------- > --- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > |
From: Arthur M. <art...@be...> - 2008-01-17 14:59:03
|
Hi Anders, Here's an example that gives an exception. Hopefully this code will retain= a semblance of formatting on emailing. public class TestStats extends TestCase { public void testEfficientFrontier() { // create expected returns matrix PrimitiveMatrix expectedReturnsMatrix =3D new PrimitiveMatrix(new double[= ][] { { -0.007155942261937039 }, { -0.003665887902733331 }, { -0.004130184341000032 }, { -0.005639860515= 211043 }, { 0.0007211966666666817 }, { 0.0003258225000000077 }, { -0.005754291666= 666666 }, { -0.004264291666666667 }, { -0.0017500000000000003 } }); // create covariance matrix PrimitiveMatrix covarianceMatrix =3D new PrimitiveMatrix(new double[][] { { 0.001561410465201063, 0.00006366128201274021, -0.0001323096896= 759724, 0.0000909074052724909, 0.00003172000033558704, 0.00001955483= 223848944, -0.00013771504482647386, -0.00004858457275314645, -0.0000129= 54723060403266 }, { 0.00006366128201274021, 0.00016419786524761803, -0.0000156628891= 1558343, -0.00008688646089751923, 0.0000027349925543017186, 0.00000123561= 59598500247, -0.000024367796639005863, -0.000017576048221096555, -0.0000070= 052245518771815 }, { -0.0001323096896759724, -0.00001566288911558343, 0.0001430155985= 985913, 0.00007675339168559199, -0.00007600590426518823, 0.00003297653= 8909267937, 0.00009520305608240259, 0.00007373075639042642, -0.0000074= 77057858706954 }, { 0.0000909074052724909, -0.00008688646089751923, 0.0000767533916= 8559199, 0.000967519991100896, -0.0000533460293834595, 0.00008665760= 416026126, 0.00014591175388747613, 0.0001232364989586903, 0.0001109= 7998789484925 }, { 0.00003172000033558704, 0.0000027349925543017186, -0.0000760059042= 6518823, -0.0000533460293834595, 0.000025267064307337795, -0.00003089584= 520279407, -0.00005593123237578969, -0.000017013960349712132, 0.0000013= 056146551724419 }, { 0.00001955483223848944, 0.0000012356159598500247, 0.0000329765389= 09267937, 0.00008665760416026126, -0.00003089584520279407, 0.00016254994= 47274783, 0.00008242949058588471, 0.00010276895784859992, 0.0000005= 898510775862205 }, { -0.00013771504482647386, -0.000024367796639005863, 0.0000952030560= 8240259, 0.00014591175388747613, -0.00005593123237578969, 0.00008242949= 058588471, 0.000560956958802083, 0.0002838794236862429, 0.0000914= 3821659482758 }, { -0.00004858457275314645, -0.000017576048221096555, 0.0000737307563= 9042642, 0.0001232364989586903, -0.000017013960349712132, 0.00010276895= 784859992, 0.0002838794236862429, 0.00021068964250359204, 0.0000446= 1044181034483 }, { -0.000012954723060403266, -0.0000070052245518771815, -0.0000074770578= 58706954, 0.00011097998789484925, 0.0000013056146551724419, 0.00000058985= 10775862205, 0.00009143821659482758, 0.00004461044181034483, 0.0000676= 1920797413792 } }); MarketEquilibrium myMarket =3D new MarketEquilibrium(covarianceMatrix); // create asset variables - cost and weighting constraints Variable[] tmpVariables =3D new Variable[expectedReturnsMatrix.getRowDim(= )]; for (int i =3D 0; i < tmpVariables.length; i++) { tmpVariables[i] =3D new Variable(""); tmpVariables[i].setCost(expectedReturnsMatrix.toBigDecimal(i, 0).negate(= )); // set the constraints on the asset weights // require at least a 2% allocation to each asset tmpVariables[i].setLowerLimit(new BigDecimal("0.02")); // require no more than 80% allocation to each asset tmpVariables[i].setUpperLimit(new BigDecimal("0.80")); } QuadraticModel quadModel =3D new QuadraticModel(tmpVariables); Expression tmpExpr =3D quadModel.addCorrelationExpression("Variance", cov= arianceMatrix.toBigStore().toArray()); BigDecimal tmpRiskAversion =3D myMarket.getRiskAversion(); tmpExpr.setCost(tmpRiskAversion.multiply(BigMath.HALF)); // set balance expression tmpExpr =3D quadModel.addSimpleWeightExpression("Balance"); tmpExpr.setLowerLimit(BigMath.ONE); tmpExpr.setUpperLimit(BigMath.ONE); // exception here... BigMatrix.FACTORY.buildColumnVector(quadModel.getDefaultSolver().getSolut= ion()); } } ******************************************************************** This message and any attachment are confidential. If you are not the inten= ded recipient please contact the sender, delete this message and any attach= ment from your system and do not disclose, copy or distribute the contents = to any other person. Beach Horizon LLP (Beach Horizon) is not responsible = for any information contained in this email. Beach Horizon reserves the ri= ght to monitor all email messages passing through its network. ******************************************************************** |
From: Anders P. <an...@op...> - 2008-01-17 08:25:43
|
On 17 jan 2008, at 01.38, Arthur McGibbon wrote: > Hi Anders, > > thanks for your reply and the link. > > I am indeed trying to maximise sharpe ratio (at zero risk free > rate) using your library. > > I can run the MarkowitzModel.calculatePortfolioWeights method fine > as is but I'm trying to apply weighting constraints to the assets > (limits of 5% -> 55% with 10 assets). I looked in the > MarkowitzModel code and saw that the limitation on shorting was > applied by using the setLowerLimit(ZERO) on the variables and > assumed that I could use the same method in conjunction with the > setUpperLimit (passing values of 0.05 and 0.55) however this > results in NullPointerException on certain combinations of returns. Can you give me a code example that generates a NullPointerException? > I mentioned Risk Aversion Factor before because I assumed my error > was there as some RAFs generated exceptions and some didn't but it > looks as though my assumption on how to apply weighting limits was > incorrect so could you tell me whether it's possible to apply min > and max weighting limits to the assets using ojAlgo? I don't think your assumption is wrong, and I'd like to know about those exceptions. Give me code snippets that I can run. /Anders > -----Original Message----- >> From: oja...@li... > [mailto:oja...@li...]On Behalf Of Anders > Peterson > Sent: 16 January 2008 22:41 > To: oja...@li... > Subject: Re: [ojAlgo-user] Markowitz optimisation > > > On 16 jan 2008, at 15.36, Arthur McGibbon wrote: >> Hi, >> >> I've been using the MarkowitzModel code to optimise the weighting >> across assets within a portfolio but what I ideally want is the >> weights for the maximum return/risk ratio possible with the >> constraints passed (i.e. the maximum slope on the efficient >> frontier going through the origin). >> > http://en.wikipedia.org/wiki/ > Modern_portfolio_theory#The_market_portfolio >> Is it possible to use the QuadraticModel to solve for this maximum >> given the expected returns and covariance matrices? >> If so - could you give me some pointers on how to do this? >> Also - would this lead to not using a Risk Aversion Factor as the >> maximum return/risk ratio should lead to a single point on the line >> or have I got the wrong idea about what the Risk Aversion Factor is? >> > I think you're the one who should know which (mathematical) problem > you want to solve. > > When if you have more specific questions related to ojAlgo source > code I'll be glad to try and help. > > /Anders > > ---------------------------------------------------------------------- > --- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > > ******************************************************************** > This message and any attachment are confidential. If you are not > the intended recipient please contact the sender, delete this > message and any attachment from your system and do not disclose, > copy or distribute the contents to any other person. Beach Horizon > LLP (Beach Horizon) is not responsible for any information > contained in this email. Beach Horizon reserves the right to > monitor all email messages passing through its network. > ******************************************************************** > > > ---------------------------------------------------------------------- > --- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > |
From: Arthur M. <art...@be...> - 2008-01-17 00:38:31
|
Hi Anders, thanks for your reply and the link. I am indeed trying to maximise sharpe ratio (at zero risk free rate) using = your library. I can run the MarkowitzModel.calculatePortfolioWeights method fine as is bu= t I'm trying to apply weighting constraints to the assets (limits of 5% -> = 55% with 10 assets). I looked in the MarkowitzModel code and saw that the = limitation on shorting was applied by using the setLowerLimit(ZERO) on the = variables and assumed that I could use the same method in conjunction with = the setUpperLimit (passing values of 0.05 and 0.55) however this results in= NullPointerException on certain combinations of returns. I mentioned Risk Aversion Factor before because I assumed my error was ther= e as some RAFs generated exceptions and some didn't but it looks as though = my assumption on how to apply weighting limits was incorrect so could you t= ell me whether it's possible to apply min and max weighting limits to the a= ssets using ojAlgo? kind regards Arthur -----Original Message----- From: oja...@li... [mailto:oja...@li...]On Behalf Of Anders Peterson Sent: 16 January 2008 22:41 To: oja...@li... Subject: Re: [ojAlgo-user] Markowitz optimisation On 16 jan 2008, at 15.36, Arthur McGibbon wrote: > Hi, > > I've been using the MarkowitzModel code to optimise the weighting =20 > across assets within a portfolio but what I ideally want is the =20 > weights for the maximum return/risk ratio possible with the =20 > constraints passed (i.e. the maximum slope on the efficient =20 > frontier going through the origin). > http://en.wikipedia.org/wiki/=20 Modern_portfolio_theory#The_market_portfolio > Is it possible to use the QuadraticModel to solve for this maximum =20 > given the expected returns and covariance matrices? > If so - could you give me some pointers on how to do this? > Also - would this lead to not using a Risk Aversion Factor as the =20 > maximum return/risk ratio should lead to a single point on the line =20 > or have I got the wrong idea about what the Risk Aversion Factor is? > I think you're the one who should know which (mathematical) problem =20 you want to solve. When if you have more specific questions related to ojAlgo source =20 code I'll be glad to try and help. /Anders ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ ojAlgo-user mailing list ojA...@li... https://lists.sourceforge.net/lists/listinfo/ojalgo-user ******************************************************************** This message and any attachment are confidential. If you are not the inten= ded recipient please contact the sender, delete this message and any attach= ment from your system and do not disclose, copy or distribute the contents = to any other person. Beach Horizon LLP (Beach Horizon) is not responsible = for any information contained in this email. Beach Horizon reserves the ri= ght to monitor all email messages passing through its network. ******************************************************************** |
From: Anders P. <an...@op...> - 2008-01-16 22:40:42
|
On 16 jan 2008, at 15.36, Arthur McGibbon wrote: > Hi, > > I've been using the MarkowitzModel code to optimise the weighting > across assets within a portfolio but what I ideally want is the > weights for the maximum return/risk ratio possible with the > constraints passed (i.e. the maximum slope on the efficient > frontier going through the origin). > http://en.wikipedia.org/wiki/ Modern_portfolio_theory#The_market_portfolio > Is it possible to use the QuadraticModel to solve for this maximum > given the expected returns and covariance matrices? > If so - could you give me some pointers on how to do this? > Also - would this lead to not using a Risk Aversion Factor as the > maximum return/risk ratio should lead to a single point on the line > or have I got the wrong idea about what the Risk Aversion Factor is? > I think you're the one who should know which (mathematical) problem you want to solve. When if you have more specific questions related to ojAlgo source code I'll be glad to try and help. /Anders |
From: Arthur M. <art...@be...> - 2008-01-16 14:37:11
|
Hi, I've been using the MarkowitzModel code to optimise the weighting across as= sets within a portfolio but what I ideally want is the weights for the maxi= mum return/risk ratio possible with the constraints passed (i.e. the maximu= m slope on the efficient frontier going through the origin). Is it possible to use the QuadraticModel to solve for this maximum given th= e expected returns and covariance matrices? If so - could you give me some pointers on how to do this? Also - would this lead to not using a Risk Aversion Factor as the maximum r= eturn/risk ratio should lead to a single point on the line or have I got th= e wrong idea about what the Risk Aversion Factor is? regards Arthur ******************************************************************** This message and any attachment are confidential. If you are not the inten= ded recipient please contact the sender, delete this message and any attach= ment from your system and do not disclose, copy or distribute the contents = to any other person. Beach Horizon LLP (Beach Horizon) is not responsible = for any information contained in this email. Beach Horizon reserves the ri= ght to monitor all email messages passing through its network. ******************************************************************** |
From: Anders P. <an...@op...> - 2008-01-11 08:46:23
|
Yes there was a problem connecting to the database. It is fixed now. Thanks for bringing this to my attention, /Anders On 10 jan 2008, at 13.13, Paul Netherwood wrote: > I'm getting a NullPointerException when I try to create a new user > in BLApp. It looks like its on a database insert. Is the database > up and running? > > > ******************************************************************** > This message and any attachment are confidential. If you are not > the intended recipient please contact the sender, delete this > message and any attachment from your system and do not disclose, > copy or distribute the contents to any other person. Beach Horizon > LLP (Beach Horizon) is not responsible for any information > contained in this email. Beach Horizon reserves the right to > monitor all email messages passing through its network. > ******************************************************************** > > > ---------------------------------------------------------------------- > --- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/ > marketplace > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Paul N. <pau...@be...> - 2008-01-10 12:14:39
|
I'm getting a NullPointerException when I try to create a new user in BLApp= . It looks like its on a database insert. Is the database up and running? ******************************************************************** This message and any attachment are confidential. If you are not the inten= ded recipient please contact the sender, delete this message and any attach= ment from your system and do not disclose, copy or distribute the contents = to any other person. Beach Horizon LLP (Beach Horizon) is not responsible = for any information contained in this email. Beach Horizon reserves the ri= ght to monitor all email messages passing through its network. ******************************************************************** |