ojalgo-user Mailing List for oj! Algorithms (Page 21)
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: Anders P. <an...@op...> - 2009-10-19 12:26:30
|
On 19 okt 2009, at 12.18, David Stynes wrote: > We have tried on problems with up to 2400 variables and 200 > constraints/rows > and it solves it quickly (1.6~ seconds). Copied below is a complete > case > which causes the problem described (for any .mps file I can give it): That sound s really good to me. How many of the variables are integer variables? > ... > > I am using v28 of ojAlgo, and running it through Eclipse 3.5. Stepping > through it I find that the thread is created at this point of > BigDenseStore, > in the method fillMatching: > > ... > > The Future object's thread never seems to stop running though I am > not sure > why not. Should have realized this from the beginning. ojAlgo keeps a ThreadPoolExecutor instance with a non-zero core pool size. This is used all the time by ojAlgo for all sorts of things. You have to "quit" your program. http://ojalgo.org/generated/org/ojalgo/concurrent/ConcurrentUtils.html#EXECUTOR /Anders > -----Original Message----- >> From: Anders Peterson [mailto:an...@op...] > Sent: 16 October 2009 22:05 > To: oja...@li... > Cc: j.f...@4c... > Subject: Re: [ojAlgo-user] optimizing from a .mps file > > On 16 okt 2009, at 14.25, David Stynes wrote: > >> Hello, >> I am trying to use ojAlgo to read from a .mps file and use Linear/ >> Mixed >> Integer Programming to solve it. Currently the code for this is as >> follows: >> >> MathProgSysModel mps = MathProgSysModel.makeFromFile(aFile); >> OptimisationSolver os = mps.getDefaultSolver(); >> Result rs = os.solve(); >> >> This runs correctly and solves the .mps input file as desired. > > > Should have written somewhere that the MIP solver is new and > experimental - glad to hear that it solves your problem. How big is > it? > > >> However the >> second line (calling getDefaultSolver()) appears to start an >> additional >> thread running or something, as the java process does not stop after >> the >> rest of my code finishes (but the remaining code after this line >> does get >> executed). Is this intended, and/or am I using it incorrectly and >> how can I >> use it correctly to prevent the java process continuing to be active >> indefinitely instead of closing? > > > The MIP solver is multithreaded, but I don't see why any additional > threads should be created before you call solve(). > > I have a number of junit tests that basically do what you do. As far > as I can see they terminate as expected. > > Could you step through the code and tell me more precisely where that > thread is created? > > > /Anders > > >> Thanks, >> David >> >> >> > ---------------------------------------------------------------------------- > -- >> Come build with us! The BlackBerry(R) Developer Conference in SF, CA >> is the only developer event you need to attend this year. Jumpstart >> your >> developing skills, take BlackBerry mobile applications to market and >> stay >> ahead of the curve. Join us from November 9 - 12, 2009. Register now! >> http://p.sf.net/sfu/devconference >> _______________________________________________ >> ojAlgo-user mailing list >> ojA...@li... >> https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > ---------------------------------------------------------------------------- > -- > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart > your > developing skills, take BlackBerry mobile applications to market and > stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart > your > developing skills, take BlackBerry mobile applications to market and > stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > |
From: David S. <d.s...@4c...> - 2009-10-19 10:50:38
|
We have tried on problems with up to 2400 variables and 200 constraints/rows and it solves it quickly (1.6~ seconds). Copied below is a complete case which causes the problem described (for any .mps file I can give it): import java.io.File; import org.ojalgo.optimisation.OptimisationSolver; import org.ojalgo.optimisation.OptimisationSolver.Result; import org.ojalgo.optimisation.linear.mps.MathProgSysModel; public class Temp2 { public static void main(String[] args) { File aFile = new File("temp.mps"); MathProgSysModel mps = MathProgSysModel.makeFromFile(aFile); OptimisationSolver os = mps.getDefaultSolver(); Result rs = os.solve(); System.out.println( rs.getSolution() ); } } I am using v28 of ojAlgo, and running it through Eclipse 3.5. Stepping through it I find that the thread is created at this point of BigDenseStore, in the method fillMatching: public void fillMatching(final MatrixStore<BigDecimal> aLeftArg, final BinaryFunction<BigDecimal> aFunc, final MatrixStore<BigDecimal> aRightArg) { final BigDenseStore tmpLeftArg = this.cast(aLeftArg); final BigDenseStore tmpRightArg = this.cast(aRightArg); final int tmpLength = length; final int tmpHalf = tmpLength / 2; final Future<?> tmpFirstHalf = ConcurrentUtils.EXECUTOR.submit(new Runnable() { public void run() { BigDenseStore.this.fill(0, tmpHalf, tmpLeftArg, aFunc, tmpRightArg); } }); this.fill(tmpHalf, tmpLength, tmpLeftArg, aFunc, tmpRightArg); try { tmpFirstHalf.get(); } catch (final InterruptedException anException) { anException.printStackTrace(); } catch (final ExecutionException anException) { anException.printStackTrace(); } } The Future object's thread never seems to stop running though I am not sure why not. Regards, David -----Original Message----- From: Anders Peterson [mailto:an...@op...] Sent: 16 October 2009 22:05 To: oja...@li... Cc: j.f...@4c... Subject: Re: [ojAlgo-user] optimizing from a .mps file On 16 okt 2009, at 14.25, David Stynes wrote: > Hello, > I am trying to use ojAlgo to read from a .mps file and use Linear/ > Mixed > Integer Programming to solve it. Currently the code for this is as > follows: > > MathProgSysModel mps = MathProgSysModel.makeFromFile(aFile); > OptimisationSolver os = mps.getDefaultSolver(); > Result rs = os.solve(); > > This runs correctly and solves the .mps input file as desired. Should have written somewhere that the MIP solver is new and experimental - glad to hear that it solves your problem. How big is it? > However the > second line (calling getDefaultSolver()) appears to start an > additional > thread running or something, as the java process does not stop after > the > rest of my code finishes (but the remaining code after this line > does get > executed). Is this intended, and/or am I using it incorrectly and > how can I > use it correctly to prevent the java process continuing to be active > indefinitely instead of closing? The MIP solver is multithreaded, but I don't see why any additional threads should be created before you call solve(). I have a number of junit tests that basically do what you do. As far as I can see they terminate as expected. Could you step through the code and tell me more precisely where that thread is created? /Anders > Thanks, > David > > > ---------------------------------------------------------------------------- -- > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart > your > developing skills, take BlackBerry mobile applications to market and > stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user ---------------------------------------------------------------------------- -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ ojAlgo-user mailing list ojA...@li... https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Anders P. <an...@op...> - 2009-10-16 21:21:32
|
On 16 okt 2009, at 14.25, David Stynes wrote: > Hello, > I am trying to use ojAlgo to read from a .mps file and use Linear/ > Mixed > Integer Programming to solve it. Currently the code for this is as > follows: > > MathProgSysModel mps = MathProgSysModel.makeFromFile(aFile); > OptimisationSolver os = mps.getDefaultSolver(); > Result rs = os.solve(); > > This runs correctly and solves the .mps input file as desired. Should have written somewhere that the MIP solver is new and experimental - glad to hear that it solves your problem. How big is it? > However the > second line (calling getDefaultSolver()) appears to start an > additional > thread running or something, as the java process does not stop after > the > rest of my code finishes (but the remaining code after this line > does get > executed). Is this intended, and/or am I using it incorrectly and > how can I > use it correctly to prevent the java process continuing to be active > indefinitely instead of closing? The MIP solver is multithreaded, but I don't see why any additional threads should be created before you call solve(). I have a number of junit tests that basically do what you do. As far as I can see they terminate as expected. Could you step through the code and tell me more precisely where that thread is created? /Anders > Thanks, > David > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart > your > developing skills, take BlackBerry mobile applications to market and > stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: David S. <d.s...@4c...> - 2009-10-16 14:36:47
|
Hello, I am trying to use ojAlgo to read from a .mps file and use Linear/Mixed Integer Programming to solve it. Currently the code for this is as follows: MathProgSysModel mps = MathProgSysModel.makeFromFile(aFile); OptimisationSolver os = mps.getDefaultSolver(); Result rs = os.solve(); This runs correctly and solves the .mps input file as desired. However the second line (calling getDefaultSolver()) appears to start an additional thread running or something, as the java process does not stop after the rest of my code finishes (but the remaining code after this line does get executed). Is this intended, and/or am I using it incorrectly and how can I use it correctly to prevent the java process continuing to be active indefinitely instead of closing? Thanks, David |
From: Anders P. <an...@op...> - 2009-08-28 10:59:09
|
http://ojalgo.org/release.html /Anders |
From: Anders P. <an...@op...> - 2009-08-20 08:40:52
|
http://ojalgo.org/performance.html On 19 maj 2009, at 09.23, Anders Peterson wrote: > If anyone is interested. These are the numbers (performance test > results) for v27.11: > > http://ojalgo.org/generated/iMacComparison.xml > http://ojalgo.org/generated/MacProComparison.xml > http://ojalgo.org/generated/Performance.xls > > /Anders > > > On 24 apr 2009, at 08.53, Anders Peterson wrote: > >> Generally all hardware should be "better" on the new MacPro compared >> to the old iMac. In terms of installed software the two computers >> should be near identical. Among the first things I did was to run the >> ojAlgo performance tests. I was rather surprised: >> >> 1) The overall/total execution time was not much shorter. Something >> like 10%. I expected more. >> 2) Some operations were actually slower on the new MacPro. >> 3) Most (if not all) of the code that performed slower on the MacPro >> was Jama related. The other, pure ojAlgo, code generally performed >> better. >> >> Hare are the results of the performance tests on both the iMac and >> the >> MacPro >> >> http://ojalgo.org/generated/iMacComparison.xml >> http://ojalgo.org/generated/MacProComparison.xml >> >> /Anders >> >> >> >> ------------------------------------------------------------------------------ >> Crystal Reports - New Free Runtime and 30 Day Trial >> Check out the new simplified licensign option that enables unlimited >> royalty-free distribution of the report engine for externally >> facing >> server and web deployment. >> http://p.sf.net/sfu/businessobjects >> _______________________________________________ >> ojAlgo-user mailing list >> ojA...@li... >> https://lists.sourceforge.net/lists/listinfo/ojalgo-user >> >> > |
From: Anders P. <an...@op...> - 2009-07-26 21:18:25
|
Try setting the risk aversion factor to something other than 1.0. and/or do this: a) Do NOT set the target return or variance. b) Experiment with different risk aversion factors. Which risk aversion factors gives you portfolio returns 0.003081388 and 0.03360872? (the lowest and highest instrument returns) /Anders On 26 jul 2009, at 12.23, Nilesh Parekh wrote: > Hi..this is slighly modifed version of the already posted issue on > this forum earlier. > I am using ojalgo 2.6 & also tried same code with new beta 2.7 > version but the issue still persists > Below code works fails if i set the expected return to > markowitzModel.setTargetReturn(new BigDecimal("0.01051787")); > any value between 0.01051787 and 0.003081388 (which is the lowest > return in the return matrix) gives same output. > Note: Values (expected rerurn) between 0.01051787 and 0.03360872 > (max. return as per return matrix) works perfectly fine. > Do revert in case of any further clarifications. > --------START CODE--------------- > import java.math.BigDecimal; > import java.util.List; > > import org.ojalgo.finance.portfolio.MarketEquilibrium; > import org.ojalgo.finance.portfolio.MarkowitzModel; > import org.ojalgo.matrix.*; > import org.ojalgo.matrix.store.BigDenseStore; > import org.ojalgo.matrix.store.MatrixStore; > > > public class TestMarkowitz { > > public BasicMatrix getACovariances(double[][] returns){ > > int row = returns.length; > int col = returns[0].length; > MatrixStore<BigDecimal> a = BigDenseStore.FACTORY.makeZero(row, > col); > BasicMatrix covariances = new BigMatrix(a); > > for(int i=1;i<=row;i++){ > for(int j=i;j<=col;j++){ > covariances = covariances.set(i-1, j-1,returns[i-1][j-1]); > covariances = covariances.set(j-1, i-1,returns[j-1][i-1]); > } > > } > return covariances; > } > > > public static void main(String[] args) > { > int assetNum=16; > > > double[][] om={ > {0.003330616,0.003524811,0.00386567,0.003656347,0.004494241,0.004623772,0.00458625,0.004365933,0,0,0,0,0,0,0,0 > }, > {0.003524811,0.004274864,0.004372518,0.004135748,0.005144421,0.005292691,0.005249742,0.004997551,0,0,0,0,0,0,0,0 > }, > {0.00386567,0.004372518,0.005114057,0.004535687,0.005641369,0.005803962,0.005756863,0.005480312,0,0,0,0,0,0,0,0 > }, > {0.003656347,0.004135748,0.004535687,0.004728464,0.005511769,0.005670626,0.00562461,0.005354411,0,0,0,0,0,0,0,0 > }, > {0.004494241,0.005144421,0.005641369,0.005511769,0.007284319,0.006518612,0.006359324,0.00635862,0,0,0,0,0,0,0,0 > }, > {0.004623772,0.005292691,0.005803962,0.005670626,0.006518612,0.007542516,0.006562129,0.006561403,0,0,0,0,0,0,0,0 > }, > {0.00458625,0.005249742,0.005756863,0.00562461,0.006359324,0.006562129,0.007513433,0.00640107,0,0,0,0,0,0,0,0 > }, > {0.004365933,0.004997551,0.005480312,0.005354411,0.00635862,0.006561403,0.00640107,0.006805889,0,0,0,0,0,0,0,0 > }, > {0,0,0,0,0,0,0,0,0.000152891,0.000120753,7.98783E > -05,0.000116607,8.11225E-05,4.31112E-05,6.11874E-05,1.49376E-07}, > {0,0,0,0,0,0,0,0,0.000120753,0.000215819,0.000108447,0.000158311,7.62318E > -05,4.05121E-05,5.74986E-05,1.4037E-07}, > {0,0,0,0,0,0,0,0,7.98783E > -05,0.000108447,0.000251455,0.000104723,0.000105337,5.59796E > -05,7.94514E-05,1.93963E-07}, > {0,0,0,0,0,0,0,0,0.000116607,0.000158311,0.000104723,0.000285454,0.000109622,5.82568E > -05,8.26835E-05,2.01854E-07}, > {0,0,0,0,0,0,0,0,8.11225E > -05,7.62318E > -05,0.000105337,0.000109622,0.000110962,5.62808E > -05,7.47961E-05,1.97502E-06}, > {0,0,0,0,0,0,0,0,4.31112E > -05,4.05121E > -05,5.59796E > -05,5.82568E-05,5.62808E-05,4.12145E-05,4.25652E-05,1.12395E-06}, > {0,0,0,0,0,0,0,0,6.11874E > -05,5.74986E > -05,7.94514E > -05,8.26835E-05,7.47961E-05,4.25652E-05,7.62351E-05,1.4937E-06}, > {0,0,0,0,0,0,0,0,1.49376E > -07,1.4037E > -07,1.93963E > -07,2.01854E-07,1.97502E-06,1.12395E-06,1.4937E-06,6.52443E-06} > }; > > TestMarkowitz tm = new TestMarkowitz(); > > BasicMatrix covariances = tm.getACovariances(om); > > System.out.println(covariances); > > BigDecimal riskAversion = new BigDecimal(1.0); > > MarketEquilibrium marketEquilibrium = new > MarketEquilibrium(covariances,riskAversion); > > MatrixStore<BigDecimal> ret_matrix = BigDenseStore.FACTORY.makeZero > (assetNum, 1); > BasicMatrix expectedExcessReturns1 = new BigMatrix(ret_matrix); > > expectedExcessReturns1 = expectedExcessReturns1.set(0,0,0.03360872); > expectedExcessReturns1 = expectedExcessReturns1.set(1,0,0.027322319); > expectedExcessReturns1 = expectedExcessReturns1.set(2,0,0.027668137); > expectedExcessReturns1 = expectedExcessReturns1.set(3,0,0.03080239); > expectedExcessReturns1 = expectedExcessReturns1.set(4,0,0.025067124); > expectedExcessReturns1 = expectedExcessReturns1.set(5,0,0.016578507); > expectedExcessReturns1 = expectedExcessReturns1.set(6,0,0.022622714); > expectedExcessReturns1 = expectedExcessReturns1.set(7,0,0.028957183); > expectedExcessReturns1 = expectedExcessReturns1.set(8,0,0.009939058); > expectedExcessReturns1 = expectedExcessReturns1.set(9,0,0.010014445); > expectedExcessReturns1 = expectedExcessReturns1.set(10,0,0.011565874); > expectedExcessReturns1 = expectedExcessReturns1.set(11,0,0.011609169); > expectedExcessReturns1 = expectedExcessReturns1.set(12,0,0.006286505); > expectedExcessReturns1 = expectedExcessReturns1.set(13,0,0.004240681); > expectedExcessReturns1 = expectedExcessReturns1.set(14,0,0.006162067); > expectedExcessReturns1 = expectedExcessReturns1.set(15,0,0.003081388); > > System.out.println("Return Matrix" + expectedExcessReturns1); > > MarkowitzModel markowitzModel = new > MarkowitzModel(marketEquilibrium,expectedExcessReturns1); > > markowitzModel.setTargetReturn(new BigDecimal("0.01051787")); > > for(int i=0;i<assetNum;i++){ > markowitzModel.setLowerLimit(i, new BigDecimal(0.0)); > markowitzModel.setUpperLimit(i, new BigDecimal(1.0)); > } > > List<BigDecimal> re = markowitzModel.getWeights(); > > > System.out.println("=======result===================="); > for(int i=0;i<re..size();i++) > System.out.println(re.get(i)); > > System.out.println("=======result===================="); > System.out.println(markowitzModel.getMeanReturn()); > System.out.println(markowitzModel.getReturnVariance()); > return; > } > > } > > --------END CODE--------------- > -- > > Regards....Nilesh > ------------------------------------------------------------------------------ > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Anders P. <an...@op...> - 2009-07-26 18:41:16
|
Don't know what the practical size limit for a MarkowitzModel is, but I would guess it's more than 50 instruments. If using MarkowitzModel isn't flexible enough for you you can instead use QuadraticModel directly. If MarkowitzModel/QuadraticModel isn't fast enough you can use QuadraticSolver directly. /Anders On 26 jul 2009, at 06.36, Nilesh Parekh wrote: > Dear Team, > can i use MarkowitzModel to solve the weights for solving 50 X 50 > variance covariance matrix & 1X50 return matrix (i.e 50 variables) ? > plz. note that i'll also setting up the expected return to some > const. value. > i have tried with 4 X4 matrix (setting up the expected to some > const. value) & it worked perfectly fine, amzingly fast & accurate. > in this case i'll need 50 setupper limit & 50 set lowerlimits will > ojalgo support caculation of such large model. > also wanted to know the wt. is the max. possible value of n matrix > (n X n) [i.e n variable]supported by ojAlgo MarkowitzModel ? and any > advice for solving large number of variables with this model? > Thanks & Regards....Nilesh > ------------------------------------------------------------------------------ > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Nilesh P. <nil...@gm...> - 2009-07-26 10:23:27
|
Hi..this is slighly modifed version of the already posted issue on this forum earlier. I am using ojalgo 2.6 & also tried same code with new beta 2.7 version but the issue still persists Below code works fails if i set the expected return to *markowitzModel.setTargetReturn(new BigDecimal("0.01051787"));* any value *between 0.01051787 and 0.003081388 (which is the lowest return in the return matrix) gives same output. * Note: Values (expected rerurn) between *0.01051787 and 0.03360872 (max. return as per return matrix) works perfectly fine. * Do revert in case of any further clarifications. --------START CODE--------------- import java.math.BigDecimal; import java.util.List; import org.ojalgo.finance.portfolio.MarketEquilibrium; import org.ojalgo.finance.portfolio.MarkowitzModel; import org.ojalgo.matrix.*; import org.ojalgo.matrix.store.BigDenseStore; import org.ojalgo.matrix.store.MatrixStore; public class TestMarkowitz { public BasicMatrix getACovariances(double[][] returns){ int row = returns.length; int col = returns[0].length; MatrixStore<BigDecimal> a = BigDenseStore.FACTORY.makeZero(row, col); BasicMatrix covariances = new BigMatrix(a); for(int i=1;i<=row;i++){ for(int j=i;j<=col;j++){ covariances = covariances.set(i-1, j-1,returns[i-1][j-1]); covariances = covariances.set(j-1, i-1,returns[j-1][i-1]); } } return covariances; } public static void main(String[] args) { int assetNum=16; double[][] om={ {0.003330616,0.003524811,0.00386567,0.003656347,0.004494241,0.004623772,0.00458625,0.004365933,0,0,0,0,0,0,0,0}, {0.003524811,0.004274864,0.004372518,0.004135748,0.005144421,0.005292691,0.005249742,0.004997551,0,0,0,0,0,0,0,0}, {0.00386567,0.004372518,0.005114057,0.004535687,0.005641369,0.005803962,0.005756863,0.005480312,0,0,0,0,0,0,0,0}, {0.003656347,0.004135748,0.004535687,0.004728464,0.005511769,0.005670626,0.00562461,0.005354411,0,0,0,0,0,0,0,0}, {0.004494241,0.005144421,0.005641369,0.005511769,0.007284319,0.006518612,0.006359324,0.00635862,0,0,0,0,0,0,0,0}, {0.004623772,0.005292691,0.005803962,0.005670626,0.006518612,0.007542516,0.006562129,0.006561403,0,0,0,0,0,0,0,0}, {0.00458625,0.005249742,0.005756863,0.00562461,0.006359324,0.006562129,0.007513433,0.00640107,0,0,0,0,0,0,0,0}, {0.004365933,0.004997551,0.005480312,0.005354411,0.00635862,0.006561403,0.00640107,0.006805889,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0.000152891,0.000120753,7.98783E-05,0.000116607,8.11225E-05,4.31112E-05,6.11874E-05,1.49376E-07}, {0,0,0,0,0,0,0,0,0.000120753,0.000215819,0.000108447,0.000158311,7.62318E-05,4.05121E-05,5.74986E-05,1.4037E-07}, {0,0,0,0,0,0,0,0,7.98783E-05,0.000108447,0.000251455,0.000104723,0.000105337,5.59796E-05,7.94514E-05,1.93963E-07}, {0,0,0,0,0,0,0,0,0.000116607,0.000158311,0.000104723,0.000285454,0.000109622,5.82568E-05,8.26835E-05,2.01854E-07}, {0,0,0,0,0,0,0,0,8.11225E-05,7.62318E-05,0.000105337,0.000109622,0.000110962,5.62808E-05,7.47961E-05,1.97502E-06}, {0,0,0,0,0,0,0,0,4.31112E-05,4.05121E-05,5.59796E-05,5.82568E-05,5.62808E-05,4.12145E-05,4.25652E-05,1.12395E-06}, {0,0,0,0,0,0,0,0,6.11874E-05,5.74986E-05,7.94514E-05,8.26835E-05,7.47961E-05,4.25652E-05,7.62351E-05,1.4937E-06}, {0,0,0,0,0,0,0,0,1.49376E-07,1.4037E-07,1.93963E-07,2.01854E-07,1.97502E-06,1.12395E-06,1.4937E-06,6.52443E-06} }; TestMarkowitz tm = new TestMarkowitz(); BasicMatrix covariances = tm.getACovariances(om); System.out.println(covariances); BigDecimal riskAversion = new BigDecimal(1.0); MarketEquilibrium marketEquilibrium = new MarketEquilibrium(covariances,riskAversion); MatrixStore<BigDecimal> ret_matrix = BigDenseStore.FACTORY.makeZero (assetNum, 1); BasicMatrix expectedExcessReturns1 = new BigMatrix(ret_matrix); expectedExcessReturns1 = expectedExcessReturns1.set(0,0,0.03360872); expectedExcessReturns1 = expectedExcessReturns1.set(1,0,0.027322319); expectedExcessReturns1 = expectedExcessReturns1.set(2,0,0.027668137); expectedExcessReturns1 = expectedExcessReturns1.set(3,0,0.03080239); expectedExcessReturns1 = expectedExcessReturns1.set(4,0,0.025067124); expectedExcessReturns1 = expectedExcessReturns1.set(5,0,0.016578507); expectedExcessReturns1 = expectedExcessReturns1.set(6,0,0.022622714); expectedExcessReturns1 = expectedExcessReturns1.set(7,0,0.028957183); expectedExcessReturns1 = expectedExcessReturns1.set(8,0,0.009939058); expectedExcessReturns1 = expectedExcessReturns1.set(9,0,0.010014445); expectedExcessReturns1 = expectedExcessReturns1.set(10,0,0.011565874); expectedExcessReturns1 = expectedExcessReturns1.set(11,0,0.011609169); expectedExcessReturns1 = expectedExcessReturns1.set(12,0,0.006286505); expectedExcessReturns1 = expectedExcessReturns1.set(13,0,0.004240681); expectedExcessReturns1 = expectedExcessReturns1.set(14,0,0.006162067); expectedExcessReturns1 = expectedExcessReturns1.set(15,0,0.003081388); System.out.println("Return Matrix" + expectedExcessReturns1); MarkowitzModel markowitzModel = new MarkowitzModel(marketEquilibrium,expectedExcessReturns1); *markowitzModel.setTargetReturn(new BigDecimal("0.01051787"));* for(int i=0;i<assetNum;i++){ markowitzModel.setLowerLimit(i, new BigDecimal(0.0)); markowitzModel.setUpperLimit(i, new BigDecimal(1.0)); } List<BigDecimal> re = markowitzModel.getWeights(); System.out.println("=======result===================="); for(int i=0;i<re.size();i++) System.out.println(re.get(i)); System.out.println("=======result===================="); System.out.println(markowitzModel.getMeanReturn()); System.out.println(markowitzModel.getReturnVariance()); return; } } --------END CODE--------------- -- Regards....Nilesh |
From: Nilesh P. <nil...@gm...> - 2009-07-26 04:36:55
|
Dear Team, can i use MarkowitzModel to solve the weights for solving 50 X 50 variance covariance matrix & 1X50 return matrix (i.e 50 variables) ? plz. note that i'll also setting up the expected return to some const. value. i have tried with 4 X4 matrix (setting up the expected to some const. value) & it worked perfectly fine, amzingly fast & accurate. in this case i'll need 50 setupper limit & 50 set lowerlimits will ojalgo support caculation of such large model. also wanted to know the wt. is the max. possible value of n matrix (n X n) [i.e n variable]supported by ojAlgo MarkowitzModel ? and any advice for solving large number of variables with this model? Thanks & Regards....Nilesh |
From: Anders P. <an...@op...> - 2009-07-22 12:38:28
|
http://sourceforge.net/projects/ojalgo/files/ On 22 jul 2009, at 14.20, SourceForge.net wrote: > Project: ojAlgo (ojalgo) > Package: ojAlgo > Date : 2009-07-22 14:20 > > 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=698838 > > > or browse Release Notes and ChangeLog by visiting this link: > <https://sourceforge.net/project/shownotes.php?release_id=698838> > > 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: > <http://p.sf.net/sourceforge/accountproblems> > > Note that you may receive this message indirectly via one of your > mailing list > subscriptions. Please review message headers before reporting > unsolicited > mailings. |
From: <bru...@uk...> - 2009-07-18 03:18:07
|
I will be out of the office starting 17/07/2009 and will not return until 09/08/2009. I will respond to your message when I return. -------- This communication is confidential, may be privileged and is meant only for the intended recipient. If you are not the intended recipient, please notify the sender by reply and delete the message from your system. Any unauthorised dissemination, distribution or copying hereof is prohibited. BNP Paribas Trust Corporation UK Limited, BNP Paribas UK Limited, BNP Paribas Commodity Futures Limited, BNP Paribas Asset Management UK Limited and Investment Fund Services Limited are authorised and regulated by the Financial Services Authority. BNP Paribas London Branch and BNP Paribas Wealth Management London Branch are authorised by the CECEI and supervised by the Commission Bancaire. BNP Paribas London Branch is authorised and subject to limited regulation by the Financial Services Authority. Details about the extent of our authorisation and regulation by the Financial Services Authority are available from us on request. BNP Paribas is also a member of the London Stock Exchange. BNP Paribas Wealth Management London Branch is subject to limited regulation by the Financial Services Authority. Details about the extent of our authorisation and regulation by the Financial Services Authority are available from us on request. BNP Paribas Securities Services London Branch is authorised by the CECEI and supervised by the AMF, and subject to limited regulation by the Financial Services Authority. Details on the extent of our regulation by the Financial Services Authority are available from us on request. BNP Paribas Securities Services is also a member of the London Stock Exchange. BNP Paribas Trust Corporation UK Limited is registered in England and Wales (registered no. 4042668) at registered office 55 Moorgate, London EC2R 6PA. BNP Paribas UK Limited is registered in England and Wales (registered no. 1488108) at registered office 10 Harewood Avenue, London NW1 6AA. BNP Paribas Commodity Futures Limited is registered in England and Wales (registered no. 2391477) at registered office 10 Harewood Avenue, London NW1 6AA. BNP Paribas Asset Management UK Limited is registered in England and Wales (registered no. 2474627) at registered office 10 Harewood Avenue, London NW1 6AA. Investment Fund Services Limited is registered in England and Wales (registered no. 6110770) at registered office 55 Moorgate, London EC2R 6PA. BNP Paribas London Branch is registered in England and Wales (registered no. FC13447) at registered office 10 Harewood Avenue, London NW1 6AA. BNP Paribas Wealth Management London Branch is registered in England and Wales (registered no. FC023926) at registered office 10 Harewood Avenue, London NW1 6AA. BNP Paribas Securities Services London Branch is registered in England and Wales (registered no. BR006393) at registered office 55 Moorgate, London, EC2R 6PA. |
From: Keun L. <lee...@gm...> - 2009-07-17 22:56:56
|
Thank you for your reply. I've been reading through the code and I think I understand what you're saying as well as the formatting of the matrices that will be inputted. Am I correct to assume that I will need to program my own algorithm to determine a search direction, then loop it through to do SQP until an idea solution is reached? On Thu, Jul 16, 2009 at 3:18 AM, Anders Peterson<an...@op...> wrote: > On 16 jul 2009, at 02.16, Keun Lee wrote: > >> Hello, >> >> I recently discovered your package and it seems like it is a perfect >> fit for what I am trying to do, which is implement a program that will >> output tolerancing data using data points. >> >> The optimization problem in question has quadratic inequality >> constraints and there can be upwards of 1000 or so constraints >> depending on the amount of data points. >> >> Does ojalgo have the ability to take in these constraints and convert >> them to a Lagrangian formula by relaxing the constraints and solve it? > > No, you'll have to that yourself. > >> I'm also a beginner at this and am having trouble finding the way to >> do this, and am not sure what format the inputs have to be in. I >> noticed a mention of an example in the archives but I'm assuming that >> there's other code out there now that will allow me to study this >> further. > > Don't know what to tell you... (Not a very specific question.) > > Reformulate/relax your problem and see if you can find a way to feed > it to: > > http://ojalgo.org/generated/org/ojalgo/optimisation/quadratic/QuadraticModel.html > or > http://ojalgo.org/generated/org/ojalgo/optimisation/quadratic/QuadraticSolver.Builder.html > > > If you haven't already I suggest you read something about Sequential > Quadratic Programming (SQP). > > > /Anders > > >> Regards, >> -- >> Keun Lee, BSME >> Graduate Student, Industrial Engineering >> University of Miami >> Industrial Assessment Center >> 1251 Memorial Drive >> Coral Gables, FL 33146 >> >> e-mail: lee...@gm... >> >> Phone: (305) 284-2367 >> >> ------------------------------------------------------------------------------ >> Enter the BlackBerry Developer Challenge >> This is your chance to win up to $100,000 in prizes! For a limited >> time, >> vendors submitting new applications to BlackBerry App World(TM) will >> have >> the opportunity to enter the BlackBerry Developer Challenge. See >> full prize >> details at: http://p.sf.net/sfu/Challenge >> _______________________________________________ >> ojAlgo-user mailing list >> ojA...@li... >> https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > ------------------------------------------------------------------------------ > Enter the BlackBerry Developer Challenge > This is your chance to win up to $100,000 in prizes! For a limited time, > vendors submitting new applications to BlackBerry App World(TM) will have > the opportunity to enter the BlackBerry Developer Challenge. See full prize > details at: http://p.sf.net/sfu/Challenge > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > -- Keun Lee, BSME University of Miami Industrial Assessment Center 1251 Memorial Drive Coral Gables, FL 33146 |
From: Anders P. <an...@op...> - 2009-07-16 07:33:57
|
On 16 jul 2009, at 02.16, Keun Lee wrote: > Hello, > > I recently discovered your package and it seems like it is a perfect > fit for what I am trying to do, which is implement a program that will > output tolerancing data using data points. > > The optimization problem in question has quadratic inequality > constraints and there can be upwards of 1000 or so constraints > depending on the amount of data points. > > Does ojalgo have the ability to take in these constraints and convert > them to a Lagrangian formula by relaxing the constraints and solve it? No, you'll have to that yourself. > I'm also a beginner at this and am having trouble finding the way to > do this, and am not sure what format the inputs have to be in. I > noticed a mention of an example in the archives but I'm assuming that > there's other code out there now that will allow me to study this > further. Don't know what to tell you... (Not a very specific question.) Reformulate/relax your problem and see if you can find a way to feed it to: http://ojalgo.org/generated/org/ojalgo/optimisation/quadratic/QuadraticModel.html or http://ojalgo.org/generated/org/ojalgo/optimisation/quadratic/QuadraticSolver.Builder.html If you haven't already I suggest you read something about Sequential Quadratic Programming (SQP). /Anders > Regards, > -- > Keun Lee, BSME > Graduate Student, Industrial Engineering > University of Miami > Industrial Assessment Center > 1251 Memorial Drive > Coral Gables, FL 33146 > > e-mail: lee...@gm... > > Phone: (305) 284-2367 > > ------------------------------------------------------------------------------ > Enter the BlackBerry Developer Challenge > This is your chance to win up to $100,000 in prizes! For a limited > time, > vendors submitting new applications to BlackBerry App World(TM) will > have > the opportunity to enter the BlackBerry Developer Challenge. See > full prize > details at: http://p.sf.net/sfu/Challenge > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Keun L. <lee...@gm...> - 2009-07-16 00:17:07
|
Hello, I recently discovered your package and it seems like it is a perfect fit for what I am trying to do, which is implement a program that will output tolerancing data using data points. The optimization problem in question has quadratic inequality constraints and there can be upwards of 1000 or so constraints depending on the amount of data points. Does ojalgo have the ability to take in these constraints and convert them to a Lagrangian formula by relaxing the constraints and solve it? I'm also a beginner at this and am having trouble finding the way to do this, and am not sure what format the inputs have to be in. I noticed a mention of an example in the archives but I'm assuming that there's other code out there now that will allow me to study this further. Regards, -- Keun Lee, BSME Graduate Student, Industrial Engineering University of Miami Industrial Assessment Center 1251 Memorial Drive Coral Gables, FL 33146 e-mail: lee...@gm... Phone: (305) 284-2367 |
From: Anders P. <an...@op...> - 2009-06-24 07:34:37
|
That class has been removed, but everything it provided (and more) is still available: http://ojalgo.org/generated/org/ojalgo/constant/BigMath.html http://ojalgo.org/generated/org/ojalgo/constant/BigPrefix.html http://ojalgo.org/generated/org/ojalgo/function/implementation/BigFunction.html http://ojalgo.org/generated/org/ojalgo/function/aggregator/BigAggregator.html /Anders On 24 jun 2009, at 09.16, wom bat wrote: > Hi! > > I found that via google: http://ojalgo.org/generated/org/ojalgo/BigUtils.html > , but not in the jar or at http://ojalgo.org/generated/index.html, > so I was wondering what this is! I want that Class, why has it been > removed?! > > Thanks > ------------------------------------------------------------------------------ > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: wom b. <www...@go...> - 2009-06-24 07:16:18
|
Hi! I found that via google: http://ojalgo.org/generated/org/ojalgo/BigUtils.html, but not in the jar or at http://ojalgo.org/generated/index.html, so I was wondering what this is! I want that Class, why has it been removed?! Thanks |
From: Anders P. <an...@op...> - 2009-06-16 15:07:16
|
if/when you're using QuadraticModel you do not need to directly worry about the specifications of QuadraticSolver. Just model your problem the way you want it. Specifying a contribution weight makes that Variable or Expression part of the objective function. The size of a contribution weight only matters in relation to other contribution weights. Why don't you use the org.ojalgo.finance.portfolio.MarkowitzModel class or at least look at how it is implemented. /Anders On 16 jun 2009, at 16.14, bru...@uk... wrote: > > Hi, when looking at the javadoc of the QuadraticSolver class, the > following can be read: > > QuadraticSolver solves optimisation problems of the form: > > min 1/2 [X]T[Q][X] - [C]T[X] > when [AE][X] == [BE] > and [AI][X] <= [BI] > > > I wondered how it would be possible to optimise the following > problem with QuadraticSolver: > > min k*[X]T[Q][X] - (1-k)*[R]T[X] where R is the vector of the > returns and 0 <= k <= 1 > when [AE][X] == [BE] > and [AI][X] <= [BI] > > Typically I want to either: > - maximise the return for a target volatility [X]T[Q][X] = targetVol > - minimise the volatility for a target return [R]T[X] = > targetReturn > > How can I do that with QuadraticSolver? > Here is the code I wrote as an attempt to solve my problem. It gives > me weights but I am not sure if I have set the problem correctly. > > public boolean solveProblem() { > Variable[] variables = new Variable[allReturns[0].length]; > > //R is the vector of the assets' returns > //Inequality constraints are between 0 and 1 for the weights > > for (int i = 0; i < variables.length; i++) { > variables[i] = new Variable("w"+(i+1)); > variables[i].setContributionWeight( R.toBigDecimal(i, > 0) ); > variables[i].setLowerLimit("0" ); > variables[i].setUpperLimit("1" ); > } > > QuadraticModel quadraticModel = new QuadraticModel(variables); > > //Q is the correlation matrix of the assets' returns > //The question is: What do I do if I want to set a > volatility target? How do I specify it? > // How is it related to the contribution? > > Expression expression = > quadraticModel.addCorrelationExpression("Variance", Q ); > BigDecimal riskAversion = new BigDecimal("1"); > expression.setContributionWeight(riskAversion.multiply(new > BigDecimal("0.5"))); > > // set balance expression, sum of weights equal to 1 > expression = > quadraticModel.addSimpleWeightExpression("Balance"); > expression.setLowerLimit(new BigDecimal("1")); > expression.setUpperLimit(new BigDecimal("1")); > > res = quadraticModel.getDefaultSolver().solve(); > solverState = res.getState(); > > return solverState == solverState.OPTIMAL; > } > > > Regards > BF > > -------- > > This communication is confidential, may be privileged and is meant > only for the intended recipient. If you are not the intended > recipient, please notify the sender by reply and delete the message > from your system. Any unauthorised dissemination, distribution or > copying hereof is prohibited. > > BNP Paribas Trust Corporation UK Limited, BNP Paribas UK Limited, > BNP Paribas Commodity Futures Limited, BNP Paribas Asset Management > UK Limited and Investment Fund Services Limited are authorised and > regulated by the Financial Services Authority. > > BNP Paribas London Branch and BNP Paribas Wealth Management London > Branch are authorised by the CECEI and supervised by the Commission > Bancaire. > > BNP Paribas London Branch is authorised and subject to limited > regulation by the Financial Services Authority. Details about the > extent of our authorisation and regulation by the Financial Services > Authority are available from us on request. BNP Paribas is also a > member of the London Stock Exchange. > > BNP Paribas Wealth Management London Branch is subject to limited > regulation by the Financial Services Authority. Details about the > extent of our authorisation and regulation by the Financial Services > Authority are available from us on request. > > BNP Paribas Securities Services London Branch is authorised by the > CECEI and supervised by the AMF, and subject to limited regulation > by the Financial Services Authority. Details on the extent of our > regulation by the Financial Services Authority are available from us > on request. BNP Paribas Securities Services is also a member of the > London Stock Exchange. > > BNP Paribas Trust Corporation UK Limited is registered in England > and Wales (registered no. 4042668) at registered office 55 Moorgate, > London EC2R 6PA. > > BNP Paribas UK Limited is registered in England and Wales > (registered no. 1488108) at registered office 10 Harewood Avenue, > London NW1 6AA. > > BNP Paribas Commodity Futures Limited is registered in England and > Wales (registered no. 2391477) at registered office 10 Harewood > Avenue, London NW1 6AA. > > BNP Paribas Asset Management UK Limited is registered in England and > Wales (registered no. 2474627) at registered office 10 Harewood > Avenue, London NW1 6AA. > > Investment Fund Services Limited is registered in England and Wales > (registered no. 6110770) at registered office 55 Moorgate, London > EC2R 6PA. > > BNP Paribas London Branch is registered in England and Wales > (registered no. FC13447) at registered office 10 Harewood Avenue, > London NW1 6AA. > > BNP Paribas Wealth Management London Branch is registered in England > and Wales (registered no. FC023926) at registered office 10 Harewood > Avenue, London NW1 6AA. > > BNP Paribas Securities Services London Branch is registered in > England and Wales (registered no. BR006393) at registered office 55 > Moorgate, London, EC2R 6PA. > ------------------------------------------------------------------------------ > Crystal Reports - New Free Runtime and 30 Day Trial > Check out the new simplified licensing option that enables unlimited > royalty-free distribution of the report engine for externally facing > server and web deployment. > http://p.sf.net/sfu/businessobjects_______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: <bru...@uk...> - 2009-06-16 14:15:03
|
Hi, when looking at the javadoc of the QuadraticSolver class, the following can be read: QuadraticSolver solves optimisation problems of the form: min 1/2 [X]T[Q][X] - [C]T[X] when [AE][X] == [BE] and [AI][X] <= [BI] I wondered how it would be possible to optimise the following problem with QuadraticSolver: min k*[X]T[Q][X] - (1-k)*[R]T[X] where R is the vector of the returns and 0 <= k <= 1 when [AE][X] == [BE] and [AI][X] <= [BI] Typically I want to either: - maximise the return for a target volatility [X]T[Q][X] = targetVol - minimise the volatility for a target return [R]T[X] = targetReturn How can I do that with QuadraticSolver? Here is the code I wrote as an attempt to solve my problem. It gives me weights but I am not sure if I have set the problem correctly. public boolean solveProblem() { Variable[] variables = new Variable[allReturns[0].length]; //R is the vector of the assets' returns //Inequality constraints are between 0 and 1 for the weights for (int i = 0; i < variables.length; i++) { variables[i] = new Variable("w"+(i+1)); variables[i].setContributionWeight( R.toBigDecimal(i, 0) ); variables[i].setLowerLimit("0" ); variables[i].setUpperLimit("1" ); } QuadraticModel quadraticModel = new QuadraticModel(variables); //Q is the correlation matrix of the assets' returns //The question is: What do I do if I want to set a volatility target? How do I specify it? // How is it related to the contribution? Expression expression = quadraticModel.addCorrelationExpression("Variance", Q ); BigDecimal riskAversion = new BigDecimal("1"); expression.setContributionWeight(riskAversion.multiply(new BigDecimal("0.5"))); // set balance expression, sum of weights equal to 1 expression = quadraticModel.addSimpleWeightExpression("Balance"); expression.setLowerLimit(new BigDecimal("1")); expression.setUpperLimit(new BigDecimal("1")); res = quadraticModel.getDefaultSolver().solve(); solverState = res.getState(); return solverState == solverState.OPTIMAL; } Regards BF -------- This communication is confidential, may be privileged and is meant only for the intended recipient. If you are not the intended recipient, please notify the sender by reply and delete the message from your system. Any unauthorised dissemination, distribution or copying hereof is prohibited. BNP Paribas Trust Corporation UK Limited, BNP Paribas UK Limited, BNP Paribas Commodity Futures Limited, BNP Paribas Asset Management UK Limited and Investment Fund Services Limited are authorised and regulated by the Financial Services Authority. BNP Paribas London Branch and BNP Paribas Wealth Management London Branch are authorised by the CECEI and supervised by the Commission Bancaire. BNP Paribas London Branch is authorised and subject to limited regulation by the Financial Services Authority. Details about the extent of our authorisation and regulation by the Financial Services Authority are available from us on request. BNP Paribas is also a member of the London Stock Exchange. BNP Paribas Wealth Management London Branch is subject to limited regulation by the Financial Services Authority. Details about the extent of our authorisation and regulation by the Financial Services Authority are available from us on request. BNP Paribas Securities Services London Branch is authorised by the CECEI and supervised by the AMF, and subject to limited regulation by the Financial Services Authority. Details on the extent of our regulation by the Financial Services Authority are available from us on request. BNP Paribas Securities Services is also a member of the London Stock Exchange. BNP Paribas Trust Corporation UK Limited is registered in England and Wales (registered no. 4042668) at registered office 55 Moorgate, London EC2R 6PA. BNP Paribas UK Limited is registered in England and Wales (registered no. 1488108) at registered office 10 Harewood Avenue, London NW1 6AA. BNP Paribas Commodity Futures Limited is registered in England and Wales (registered no. 2391477) at registered office 10 Harewood Avenue, London NW1 6AA. BNP Paribas Asset Management UK Limited is registered in England and Wales (registered no. 2474627) at registered office 10 Harewood Avenue, London NW1 6AA. Investment Fund Services Limited is registered in England and Wales (registered no. 6110770) at registered office 55 Moorgate, London EC2R 6PA. BNP Paribas London Branch is registered in England and Wales (registered no. FC13447) at registered office 10 Harewood Avenue, London NW1 6AA. BNP Paribas Wealth Management London Branch is registered in England and Wales (registered no. FC023926) at registered office 10 Harewood Avenue, London NW1 6AA. BNP Paribas Securities Services London Branch is registered in England and Wales (registered no. BR006393) at registered office 55 Moorgate, London, EC2R 6PA. |
From: Anders P. <an...@op...> - 2009-06-08 08:26:57
|
I've built something you may want to try. The next version of ojAlgo will have an LP/simplex solver as well as an MIP/branch-and-bound solver that works with both linear and quadratic (sub) solvers. This is NOT finished! The LP solver can handle most cases. It's just not yet very good at dealing with infeasible and/or unbounded problems. The MIP solver is even less polished. So far there is only 1 unit test for it - that works. http://ojalgo.org/generated/org/ojalgo/optimisation/integer/IntegerSolver.Builder.html I'm interested in getting test cases. /Anders On 18 maj 2009, at 13.48, Anders Peterson wrote: > On 18 maj 2009, at 11.10, Lukas Rupprecht wrote: > >> Hi everybody, >> >> I need to solve an integer quadratic program (especially a 0-1 >> quadratic >> program) in Java and I found ojAlgo for it. I got a quadratic solver >> running but I can't figure out how to set integer constraints to the >> problem. To create my program I used: >> >> QuadraticSolver.Builder qp = new QuadraticSolver.Builder(Q, c); >> >> Is there any possibility to solve integer quadratic programs with >> ojAlgo >> and if so, how does it work? > > > No, not directly. You'll have to implement some master algorithm > yourself. Just like someone recently did when they needed to handle > non-linear constraints. > > /Anders > > >> Greets and thanks in advance, >> >> Lukas >> >> ------------------------------------------------------------------------------ >> Crystal Reports - New Free Runtime and 30 Day Trial >> Check out the new simplified licensing option that enables >> unlimited royalty-free distribution of the report engine >> for externally facing server and web deployment. >> http://p.sf.net/sfu/businessobjects >> _______________________________________________ >> ojAlgo-user mailing list >> ojA...@li... >> https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Anders P. <an...@op...> - 2009-05-19 07:23:46
|
If anyone is interested. These are the numbers (performance test results) for v27.11: http://ojalgo.org/generated/iMacComparison.xml http://ojalgo.org/generated/MacProComparison.xml http://ojalgo.org/generated/Performance.xls /Anders On 24 apr 2009, at 08.53, Anders Peterson wrote: > Generally all hardware should be "better" on the new MacPro compared > to the old iMac. In terms of installed software the two computers > should be near identical. Among the first things I did was to run the > ojAlgo performance tests. I was rather surprised: > > 1) The overall/total execution time was not much shorter. Something > like 10%. I expected more. > 2) Some operations were actually slower on the new MacPro. > 3) Most (if not all) of the code that performed slower on the MacPro > was Jama related. The other, pure ojAlgo, code generally performed > better. > > Hare are the results of the performance tests on both the iMac and the > MacPro > > http://ojalgo.org/generated/iMacComparison.xml > http://ojalgo.org/generated/MacProComparison.xml > > /Anders > > > > ------------------------------------------------------------------------------ > Crystal Reports - New Free Runtime and 30 Day Trial > Check out the new simplified licensign option that enables unlimited > royalty-free distribution of the report engine for externally > facing > server and web deployment. > http://p.sf.net/sfu/businessobjects > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > |
From: Anders P. <ap...@op...> - 2009-05-18 12:04:29
|
On 18 maj 2009, at 13.48, Anders Peterson wrote: > On 18 maj 2009, at 11.10, Lukas Rupprecht wrote: > >> Hi everybody, >> >> I need to solve an integer quadratic program (especially a 0-1 >> quadratic >> program) in Java and I found ojAlgo for it. I got a quadratic solver >> running but I can't figure out how to set integer constraints to the >> problem. To create my program I used: >> >> QuadraticSolver.Builder qp = new QuadraticSolver.Builder(Q, c); >> >> Is there any possibility to solve integer quadratic programs with >> ojAlgo >> and if so, how does it work? > > > No, not directly. You'll have to implement some master algorithm > yourself. Just like someone recently did when they needed to handle > non-linear constraints. > > /Anders > > >> Greets and thanks in advance, >> >> Lukas >> >> ------------------------------------------------------------------------------ >> Crystal Reports - New Free Runtime and 30 Day Trial >> Check out the new simplified licensing option that enables >> unlimited royalty-free distribution of the report engine >> for externally facing server and web deployment. >> http://p.sf.net/sfu/businessobjects >> _______________________________________________ >> ojAlgo-user mailing list >> ojA...@li... >> https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Anders P. <an...@op...> - 2009-05-18 12:04:24
|
On 18 maj 2009, at 11.10, Lukas Rupprecht wrote: > Hi everybody, > > I need to solve an integer quadratic program (especially a 0-1 > quadratic > program) in Java and I found ojAlgo for it. I got a quadratic solver > running but I can't figure out how to set integer constraints to the > problem. To create my program I used: > > QuadraticSolver.Builder qp = new QuadraticSolver.Builder(Q, c); > > Is there any possibility to solve integer quadratic programs with > ojAlgo > and if so, how does it work? No, not directly. You'll have to implement some master algorithm yourself. Just like someone recently did when they needed to handle non-linear constraints. /Anders > Greets and thanks in advance, > > Lukas > > ------------------------------------------------------------------------------ > Crystal Reports - New Free Runtime and 30 Day Trial > Check out the new simplified licensing option that enables > unlimited royalty-free distribution of the report engine > for externally facing server and web deployment. > http://p.sf.net/sfu/businessobjects > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Lukas R. <rup...@in...> - 2009-05-18 09:14:00
|
Hi everybody, I need to solve an integer quadratic program (especially a 0-1 quadratic program) in Java and I found ojAlgo for it. I got a quadratic solver running but I can't figure out how to set integer constraints to the problem. To create my program I used: QuadraticSolver.Builder qp = new QuadraticSolver.Builder(Q, c); Is there any possibility to solve integer quadratic programs with ojAlgo and if so, how does it work? Greets and thanks in advance, Lukas |
From: Anders P. <an...@op...> - 2009-04-24 06:54:06
|
Generally all hardware should be "better" on the new MacPro compared to the old iMac. In terms of installed software the two computers should be near identical. Among the first things I did was to run the ojAlgo performance tests. I was rather surprised: 1) The overall/total execution time was not much shorter. Something like 10%. I expected more. 2) Some operations were actually slower on the new MacPro. 3) Most (if not all) of the code that performed slower on the MacPro was Jama related. The other, pure ojAlgo, code generally performed better. Hare are the results of the performance tests on both the iMac and the MacPro http://ojalgo.org/generated/iMacComparison.xml http://ojalgo.org/generated/MacProComparison.xml /Anders |