ojalgo-user Mailing List for oj! Algorithms (Page 23)
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...> - 2008-12-16 13:46:54
|
On 26 nov 2008, at 09.06, Oddvar Grønning wrote: > >>> Do you have any hints/links that can put me on the right track to >>> pre-solve the system myself? > >> Don't feel I know the best way to fix your problem. > >> The AE matrix contains some very small elements like for instance >> -3.4914813388431334E-15. This is a constraint parameter?! Having >> parameters with very different magnitude could be a problem, but in >> this case the number itself is just too small. > > Ok, I see. Just so you don't think I take the numbers out of the > air :-): That small number is the result of a cosine call with an > angle close to pi/2.. The angle is actually a direction of a moving > object, and can take the value of any number between - pi and pi. > Such numbers are also common in control systems (i.e. Model > Predictive Control) due to rounding errors. > I'll try to remove such numbers before calling the QP solver. > >>> Or do you have any plans for developing a pre-solver? > >> Yes... I'm interested in getting feedback on what's new / in CVS. /Anders |
From: Oddvar G. <od...@pr...> - 2008-11-26 08:07:18
|
>> Do you have any hints/links that can put me on the right track to >> pre-solve the system myself? >Don't feel I know the best way to fix your problem. >The AE matrix contains some very small elements like for instance >-3.4914813388431334E-15. This is a constraint parameter?! Having >parameters with very different magnitude could be a problem, but in >this case the number itself is just too small. Ok, I see. Just so you don't think I take the numbers out of the air :-): That small number is the result of a cosine call with an angle close to pi/2. The angle is actually a direction of a moving object, and can take the value of any number between - pi and pi. Such numbers are also common in control systems (i.e. Model Predictive Control) due to rounding errors. I'll try to remove such numbers before calling the QP solver. >> Or do you have any plans for developing a pre-solver? >Yes... Great! Thanks again. - Oddvar >/Anders > Thanks for your help! > > - Oddvar > > -----Original Message----- >> From: Anders Peterson [mailto:an...@op...] > Sent: 23. november 2008 21:10 > To: Anders Peterson > Subject: Re: [ojAlgo-user] v25.1 > > On 21 nov 2008, at 12.40, Anders Peterson wrote: > >> On 21 nov 2008, at 10.07, Oddvar Grønning wrote: >> >>> I have a dynamic optimization problem to solve that mostly is >>> overdetermined, so the optimization problem has a set of solutions >>> instead of one global solution. I guess this is the reason of the >>> numerical difficulties of my systems. >> >> Yes, I think the problem is that you have several (near) redundant >> constraints. > > Don't think so anymore... > > I've long felt that the QP solvers needed a pre-solver that analysed > and fixed the model/problem for better numerical performance. I think > that the Matlab solver has one, and that's the difference. By > experimenting a bit I managed to improve the quality of the solution > to your latest model/problem: > > {{0.0}, > {0.0175}, > {-0.0175}, > {1.4639}, > {5.0}, > {4.8768}, > {4.4581}, > {-6.7724}, > {0.2257}} > > This solution is VERY close to the what you got from Matlab! > > Until ojAlgo actually has such a pre-solver you have to think about > how you construct your matrices. > > /Anders > ---------------------------------------------------------------------- > --- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win > great prizes > Grand prize is a trip for two to an Open Source event anywhere in > the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > > > ---------------------------------------------------------------------- > --- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win > great prizes > Grand prize is a trip for two to an Open Source event anywhere in > the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ ojAlgo-user mailing list ojA...@li... https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Anders P. <an...@op...> - 2008-11-24 14:06:55
|
On 24 nov 2008, at 13.33, Oddvar Grønning wrote: > Yes, this makes sense. > > The last few days I have been checking my system for poor condition > setup, but have not found any structural issues. > My system is sort of a sequential QP, the equality constraints are > nonlinear, so I linearize and iterate till I find the solution. > > I guess some of my sub-systems are badly scaled (in lack of a > better term), and should be fixed before calling the QP-solver. > > Do you have any hints/links that can put me on the right track to > pre-solve the system myself? Don't feel I know the best way to fix your problem. The AE matrix contains some very small elements like for instance -3.4914813388431334E-15. This is a constraint parameter?! Having parameters with very different magnitude could be a problem, but in this case the number itself is just too small. > Or do you have any plans for developing a pre-solver? Yes... /Anders > Thanks for your help! > > - Oddvar > > -----Original Message----- >> From: Anders Peterson [mailto:an...@op...] > Sent: 23. november 2008 21:10 > To: Anders Peterson > Subject: Re: [ojAlgo-user] v25.1 > > On 21 nov 2008, at 12.40, Anders Peterson wrote: > >> On 21 nov 2008, at 10.07, Oddvar Grønning wrote: >> >>> I have a dynamic optimization problem to solve that mostly is >>> overdetermined, so the optimization problem has a set of solutions >>> instead of one global solution. I guess this is the reason of the >>> numerical difficulties of my systems. >> >> Yes, I think the problem is that you have several (near) redundant >> constraints. > > Don't think so anymore... > > I've long felt that the QP solvers needed a pre-solver that analysed > and fixed the model/problem for better numerical performance. I think > that the Matlab solver has one, and that's the difference. By > experimenting a bit I managed to improve the quality of the solution > to your latest model/problem: > > {{0.0}, > {0.0175}, > {-0.0175}, > {1.4639}, > {5.0}, > {4.8768}, > {4.4581}, > {-6.7724}, > {0.2257}} > > This solution is VERY close to the what you got from Matlab! > > Until ojAlgo actually has such a pre-solver you have to think about > how you construct your matrices. > > /Anders > ---------------------------------------------------------------------- > --- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win > great prizes > Grand prize is a trip for two to an Open Source event anywhere in > the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > > > ---------------------------------------------------------------------- > --- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win > great prizes > Grand prize is a trip for two to an Open Source event anywhere in > the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > |
From: Oddvar G. <od...@pr...> - 2008-11-24 13:04:00
|
Yes, this makes sense. The last few days I have been checking my system for poor condition setup, but have not found any structural issues. My system is sort of a sequential QP, the equality constraints are nonlinear, so I linearize and iterate till I find the solution. I guess some of my sub-systems are badly scaled (in lack of a better term), and should be fixed before calling the QP-solver. Do you have any hints/links that can put me on the right track to pre-solve the system myself? Or do you have any plans for developing a pre-solver? Thanks for your help! - Oddvar -----Original Message----- From: Anders Peterson [mailto:an...@op...] Sent: 23. november 2008 21:10 To: Anders Peterson Subject: Re: [ojAlgo-user] v25.1 On 21 nov 2008, at 12.40, Anders Peterson wrote: > On 21 nov 2008, at 10.07, Oddvar Grønning wrote: > >> I have a dynamic optimization problem to solve that mostly is >> overdetermined, so the optimization problem has a set of solutions >> instead of one global solution. I guess this is the reason of the >> numerical difficulties of my systems. > > Yes, I think the problem is that you have several (near) redundant > constraints. Don't think so anymore... I've long felt that the QP solvers needed a pre-solver that analysed and fixed the model/problem for better numerical performance. I think that the Matlab solver has one, and that's the difference. By experimenting a bit I managed to improve the quality of the solution to your latest model/problem: {{0.0}, {0.0175}, {-0.0175}, {1.4639}, {5.0}, {4.8768}, {4.4581}, {-6.7724}, {0.2257}} This solution is VERY close to the what you got from Matlab! Until ojAlgo actually has such a pre-solver you have to think about how you construct your matrices. /Anders ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ ojAlgo-user mailing list ojA...@li... https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Anders P. <an...@op...> - 2008-11-23 20:24:54
|
On 21 nov 2008, at 12.40, Anders Peterson wrote: > On 21 nov 2008, at 10.07, Oddvar Grønning wrote: > >> I have a dynamic optimization problem to solve that mostly is >> overdetermined, so the optimization problem has a set of solutions >> instead of one global solution. I guess this is the reason of the >> numerical difficulties of my systems. > > Yes, I think the problem is that you have several (near) redundant > constraints. Don't think so anymore... I've long felt that the QP solvers needed a pre-solver that analysed and fixed the model/problem for better numerical performance. I think that the Matlab solver has one, and that's the difference. By experimenting a bit I managed to improve the quality of the solution to your latest model/problem: {{0.0}, {0.0175}, {-0.0175}, {1.4639}, {5.0}, {4.8768}, {4.4581}, {-6.7724}, {0.2257}} This solution is VERY close to the what you got from Matlab! Until ojAlgo actually has such a pre-solver you have to think about how you construct your matrices. /Anders |
From: Anders P. <an...@op...> - 2008-11-21 11:44:10
|
On 21 nov 2008, at 10.07, Oddvar Grønning wrote: > Sorry about the e-mail address, it was changed during a mail server > upgrade.. Should be back to the old now. > > V25.1 works without exceptions. I still a lot of FAILED results, > was planning to ask you about this next. I guess this is due to the > intermediate sub-problem solutions you are mentioning. I think so. > I have a dynamic optimization problem to solve that mostly is > overdetermined, so the optimization problem has a set of solutions > instead of one global solution. I guess this is the reason of the > numerical difficulties of my systems. Yes, I think the problem is that you have several (near) redundant constraints. > I see that if I use the solution from the ActiveSetSolver even if > the state is FAILED, it seems to work very well. I'm no expert on > optimization problems, but it seems to me that the ActiveSetSolver > solution actually is in the optimal solution set, or very near, and > that the FAILED state is somewhat misleading. Do you mean feasible solution set? Do the Matlab and ojAlgo solutions give the same objective value? FAILED, in this case, should be interpreted as "I don't know the quality of this solution". It seems to me, since you're happy, that you get a feasible solution that is close to optimal. Generally the solvers are not very intelligent in terms of setting the correct state. There's definitely room for improvement here. In some of your cases you should get FEASIBLE if the algorithm can't find/prove OPTIMAL or UNIQUE. /Anders > Thanks for your help, Anders. > > - Oddvar > > -----Original Message----- >> From: Anders Peterson [mailto:an...@op...] > Sent: 20. november 2008 13:30 > To: Oddvar Grønning > Subject: v25.1 > > How does this version work for you? |
From: Anders P. <an...@op...> - 2008-11-21 07:28:45
|
I changed the release to v25.1 ojalgo-25.1.tar.gz ojalgo-25.1.zip Got a report of a case where ActiveSetSolver failed with v25.0 but worked with some previous release. Each report like this is turned into a unit test. When I change the code I always make sure all existing unit tests continue to work, but I still manage to create new problems. I need more unit tests. You are very welcome to supply a unit test for your particular use case (any part of ojAlgo) even if there is no problem related to it now. /Anders On 18 nov 2008, at 12.20, Anders Peterson wrote: > ojAlgo v25 has been released > > http://ojalgo.org/change_log.html > > and the features/performance comparison has been slightly updated > > http://ojalgo.org/matrix_compare.html > > Each performance test is now looped 100 times instead of just 10 > times before. The complete set of performance tests takes about 10 > hours to run on my computer. > > /Anders > > > SourceForge.net wrote: >> Project: ojAlgo (ojalgo) >> Package: ojAlgo >> Date : 2008-11-18 11:39 >> >> 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=641249> >> or browse Release Notes and ChangeLog by visiting this link: >> <https://sourceforge.net/project/shownotes.php?release_id=641249> >> 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. > > ---------------------------------------------------------------------- > --- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win > great prizes > Grand prize is a trip for two to an Open Source event anywhere in > the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > |
From: Anders P. <an...@op...> - 2008-11-20 09:29:36
|
Could you please check which e-mail address your using? It seems you're not using one that is a member of this list. There are two aspects of this problem: 1) ojAlgo has numerical difficulties when solving this problem (actually with several of your problems). ojAlgo doesn't produce solutions as good as Matlab's. With poor intermediate (sub-problem) solutions it is difficult to conclude if the main algorithm should stop iterating or not... By tweaking the stop-criteria I can get the algorithm to exit normally and produce a solution - just not a very good one - and this without breaking any other existing unit tests. Guess this is ok... 2) v25.0 had a bug that gave you an ArrayIndexOutOfBoundsException instead of just exiting with state "FAILED". This is fixed now. On 19 nov 2008, at 18.15, oja...@li... wrote: > Matlab comes up with: > > x = > > 0.00000000000000 > 0.01750000000000 > -0.01750000000000 > 1.46389524463679 > 5.00000000000000 > 4.87681260745493 > 4.45803387299108 > -6.77235264210831 > 0.22574508859158 ojAlgo can only produce something like this: x = {{5.340576172E-5}, {0.01749420166016}, {-0.0174560546875}, {1.4642539024353}, {4.99999952316284}, {4.87466540336609}, {4.46074233874029}, {-6.7764671657036}, {0.2258822393782}} > -----Original Message----- >> From: Anders Peterson [mailto:an...@op...] > Sent: 19. november 2008 16:00 > To: Anders Peterson > Subject: Re: [ojAlgo-user] Auto-discard notification > > What solution do you get from Matlab in this case? /Anders > > On 19 nov 2008, at 13.04, oja...@li... > wrote: > >> The attached message has been automatically discarded. >> Date: onsdag 19 nov 2008 13.03.33 GMT+01:00 >> To: "'oja...@li...'" <ojalgo- >> us...@li...> >> Subject: RE: [ojAlgo-user] ojAlgo v25 >> >> >> >> Hi, I've tested the v25 ActiveSetSolver. >> >> I triggered an ArrayIndexOutOfBoundsException that I did not >> encounter in v24.11: >> >> Exception in thread "main" >> java.lang.ArrayIndexOutOfBoundsException: 2 >> at >> org.ojalgo.optimisation.quadratic.ActiveSetSolver.needsAnotherIterati >> o >> n(ActiveSetSolver.java:230) >> at org.ojalgo.optimisation.quadratic.QuadraticSolver.solve >> (QuadraticSolver..java:144) >> >> Here is an example that will reproduce the exception: >> >> >> import org.ojalgo.matrix.BasicMatrix; >> import org.ojalgo.matrix.PrimitiveMatrix; >> import org.ojalgo.optimisation.OptimisationSolver.Result; >> import org.ojalgo.optimisation.quadratic.ActiveSetSolver; >> >> public class QPTest { >> >> public static void main(String[] args) { >> new QPTest(); >> } >> >> public QPTest() { >> >> BasicMatrix[] system = new BasicMatrix[6]; >> //{[AE], [be], [Q], [c], [AI], [bi]} >> >> double[][] AE = new double[][]{{-10.630019918689772, >> 0.15715259580856766, -24.006889886456438, -3.4914813388431334E-15, >> 0.9987922086746552, 0.9018272287390979, 1.0, 0.0, 0.0}, >> {-3.711451617763614E-14, -3.1946032406211518, 50.10466796063192, >> 1.0, 0.04913373475326318, 0.4320968057099691, 0.0, 1.0, 0.0}, >> {-1.1134354853290842E-12, 94.42372385635744, -1719.2020477970657, >> 30.0, -10.463141920669791, -4.8464591126471905, 0.0, 0.0, 1.0}}; >> >> system[0] = PrimitiveMatrix.FACTORY.copy(AE); // AE >> system[1] = PrimitiveMatrix.FACTORY.copy(new double[][] >> {{14.272908058664967}, {-3.888270819999793}, >> {-0.06992907379067503}}); // be >> system[2] = PrimitiveMatrix.FACTORY.buildEye(9, 9); // Q >> system[2] = system[2].set(3, 3, 10); >> system[2] = system[2].set(4, 4, 10); >> system[2] = system[2].set(5, 5, 10); >> system[2] = system[2].set(6, 6, 1000000000); >> system[2] = system[2].set(7, 7, 1000000000); >> system[2] = system[2].set(8, 8, 1000000000); >> system[3] = PrimitiveMatrix.FACTORY.copy(new double[][]{{0}, {0}, >> {0}, {1}, {1}, {-1}, {0}, {0}, {0}}); // c >> >> double[][] Ain = new double[18][9]; >> >> for(int i = 0; i < 9; i++) { >> Ain[i][i] = 1; >> Ain[i+9][i] = -1; >> } >> >> system[4] = PrimitiveMatrix.FACTORY.copy(Ain); // AI >> >> double[][] bin = new double[][]{{0}, {0.0175}, {0.0175}, {5}, >> {5}, {5}, {100000}, {100000}, {100000}, {0}, {0.0175}, {0.0175}, >> {5}, {5}, {5}, {100000}, {100000}, {100000}}; >> >> system[5] = PrimitiveMatrix.FACTORY.copy(bin); // bi >> >> >> ActiveSetSolver as = new ActiveSetSolver(system); >> Result res = as.solve(); >> System.out.println("state: " + res.getState()); >> print("sol", res.getSolution()); >> >> } >> } >> >> - Oddvar > > > ---------------------------------------------------------------------- > --- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win > great prizes > Grand prize is a trip for two to an Open Source event anywhere in > the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > > > > |
From: Anders P. <an...@op...> - 2008-11-19 15:15:49
|
What solution do you get from Matlab in this case? /Anders On 19 nov 2008, at 13.04, oja...@li... wrote: > The attached message has been automatically discarded. > Date: onsdag 19 nov 2008 13.03.33 GMT+01:00 > To: "'oja...@li...'" <ojalgo- > us...@li...> > Subject: RE: [ojAlgo-user] ojAlgo v25 > > > > Hi, I've tested the v25 ActiveSetSolver. > > I triggered an ArrayIndexOutOfBoundsException that I did not > encounter in v24.11: > > Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2 > at > org.ojalgo.optimisation.quadratic.ActiveSetSolver.needsAnotherIteratio > n(ActiveSetSolver.java:230) > at org.ojalgo.optimisation.quadratic.QuadraticSolver.solve > (QuadraticSolver..java:144) > > Here is an example that will reproduce the exception: > > > import org.ojalgo.matrix.BasicMatrix; > import org.ojalgo.matrix.PrimitiveMatrix; > import org.ojalgo.optimisation.OptimisationSolver.Result; > import org.ojalgo.optimisation.quadratic.ActiveSetSolver; > > public class QPTest { > > public static void main(String[] args) { > new QPTest(); > } > > public QPTest() { > > BasicMatrix[] system = new BasicMatrix[6]; > //{[AE], [be], [Q], [c], [AI], [bi]} > > double[][] AE = new double[][]{{-10.630019918689772, > 0.15715259580856766, -24.006889886456438, -3.4914813388431334E-15, > 0.9987922086746552, 0.9018272287390979, 1.0, 0.0, 0.0}, > {-3.711451617763614E-14, -3.1946032406211518, 50.10466796063192, > 1.0, 0.04913373475326318, 0.4320968057099691, 0.0, 1.0, 0.0}, > {-1.1134354853290842E-12, 94.42372385635744, -1719.2020477970657, > 30.0, -10.463141920669791, -4.8464591126471905, 0.0, 0.0, 1.0}}; > > system[0] = PrimitiveMatrix.FACTORY.copy(AE); // AE > system[1] = PrimitiveMatrix.FACTORY.copy(new double[][] > {{14.272908058664967}, {-3.888270819999793}, > {-0.06992907379067503}}); // be > system[2] = PrimitiveMatrix.FACTORY.buildEye(9, 9); // Q > system[2] = system[2].set(3, 3, 10); > system[2] = system[2].set(4, 4, 10); > system[2] = system[2].set(5, 5, 10); > system[2] = system[2].set(6, 6, 1000000000); > system[2] = system[2].set(7, 7, 1000000000); > system[2] = system[2].set(8, 8, 1000000000); > system[3] = PrimitiveMatrix.FACTORY.copy(new double[][]{{0}, {0}, > {0}, {1}, {1}, {-1}, {0}, {0}, {0}}); // c > > double[][] Ain = new double[18][9]; > > for(int i = 0; i < 9; i++) { > Ain[i][i] = 1; > Ain[i+9][i] = -1; > } > > system[4] = PrimitiveMatrix.FACTORY.copy(Ain); // AI > > double[][] bin = new double[][]{{0}, {0.0175}, {0.0175}, {5}, > {5}, {5}, {100000}, {100000}, {100000}, {0}, {0.0175}, {0.0175}, > {5}, {5}, {5}, {100000}, {100000}, {100000}}; > > system[5] = PrimitiveMatrix.FACTORY.copy(bin); // bi > > > ActiveSetSolver as = new ActiveSetSolver(system); > Result res = as.solve(); > System.out.println("state: " + res.getState()); > print("sol", res.getSolution()); > > } > } > > - Oddvar |
From: Anders P. <an...@op...> - 2008-11-18 11:21:01
|
ojAlgo v25 has been released http://ojalgo.org/change_log.html and the features/performance comparison has been slightly updated http://ojalgo.org/matrix_compare.html Each performance test is now looped 100 times instead of just 10 times before. The complete set of performance tests takes about 10 hours to run on my computer. /Anders SourceForge.net wrote: > Project: ojAlgo (ojalgo) > Package: ojAlgo > Date : 2008-11-18 11:39 > > 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=641249> > or browse Release Notes and ChangeLog by visiting this link: > <https://sourceforge.net/project/shownotes.php?release_id=641249> > 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: Nigel S. <nig...@gm...> - 2008-11-13 13:59:51
|
Thanks Anders, works like a charm. We're back down to 0.3s. Cheers Nigel 2008/11/13 Anders Peterson <an...@op...>: > On 13 nov 2008, at 11.32, Nigel Sim wrote: > >> Hi, I wonder if someone could please comment on the proper way to >> populate blank matricies, with memory efficiency in mind. >> >> The example I have is loading a CSV file into the matrix. Previously I >> used JAMA: >> 1) Created the matrix (new Matrix(rowCount, colCount)) >> 2) Iterate over the rows: >> 2.1) Iterate over the columns >> 2.1.1) Write to the array (currentMatrix.set(row, j, >> Double.parseDouble(cols[remainingCols.get(j)]));) >> >> I adapted this to ojalgo, so now I use >> 1) PrimitiveMatrix.FACTORY.buildZero(rowCount, colCount) >> .... >> 2.1.1) currentMatrix = currentMatrix.set(row, j, >> Double.parseDouble(cols[colsOfInterest[j]])); >> >> This is very slow, in that the JAMA version takes 0.3 s to run, and >> the ojalgo version takes 30+ seconds to run. Essentially because the >> matrix set method seems to make a copy of the matrix, which it >> returns. This does seem at odds with the java doc which indicates that >> the physical stores are mutable, so I would assume the matrix should >> also be mutable. > > > Didn't know it was that slow... I rarely use the set-method in > BasicMatrix, and when I do it's only to set a few (a small number) of > elements. > > The BasicMatrix interface doesn't force implementations to be > mutable, and the implementations BigMatrix, PrimitiveMatrix and > ComplexMatrix are immutable. When you call set(...) nothing is > copied, but a couple of new instances are created - a new BasicMatrix > and a new MatrixStore - and they contain the old/previous MatrixStore. > > I'd do it like this: > > PrimitiveDenseStore.FACTORY.makeEmpty(rowCount, colCount); > > and then loop to set the elements the way you did before. > > You do not have to create a BasicMatrix instance, and if you worry > very much about memory consumption then you probably shouldn't. > > >> The other option appears to be to create a double array and copy it >> into the matrix with the factory, but this will mean, for a short >> time, there will be two copies of a potentially large array in memory. >> >> Any advice would be most helpful. > > > Currently the only way to create a new BasicMatrix instance without > using the set-method and without any "unnecessary" copying is to > create a MatrixStore and then instantiate a BasicMatrix > implementation by calling a constructor directly. The constructors in > BigMatrix, PrimitiveMatrix and ComplexMatrix do not copy anything. > > > /Anders > > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > |
From: Anders P. <an...@op...> - 2008-11-13 13:10:41
|
On 13 nov 2008, at 11.32, Nigel Sim wrote: > Hi, I wonder if someone could please comment on the proper way to > populate blank matricies, with memory efficiency in mind. > > The example I have is loading a CSV file into the matrix. Previously I > used JAMA: > 1) Created the matrix (new Matrix(rowCount, colCount)) > 2) Iterate over the rows: > 2.1) Iterate over the columns > 2.1.1) Write to the array (currentMatrix.set(row, j, > Double.parseDouble(cols[remainingCols.get(j)]));) > > I adapted this to ojalgo, so now I use > 1) PrimitiveMatrix.FACTORY.buildZero(rowCount, colCount) > .... > 2.1.1) currentMatrix = currentMatrix.set(row, j, > Double.parseDouble(cols[colsOfInterest[j]])); > > This is very slow, in that the JAMA version takes 0.3 s to run, and > the ojalgo version takes 30+ seconds to run. Essentially because the > matrix set method seems to make a copy of the matrix, which it > returns. This does seem at odds with the java doc which indicates that > the physical stores are mutable, so I would assume the matrix should > also be mutable. Didn't know it was that slow... I rarely use the set-method in BasicMatrix, and when I do it's only to set a few (a small number) of elements. The BasicMatrix interface doesn't force implementations to be mutable, and the implementations BigMatrix, PrimitiveMatrix and ComplexMatrix are immutable. When you call set(...) nothing is copied, but a couple of new instances are created - a new BasicMatrix and a new MatrixStore - and they contain the old/previous MatrixStore. I'd do it like this: PrimitiveDenseStore.FACTORY.makeEmpty(rowCount, colCount); and then loop to set the elements the way you did before. You do not have to create a BasicMatrix instance, and if you worry very much about memory consumption then you probably shouldn't. > The other option appears to be to create a double array and copy it > into the matrix with the factory, but this will mean, for a short > time, there will be two copies of a potentially large array in memory. > > Any advice would be most helpful. Currently the only way to create a new BasicMatrix instance without using the set-method and without any "unnecessary" copying is to create a MatrixStore and then instantiate a BasicMatrix implementation by calling a constructor directly. The constructors in BigMatrix, PrimitiveMatrix and ComplexMatrix do not copy anything. /Anders |
From: Nigel S. <nig...@gm...> - 2008-11-13 10:32:27
|
Hi, I wonder if someone could please comment on the proper way to populate blank matricies, with memory efficiency in mind. The example I have is loading a CSV file into the matrix. Previously I used JAMA: 1) Created the matrix (new Matrix(rowCount, colCount)) 2) Iterate over the rows: 2.1) Iterate over the columns 2.1.1) Write to the array (currentMatrix.set(row, j, Double.parseDouble(cols[remainingCols.get(j)]));) I adapted this to ojalgo, so now I use 1) PrimitiveMatrix.FACTORY.buildZero(rowCount, colCount) ... 2.1.1) currentMatrix = currentMatrix.set(row, j, Double.parseDouble(cols[colsOfInterest[j]])); This is very slow, in that the JAMA version takes 0.3 s to run, and the ojalgo version takes 30+ seconds to run. Essentially because the matrix set method seems to make a copy of the matrix, which it returns. This does seem at odds with the java doc which indicates that the physical stores are mutable, so I would assume the matrix should also be mutable. The other option appears to be to create a double array and copy it into the matrix with the factory, but this will mean, for a short time, there will be two copies of a potentially large array in memory. Any advice would be most helpful. Cheers Nigel |
From: Anders P. <an...@op...> - 2008-11-07 13:28:22
|
I've added a solve-method to ActiveSetSolver that takes a suggested solution as input. It may be able to jumpstart its algorithm using this suggestion. If you only made small modifications to your model/ problem since you last solved it; then maybe the last solution you have is a good guess for the new model/problem. I've built it, but haven't tested/used it myself. The solver OptimisationSolver.Result class now also contains the number of iterations used to reach the solution. It could be interesting to compare the number of iterations needed depending on which solve(?) method you call. /Anders |
From: Anders P. <an...@op...> - 2008-11-07 08:11:40
|
I'm sad to see that this list has begun to receive spam. Posts from all members (existing and new) will be moderated until I decide to trust that individual poster. Posts from non-members are quietly discarded. I hope this will solve the problem! /Anders |
From: Oddvar G. <od...@pr...> - 2008-10-16 09:45:27
|
I got the new code from the CSV, and your jar file, the ActiveSetSolver now works like a charm :-). When the references changes in my system, I iterate the ActiveSetSolver more than a 100 times per. second without problems, great performance! (The ArrayIndexOutOfBoundsException was on line 242, I see you have done some changes there) Thanks a lot Anders - Oddvar |
From: Anders P. <an...@op...> - 2008-10-16 07:31:00
|
I don't see the ArrayIndexOutOfBoundsException. That's most likely because I use a later version (24.9) than you do. I've made some changes to ActiveSetSolver that would affect this (I think I know where/why you got that exception). The incorrect state: I don't see the same thing you do, but I do see something is wrong. I'll try to have a look at this later today. Is it possible for you to get the latest version from CVS? /Anders On 15 okt 2008, at 15.11, Oddvar Grønning wrote: > Thanks for your answer, Anders, it did solve my system (even though > the result state was FAILED). > > As you might have guessed, I am using the ActiveSetSolver as a part > of a larger system where the system matrixes to be solved changes > all the time (not the dimensions but the values of the matrixes). > > I still get errors in certain situations. I will present a system > that triggers an ArrayIndexOutOfBoundsException in ActiveSetSolver. > Again, Matlabs quadprog produces a correct result. > > public class QPTest { > > public static void main(String[] args) { > new QPTest(); > } > > public QPTest() { > > BasicMatrix[] system = new BasicMatrix[6]; > //{[AE], [be], [Q], [c], [AI], [bi]} > > double[][] AE = new double[][] > {{-0.6864742690952357, -0.5319998214213948, 1.2385363215384646, > -3.4914813388431334E-15, 0.976619978072726, 0.8727726942384015, > 1.0, 0.0, 0.0}, {-2.396812100141995E-15, 2.4168686217298863, > -2.2145077177955423, 1.0, 0.21497306442721648, 0.48812685256175126, > 0.0, 1.0, 0.0},{-7.190436300425984E-14, -67.71806025910404, > 77.58205842771245, 30.0, -15.23877173547103, -6.788851328706924, > 0.0, 0.0, 1.0}}; > system[0] = PrimitiveMatrix.FACTORY.copy(AE); // AE > system[1] = PrimitiveMatrix.FACTORY.copy(new double > [][]{{0.459002008118756}, {0.002566161917554134}, > {-0.03315618953218959}}); // be > system[2] = PrimitiveMatrix.FACTORY.buildEye(9, > 9); // Q > system[2] = system[2].set(3, 3, 10); > system[2] = system[2].set(4, 4, 10); > system[2] = system[2].set(5, 5, 10); > system[2] = system[2].set(6, 6, 1000000000); > system[2] = system[2].set(7, 7, 1000000000); > system[2] = system[2].set(8, 8, 1000000000); > system[3] = PrimitiveMatrix.FACTORY.copy(new double > [][]{{0}, {0}, {0}, {1}, {1}, {-1}, {0}, {0}, > {0}}); // c > > double[][] Ain = new double[18][9]; > > for(int i = 0; i < 9; i++) { > Ain[i][i] = 1; > Ain[i+9][i] = -1; > } > > system[4] = PrimitiveMatrix.FACTORY.copy(Ain); // AI > double[][] bin = new double[][]{{0}, {0.0175}, > {0.0175}, {0.5}, {0.5}, {0.5}, {100000}, {100000}, {100000}, {0}, > {0.0175}, {0.0175}, {0.5}, {0.5}, {0.5}, {100000}, {100000}, > {100000}}; > system[5] = PrimitiveMatrix.FACTORY.copy > (bin); // bi > > ActiveSetSolver as = new ActiveSetSolver(system); > Result res = as.solve(); > System.out.println("state: " + res.getState()); > } > } > > The result from Matlab: > X = > > -0.00000000000000 > -0.01750000000000 > 0.01750000000000 > 0.13427356981778 > 0.50000000000000 > -0.14913060410765 > 0.06986475572103 > -0.08535020176844 > 0.00284500680371 > > > Thanks, > - Oddvar > > -----Original Message----- >> From: Anders Peterson [mailto:an...@op...] > Sent: 14. oktober 2008 15:41 > To: oja...@li... > Subject: Re: [ojAlgo-user] ActiveSetSolver - RuntimeException: > Matrix is singular. > > If you use PrimitiveMatrix.FACTORY instead of JamaMatrix.FACTORY your > code will run successfully and produce a solution > that is the same as the one you got from Matlab (within 4 decimals). > > The reason is that PrimitiveMatrix, BigMatrix & ComplexMatrix (the > "native" ojAlgo matrices) are more intelligent in solving equation > systems than JamaMatrix. Look at the implementations of > BasicMatrix#solve() and you'll see what I mean. > > /Anders > > 14 okt 2008 kl. 12.56 skrev Oddvar Grønning: > >> Hi, >> >> >> >> I'm trying to solve some quadratic programming systems using >> version 24. The ActiveSetSolver does not always converge to a >> solution, but throws an exception, "Matrix is singular" (The >> exception is thrown by org.ojalgo.matrix.jama.LUDecomposition). >> >> The thing is that if I run Matlabs quadprog method on the exact >> same system, a solution is found without problems. Here is the code >> that produces the exception: >> >> >> >> public class QPTest { >> >> >> >> public static void main(String[] args) { >> >> new QPTest(); >> >> } >> >> >> >> public QPTest() { >> >> >> >> BasicMatrix[] system = new BasicMatrix[6]; >> >> //{[AE], [be], [Q], [c], [AI], [bi]} >> >> >> >> double[][] AE = new double[][] >> {{-0.0729971273939726,-0.31619624199405116,-0.14365990081105298,-3.49 >> 1 >> 4813388431334E-15,0.9963066090106673,0.9989967493404447,1.0,0.0,0.0}, >> {-2.5486810808521023E-16,3.6687950405257466,3.2047109656515507,1.0,0. >> 0 >> 8586699506600544,0.04478275122437895,0.0,1.0,0.0}, >> {-7.646043242556307E-15,-107.21808503782593,-97.434268076846,30.0,-11 >> . >> 54276933307617,7.647488207332634,0.0,0,1.0}}; >> >> system[0] = JamaMatrix.FACTORY.copy >> (AE); // AE >> >> system[1] = JamaMatrix.FACTORY.copy(new >> double[][]{{10.461669614447484}, {-0.5328532701990767}, >> {15.782527136201711}}); // be >> >> system[2] = JamaMatrix.FACTORY.buildEye(9, >> 9); // Q >> >> system[2] = system[2].set(3, 3, 10); >> >> system[2] = system[2].set(4, 4, 10); >> >> system[2] = system[2].set(5, 5, 10); >> >> system[2] = system[2].set(6, 6, 1000000000); >> >> system[2] = system[2].set(7, 7, 1000000000); >> >> system[2] = system[2].set(8, 8, 1000000000); >> >> system[3] = JamaMatrix.FACTORY.copy(new >> double[][]{{0}, {0}, {0}, {1}, {1}, {1}, {0}, {0}, >> {0}}); // c >> >> >> >> double[][] Ain = new double[18][9]; >> >> >> >> for(int i = 0; i < 9; i++) { >> >> Ain[i][i] = 1; >> >> Ain[i+9][i] = -1; >> >> } >> >> system[4] = JamaMatrix.FACTORY.copy >> (Ain); // AI >> >> >> >> double[][] bin = new double[][]{{0}, >> {0.0175}, {0.0175}, {5}, {5}, {5}, {100000}, {100000}, {100000}, >> {0}, {0.0175}, {0.0175}, {5}, {5}, {5}, {100000}, {100000}, >> {100000}}; >> >> system[5] = JamaMatrix.FACTORY.copy >> (bin); // bi >> >> >> >> ActiveSetSolver as = new ActiveSetSolver >> (system); >> >> Result res = as.solve(); >> >> } >> >> } >> >> >> >> Am I doing something wrong? Bug? >> >> >> >> Matlab is returning: >> >> X = >> >> >> >> 0.00000000000000 >> >> -0.01750000000000 >> >> -0.01750000000000 >> >> 0.88830035195990 >> >> 4.56989525276369 >> >> 5.00000000000000 >> >> 0.90562154243124 >> >> -1.91718419629399 >> >> 0.06390614020590 >> >> >> >> - Oddvar >> >> --------------------------------------------------------------------- >> - >> --- >> This SF.Net email is sponsored by the Moblin Your Move Developer's >> challenge >> Build the coolest Linux based applications with Moblin SDK & win >> great prizes >> Grand prize is a trip for two to an Open Source event anywhere in >> the world >> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >> _______________________________________________ >> ojAlgo-user mailing list >> ojA...@li... >> https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > > ---------------------------------------------------------------------- > --- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win > great prizes > Grand prize is a trip for two to an Open Source event anywhere in > the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > > > ---------------------------------------------------------------------- > --- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win > great prizes > Grand prize is a trip for two to an Open Source event anywhere in > the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > > |
From: Oddvar G. <od...@pr...> - 2008-10-15 13:12:28
|
Thanks for your answer, Anders, it did solve my system (even though the result state was FAILED). As you might have guessed, I am using the ActiveSetSolver as a part of a larger system where the system matrixes to be solved changes all the time (not the dimensions but the values of the matrixes). I still get errors in certain situations. I will present a system that triggers an ArrayIndexOutOfBoundsException in ActiveSetSolver. Again, Matlabs quadprog produces a correct result. public class QPTest { public static void main(String[] args) { new QPTest(); } public QPTest() { BasicMatrix[] system = new BasicMatrix[6]; //{[AE], [be], [Q], [c], [AI], [bi]} double[][] AE = new double[][]{{-0.6864742690952357, -0.5319998214213948, 1.2385363215384646, -3.4914813388431334E-15, 0.976619978072726, 0.8727726942384015, 1.0, 0.0, 0.0}, {-2.396812100141995E-15, 2.4168686217298863, -2.2145077177955423, 1.0, 0.21497306442721648, 0.48812685256175126, 0.0, 1.0, 0.0},{-7.190436300425984E-14, -67.71806025910404, 77.58205842771245, 30.0, -15.23877173547103, -6.788851328706924, 0.0, 0.0, 1.0}}; system[0] = PrimitiveMatrix.FACTORY.copy(AE); // AE system[1] = PrimitiveMatrix.FACTORY.copy(new double[][]{{0.459002008118756}, {0.002566161917554134}, {-0.03315618953218959}}); // be system[2] = PrimitiveMatrix.FACTORY.buildEye(9, 9); // Q system[2] = system[2].set(3, 3, 10); system[2] = system[2].set(4, 4, 10); system[2] = system[2].set(5, 5, 10); system[2] = system[2].set(6, 6, 1000000000); system[2] = system[2].set(7, 7, 1000000000); system[2] = system[2].set(8, 8, 1000000000); system[3] = PrimitiveMatrix.FACTORY.copy(new double[][]{{0}, {0}, {0}, {1}, {1}, {-1}, {0}, {0}, {0}}); // c double[][] Ain = new double[18][9]; for(int i = 0; i < 9; i++) { Ain[i][i] = 1; Ain[i+9][i] = -1; } system[4] = PrimitiveMatrix.FACTORY.copy(Ain); // AI double[][] bin = new double[][]{{0}, {0.0175}, {0.0175}, {0.5}, {0.5}, {0.5}, {100000}, {100000}, {100000}, {0}, {0.0175}, {0.0175}, {0.5}, {0.5}, {0.5}, {100000}, {100000}, {100000}}; system[5] = PrimitiveMatrix.FACTORY.copy(bin); // bi ActiveSetSolver as = new ActiveSetSolver(system); Result res = as.solve(); System.out.println("state: " + res.getState()); } } The result from Matlab: X = -0.00000000000000 -0.01750000000000 0.01750000000000 0.13427356981778 0.50000000000000 -0.14913060410765 0.06986475572103 -0.08535020176844 0.00284500680371 Thanks, - Oddvar -----Original Message----- From: Anders Peterson [mailto:an...@op...] Sent: 14. oktober 2008 15:41 To: oja...@li... Subject: Re: [ojAlgo-user] ActiveSetSolver - RuntimeException: Matrix is singular. If you use PrimitiveMatrix.FACTORY instead of JamaMatrix.FACTORY your code will run successfully and produce a solution that is the same as the one you got from Matlab (within 4 decimals). The reason is that PrimitiveMatrix, BigMatrix & ComplexMatrix (the "native" ojAlgo matrices) are more intelligent in solving equation systems than JamaMatrix. Look at the implementations of BasicMatrix#solve() and you'll see what I mean. /Anders 14 okt 2008 kl. 12.56 skrev Oddvar Grønning: > Hi, > > > > I'm trying to solve some quadratic programming systems using > version 24. The ActiveSetSolver does not always converge to a > solution, but throws an exception, "Matrix is singular" (The > exception is thrown by org.ojalgo.matrix.jama.LUDecomposition). > > The thing is that if I run Matlabs quadprog method on the exact > same system, a solution is found without problems. Here is the code > that produces the exception: > > > > public class QPTest { > > > > public static void main(String[] args) { > > new QPTest(); > > } > > > > public QPTest() { > > > > BasicMatrix[] system = new BasicMatrix[6]; > > //{[AE], [be], [Q], [c], [AI], [bi]} > > > > double[][] AE = new double[][] > {{-0.0729971273939726,-0.31619624199405116,-0.14365990081105298,-3.491 > 4813388431334E-15,0.9963066090106673,0.9989967493404447,1.0,0.0,0.0}, > {-2.5486810808521023E-16,3.6687950405257466,3.2047109656515507,1.0,0.0 > 8586699506600544,0.04478275122437895,0.0,1.0,0.0}, > {-7.646043242556307E-15,-107.21808503782593,-97.434268076846,30.0,-11. > 54276933307617,7.647488207332634,0.0,0,1.0}}; > > system[0] = JamaMatrix.FACTORY.copy > (AE); // AE > > system[1] = JamaMatrix.FACTORY.copy(new > double[][]{{10.461669614447484}, {-0.5328532701990767}, > {15.782527136201711}}); // be > > system[2] = JamaMatrix.FACTORY.buildEye(9, > 9); // Q > > system[2] = system[2].set(3, 3, 10); > > system[2] = system[2].set(4, 4, 10); > > system[2] = system[2].set(5, 5, 10); > > system[2] = system[2].set(6, 6, 1000000000); > > system[2] = system[2].set(7, 7, 1000000000); > > system[2] = system[2].set(8, 8, 1000000000); > > system[3] = JamaMatrix.FACTORY.copy(new > double[][]{{0}, {0}, {0}, {1}, {1}, {1}, {0}, {0}, > {0}}); // c > > > > double[][] Ain = new double[18][9]; > > > > for(int i = 0; i < 9; i++) { > > Ain[i][i] = 1; > > Ain[i+9][i] = -1; > > } > > system[4] = JamaMatrix.FACTORY.copy > (Ain); // AI > > > > double[][] bin = new double[][]{{0}, > {0.0175}, {0.0175}, {5}, {5}, {5}, {100000}, {100000}, {100000}, > {0}, {0.0175}, {0.0175}, {5}, {5}, {5}, {100000}, {100000}, {100000}}; > > system[5] = JamaMatrix.FACTORY.copy > (bin); // bi > > > > ActiveSetSolver as = new ActiveSetSolver > (system); > > Result res = as.solve(); > > } > > } > > > > Am I doing something wrong? Bug? > > > > Matlab is returning: > > X = > > > > 0.00000000000000 > > -0.01750000000000 > > -0.01750000000000 > > 0.88830035195990 > > 4.56989525276369 > > 5.00000000000000 > > 0.90562154243124 > > -1.91718419629399 > > 0.06390614020590 > > > > - Oddvar > > ---------------------------------------------------------------------- > --- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win > great prizes > Grand prize is a trip for two to an Open Source event anywhere in > the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ ojAlgo-user mailing list ojA...@li... https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Anders P. <an...@op...> - 2008-10-14 14:02:59
|
If you use PrimitiveMatrix.FACTORY instead of JamaMatrix.FACTORY your code will run successfully and produce a solution that is the same as the one you got from Matlab (within 4 decimals). The reason is that PrimitiveMatrix, BigMatrix & ComplexMatrix (the "native" ojAlgo matrices) are more intelligent in solving equation systems than JamaMatrix. Look at the implementations of BasicMatrix#solve() and you'll see what I mean. /Anders 14 okt 2008 kl. 12.56 skrev Oddvar Grønning: > Hi, > > > > I’m trying to solve some quadratic programming systems using > version 24. The ActiveSetSolver does not always converge to a > solution, but throws an exception, “Matrix is singular” (The > exception is thrown by org.ojalgo.matrix.jama.LUDecomposition). > > The thing is that if I run Matlabs quadprog method on the exact > same system, a solution is found without problems. Here is the code > that produces the exception: > > > > public class QPTest { > > > > public static void main(String[] args) { > > new QPTest(); > > } > > > > public QPTest() { > > > > BasicMatrix[] system = new BasicMatrix[6]; > > //{[AE], [be], [Q], [c], [AI], [bi]} > > > > double[][] AE = new double[][] > {{-0.0729971273939726,-0.31619624199405116,-0.14365990081105298,-3.491 > 4813388431334E-15,0.9963066090106673,0.9989967493404447,1.0,0.0,0.0}, > {-2.5486810808521023E-16,3.6687950405257466,3.2047109656515507,1.0,0.0 > 8586699506600544,0.04478275122437895,0.0,1.0,0.0}, > {-7.646043242556307E-15,-107.21808503782593,-97.434268076846,30.0,-11. > 54276933307617,7.647488207332634,0.0,0,1.0}}; > > system[0] = JamaMatrix.FACTORY.copy > (AE); // AE > > system[1] = JamaMatrix.FACTORY.copy(new > double[][]{{10.461669614447484}, {-0.5328532701990767}, > {15.782527136201711}}); // be > > system[2] = JamaMatrix.FACTORY.buildEye(9, > 9); // Q > > system[2] = system[2].set(3, 3, 10); > > system[2] = system[2].set(4, 4, 10); > > system[2] = system[2].set(5, 5, 10); > > system[2] = system[2].set(6, 6, 1000000000); > > system[2] = system[2].set(7, 7, 1000000000); > > system[2] = system[2].set(8, 8, 1000000000); > > system[3] = JamaMatrix.FACTORY.copy(new > double[][]{{0}, {0}, {0}, {1}, {1}, {1}, {0}, {0}, > {0}}); // c > > > > double[][] Ain = new double[18][9]; > > > > for(int i = 0; i < 9; i++) { > > Ain[i][i] = 1; > > Ain[i+9][i] = -1; > > } > > system[4] = JamaMatrix.FACTORY.copy > (Ain); // AI > > > > double[][] bin = new double[][]{{0}, > {0.0175}, {0.0175}, {5}, {5}, {5}, {100000}, {100000}, {100000}, > {0}, {0.0175}, {0.0175}, {5}, {5}, {5}, {100000}, {100000}, {100000}}; > > system[5] = JamaMatrix.FACTORY.copy > (bin); // bi > > > > ActiveSetSolver as = new ActiveSetSolver > (system); > > Result res = as.solve(); > > } > > } > > > > Am I doing something wrong? Bug? > > > > Matlab is returning: > > X = > > > > 0.00000000000000 > > -0.01750000000000 > > -0.01750000000000 > > 0.88830035195990 > > 4.56989525276369 > > 5.00000000000000 > > 0.90562154243124 > > -1.91718419629399 > > 0.06390614020590 > > > > - Oddvar > > ---------------------------------------------------------------------- > --- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win > great prizes > Grand prize is a trip for two to an Open Source event anywhere in > the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |
From: Oddvar G. <od...@pr...> - 2008-10-14 11:18:26
|
Hi, I'm trying to solve some quadratic programming systems using version 24. The ActiveSetSolver does not always converge to a solution, but throws an exception, "Matrix is singular" (The exception is thrown by org.ojalgo.matrix.jama.LUDecomposition). The thing is that if I run Matlabs quadprog method on the exact same system, a solution is found without problems. Here is the code that produces the exception: public class QPTest { public static void main(String[] args) { new QPTest(); } public QPTest() { BasicMatrix[] system = new BasicMatrix[6]; //{[AE], [be], [Q], [c], [AI], [bi]} double[][] AE = new double[][]{{-0.0729971273939726,-0.31619624199405116,-0.14365990081105298,-3.4914813388431334E-15,0.9963066090106673,0.9989967493404447,1.0,0.0,0.0}, {-2.5486810808521023E-16,3.6687950405257466,3.2047109656515507,1.0,0.08586699506600544,0.04478275122437895,0.0,1.0,0.0},{-7.646043242556307E-15,-107.21808503782593,-97.434268076846,30.0,-11.54276933307617,7.647488207332634,0.0,0,1.0}}; system[0] = JamaMatrix.FACTORY.copy(AE); // AE system[1] = JamaMatrix.FACTORY.copy(new double[][]{{10.461669614447484}, {-0.5328532701990767}, {15.782527136201711}}); // be system[2] = JamaMatrix.FACTORY.buildEye(9, 9); // Q system[2] = system[2].set(3, 3, 10); system[2] = system[2].set(4, 4, 10); system[2] = system[2].set(5, 5, 10); system[2] = system[2].set(6, 6, 1000000000); system[2] = system[2].set(7, 7, 1000000000); system[2] = system[2].set(8, 8, 1000000000); system[3] = JamaMatrix.FACTORY.copy(new double[][]{{0}, {0}, {0}, {1}, {1}, {1}, {0}, {0}, {0}}); // c double[][] Ain = new double[18][9]; for(int i = 0; i < 9; i++) { Ain[i][i] = 1; Ain[i+9][i] = -1; } system[4] = JamaMatrix.FACTORY.copy(Ain); // AI double[][] bin = new double[][]{{0}, {0.0175}, {0.0175}, {5}, {5}, {5}, {100000}, {100000}, {100000}, {0}, {0.0175}, {0.0175}, {5}, {5}, {5}, {100000}, {100000}, {100000}}; system[5] = JamaMatrix.FACTORY.copy(bin); // bi ActiveSetSolver as = new ActiveSetSolver(system); Result res = as.solve(); } } Am I doing something wrong? Bug? Matlab is returning: X = 0.00000000000000 -0.01750000000000 -0.01750000000000 0.88830035195990 4.56989525276369 5.00000000000000 0.90562154243124 -1.91718419629399 0.06390614020590 - Oddvar |
From: Anders P. <an...@op...> - 2008-08-07 18:44:58
|
http://ojalgo.org/change_log.html |
From: Anders P. <an...@op...> - 2008-05-16 10:28:06
|
Found a bug in 23.0 that needed fixing. multiplyRight in PrimitiveDenseStore returned an incorrect answer when the store was shaded (isShaded returns true). This should be the only difference between 23.0 and 23.2. In case I screwed up 23.0 will be available to download (for a while). /Anders |
From: Anders P. <and...@op...> - 2008-05-06 07:51:32
|
http://ojalgo.org/change_log.html SourceForge.net wrote: > Project: ojAlgo (ojalgo) > Package: ojAlgo > Date : 2008-05-06 09:33 > > 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=597409> > or browse Release Notes and ChangeLog by visiting this link: > <https://sourceforge.net/project/shownotes.php?release_id=597409> > > 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: Andreas R. <a....@tu...> - 2008-04-17 08:26:04
|
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! PS: Please apologize if this eMail was send twice. This is my first Post here. |
From: Anders P. <an...@op...> - 2008-04-17 07:55:45
|
How about this: import org.ojalgo.matrix.decomposition.Cholesky; import org.ojalgo.matrix.decomposition.CholeskyDecomposition; import org.ojalgo.matrix.store.MatrixStore; MatrixStore<Double> tmpMtrxA = ...; MatrixStore<Double> tmpMtrxB = ...; MatrixStore<Double> tmpMtrxC = ...; Cholesky<Double> tmpChol = CholeskyDecomposition.makePrimitive(); tmpChol.compute(tmpMtrxA); MatrixStore<Double> tmpMtrxResult = tmpMtrxC.multiplyLeft(tmpChol.getL ()).multiplyRight(tmpChol.getL()); /Anders On 17 apr 2008, at 09.21, Andreas Reim wrote: > 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 > S:\i6070505\Vorlagen\Normal.dot, 17.04.08 - > 09:02 > Seite 1 von 1 > > ---------------------------------------------------------------------- > --- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save > $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http:// > java.sun.com/javaone_______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user |