Re: Limitations of Minimize? Time to buy a new PC for Mathematica?
- To: mathgroup at smc.vnet.net
- Subject: [mg113099] Re: Limitations of Minimize? Time to buy a new PC for Mathematica?
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Wed, 13 Oct 2010 12:39:12 -0400 (EDT)
On 10/12/10 at 4:29 AM, adrianboyko at gmail.com (Adrian Boyko) wrote: >I'm trying to perform linear least squares with constraints (all x's >> 0) and somebody suggested I might be able to do this with >Minimize. A constrained least squares problem can be solved by FindFit. Since FindFit is intended specifically for a least squares problem it is definitely going to be a better choice than Minimize which is a more general tool. But, the code you list below using Minimize does not reflect a least squares problem. A linear least squares problem has the form y == a f[x1] + b g[x2] + c h[x3] + ... where a, b, c are the unknown parameters you are looking for. The functions f, g h and the values x1, x2 and x3 are all known. The expression being minimized would be (y1 - a f[x11] + b g[x21] + c h[x31])^2 + (y2 - a f[x12] + b g[x22] + c h[x32])^2 ) + ... And the constraints are put on a, b and c, the unknown parameters. This is clearly not what you are doing with Minimize. If the expression you've written with Minimize does indeed correctly reflect what you are trying to do, you might have more success by replacing Minimize with NMinimize. Also, the syntax for both either Minimize and NMinimize should be (per the documentation) Minimize[{expr, constraints},{vars}] You are using Minimize[{expr {constraints}}, {vars}] which is not the same. Try using the syntax indicated by the documentation and see if that makes a difference. >When I run the following, Mathematica works on it for a >very long time <snip> >Minimize[ >{ + (660-x24)^2 + (341-x0-x12-x15-x17-x32)^2 + >(528-x0-x15-x24-x33)^2 + (266-x24)^2 + (263-x0-x9-x12)^2 + >(181-x17)^2 + (353-x14)^2 + (120-x0-x12-x15-x33)^2 + >(149-x0-x12-x14-x15-x33)^2 + (215-x0-x12-x17-x32)^2 + (566-x20)^2 + >(777-x0)^2 + (94-x24)^2 + (56-x15)^2 + (53-x12)^2 + (351-x24)^2 + >(426-x0-x12-x15-x17-x24-x33)^2 + (477-x24)^2 + (357-x12)^2 + >(548-x0-x12-x32)^2 + (210-x17-x24)^2 + (167-x9)^2 + >(173-x0-x12-x20)^2 + (77-x17-x24)^2 + (173-x20-x38)^2 + >(218-x0-x12-x14-x15-x20-x38)^2 + (217-x0)^2 + (482-x0-x12)^2 + >(252-x12)^2 + (312-x24)^2 + (212-x17)^2 + (606-x17)^2 + (337-x9)^2 + >(831-x0)^2 + (212-x0-x9-x12-x15-x32-x33)^2, { x0 > 0 && x9 > 0 && >x12 > 0 && x14 > 0 && x15 > 0 && x17 > 0 >&& x20 > 0 && x24 > 0 && x32 > 0 && x33 > 0 && x38 > 0 >} >}, >{x0, x9, x12, x14, x15, x17, x20, x24, x32, x33, x38} >]