Message Boards Message Boards

0
|
5195 Views
|
5 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Solve a system of 5 linear & non-linear equations

I have parametrized a complex economic growth model and reduced it to a system of 5 linear & non-linear equations, including one parameter with bounds. All solvers (NSolve, FindRoot, FindInstance etc) fail to solve it within 5 minutes with various accuracy or precision I tried. If I use NMaximize of some of the equations as an objective function, given all equations, I get different solutions, closed to each other though, and sometimes even NMaximize fails. Notice also that in FindInstance for instance I used some bounds provided by the NMaximize solution, and still it failed to solve it. I attach the file. Any help is welcomed!

Attachments:
5 Replies
Anonymous User
Anonymous User
Posted 4 years ago

I would be concerned that NMinimize may not have found all roots but only a correct answer in a given region (perhaps the correct region).

I think you should have to find all zeroes and branches of each separate equation (some flip direction given parameters - problematic for linear modeling with NMinimize i'd would guess - but I do not know what each method does) to verify.

Also, "&& 0.15 >= z0 > 0.1 && r >= 0.04 && S >= 17 && [Phi] >= 38 && g >= 0.014" is a condition not given for the above solutions - I cannot say immediately if that effects the number roots or branches at this time, but it is more restrictive and not explained above.

I see [Phi] is .39 but the condition in the notebook says >=38 ... perhaps a typo?

-0.01- 1.5 g + 0.8` r == 0 is given as equality but also used in NMaximize. I would ask ? What kind of equality is allowed to be maximized? (in other words i am un-familiar with the problem at hand)

I don't see why the provided .nb hasn't attempted to show a plotting (a quick visual verification, because plotting would show any issues in the regions given, if we think the functions are smooth in the interval we are solving in - which also determines what methods are allowed to be used).

I might ask if any of the above is allowed to be in the imaginary plane or to be so during solving (i hate to complicate things).

I cannot make heads or tails of the below (i supposed I could buy all the reference books $$$ and learn). my main question is does it exactly find all zero all branches? to me it says "maybe" which the original poster does not say is "good enough".

http://mathworld.wolfram.com/EvolutionStrategies.html

A differential evolution method used to minimize functions of real variables. Evolution strategies are significantly faster at numerical optimization than traditional genetic algorithms and also more likely to find a function's true global extremum.

These methods heuristically "mimic" biological evolution: namely, the process of natural selection and the "survival of the fittest" principle. An adaptive search procedure based on a "population" of candidate solution points is used. Iterations involve a competitive selection that drops the poorer solutions. The remaining pool of candidates with higher "fitness value" are then "recombined" with other solutions by swapping components with another; they can also be "mutated" by making some smaller-scale change to a candidate. The recombination and mutation moves are applied sequentially; their aim is to generate new solutions that are biased towards subsets of D in which good, although not necessarily globally optimized, solutions have already been found. Numerous variants of this general strategy based on diverse evolution "game rules" can be constructed. The different types of evolutionary search methods include approaches that are aimed at continuous global optimization problems, and also others that are targeted towards solving combinatorial problems. The latter group is often called genetic algorithms (Goldberg 1989, Michalewicz 1996, Osman and Kelly 1996, Voss et al. 1999).

POSTED BY: Anonymous User

John, Thanks very much for your time and the suggestions. I have nothing against FindRoot, but I wonder if the solution is local, despite the fact that is very near the NMaximize. I used NMaximize since NSolve did not find any solutions within some time constraints.

In the attached file you see that NMaximize (or NMinimize in that example) finds the global optimum, while the FindRoot finds all four roots. The example is easy though, it is just one variable, while in my case I have 5, or actually 6 variables, so I am afraid that if FindRoot found some solution for all 5 (or 6) variables, it might not search for other alternatives. Best Regards Christos

Attachments:
Anonymous User
Anonymous User
Posted 4 years ago

I don't see FindRoot gave a different result - instead I see more precision and accuracy stated. That could be because some numbers are giving as arbitrary and some not (it could be in error - but i tend to doubt we are seeing a new bug).

Different procedures will certainly give different precision and accuracy because they should do so.

Numbers should be given as arbitrary precision until it is time to read them so that better accuracy and precision is achieved unless the numbers are truly known only as measurements (in which case keeping precision and accuracy goals "consistent" is never going to be a simple matter).

POSTED BY: Anonymous User

I appear to be getting relatively consistent solutions:

NMaximize[{g, -0.01 - 1.5 g + 0.8 r == 
   0, (1 - E^((-g + r) (-60 + S)))/(-g + r) - 1.25` S == 
   0, -((1 - E^(
      60 (g - r)))/((-E^(60 (g - r)) + E^((g - r) S)) S^0.8` z0)) + (
    0.7142857142857143` (1 - \[Phi]))/HY == 
   0, -0.1333333333333334` HY + r == 0, 
  g - 0.2` (-HY + 1/60 (60 - S) S^0.8` z0 \[Phi]) == 0, .15 >= z0 > 
   0.1}, {g, \[Phi], S, HY, r, z0}, MaxIterations -> 1000, 
 Method -> "DifferentialEvolution"]

and

NMaximize[{g, -0.01 - 1.5 g + 0.8 r == 
0, (1 - E^((-g + r) (-60 + S)))/(-g + r) - 1.25` S == 
0, -((1 - E^(
60 (g - r)))/((-E^(60 (g - r)) + E^((g - r) S)) S^0.8` z0)) + (
0.7142857142857143` (1 - \[Phi]))/HY == 
0, -0.1333333333333334` HY + r == 0, 
g - 0.2` (-HY + 1/60 (60 - S) S^0.8` z0 \[Phi]) == 0, .15 >= z0 > 
0.1}, {g, \[Phi], S, HY, r, z0}, MaxIterations -> 1000, 
Method -> "SimulatedAnnealing"]

and

NMaximize[{g, -0.01 - 1.5 g + 0.8 r == 
   0, (1 - E^((-g + r) (-60 + S)))/(-g + r) - 1.25` S == 
   0, -((1 - E^(
      60 (g - r)))/((-E^(60 (g - r)) + E^((g - r) S)) S^0.8` z0)) + (
    0.7142857142857143` (1 - \[Phi]))/HY == 
   0, -0.1333333333333334` HY + r == 0, 
  g - 0.2` (-HY + 1/60 (60 - S) S^0.8` z0 \[Phi]) == 0, .15 >= z0 > 
   0.1}, {g, \[Phi], S, HY, r, z0}, MaxIterations -> 1000, 
 Method -> "RandomSearch"]

all give:

{0.0174822, {g -> 0.0174822, \[Phi] -> 0.392026, S -> 19.4554, HY -> 0.339593, r -> 0.045279, z0 -> 0.15}}

FindRoot is very fast when I run it, but indeed gives slightly different results, but I also changed the equations:

FindRoot[Rationalize[{-0.01 - 1.5 g + 0.8 r == 
    0, -0.01` - 1.5` g + 0.8` r == 
    0, (1 - E^((-g + r) (-60 + S)))/(-g + r) - 1.25` S == 
    0, -((1 - E^(
       60 (g - r)))/((-E^(60 (g - r)) + E^((g - r) S)) S^0.8` z0)) + (
     0.7142857142857143` (1 - \[Phi]))/HY == 
    0, -0.1333333333333334` HY + r == 0, 
   g - 0.2` (-HY + 1/60 (60 - S) S^0.8` z0 \[Phi]) == 0}], {{g, 
   0.0174}, {\[Phi], 0.392}, {S, 19.455}, {HY, 0.339}, {r, 
   0.0452}, {z0, 0.11}}, WorkingPrecision -> 90]

{g -> 0.01747595701522759654888879514686530406134841213208657811751823\
67866038502126910098306025329, \[Phi] -> 
  0.392039711166892955824950270274890218770446288167738002330477541690\
378470084182814459605290, 
 S -> 19.4568133105446885185181863757499840182832708946526114757457960\
193330672522626559370812986, 
 HY -> 0.3395056455266380764687486817527933383627120456074675047776002\
04811616643615967325742848119, 
 r -> 0.04526741940355174352916649090037244511502827274766233397034669\
39748822191487956434323797492, 
 z0 -> 0.1499537296343535548220535618515642739907407367358667393819615\
65413803327828645706176757813}

Cheers, Marco

POSTED BY: Marco Thiel

Thanks very much Marco! A final comment. Since FindRoot returns a result as soon as it finds anything, it may give only a local minimum or maximum, not a global one according to Mathematica. When I try your slightly modified equations with NSolve, which is supposed to be global, it fails and gives only conditional expressions. The NMaximize (which is also global, given the plausible objective function) gives very similar solutions as the FindRoot. On the other hand, this is a general equilibrium model and FindRoot is more appropriate than NMaximize. Should you prefer the FindRoot solutions as even if they might not be global, or the NMaximize ones? Thanks again!

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract