Message Boards Message Boards

GROUPS:

Odd model results and error about the AccuracyGoal in FindRoot?

Posted 5 months ago
411 Views
|
0 Replies
|
0 Total Likes
|

I built a monocentric city model using Mathematica. It optimises a system of equations by changing a parameter until there is an equilibrium, but I run into these problems:

  1. "FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances." Not sure if I should change the accuracy goal?
  2. My results don't show as single numbers, but instead a bunch of equations. I notice that the Pi symbol is in there as non-numeric. I've tried using E instead of e, Log instead of ln, N[] around my FindRoot, and dots after my numbers, but I seem to be missing something, what is it?
  3. Not sure if you can call this an error, but in my results I also get this text:

    Syntax::sntxf: "01\.00\.00\.00\.00\.00\.00Ç\.b3\.01{ü" cannot be followed by "\.7f\.00\.00\.00\.00à(\.bd\.01\.00\.00\.02\.00\.00\.00\.bd\.01\.00\.00\.00\.10\.00\.00\.00\.00\.00\.00\.00\.00\.00\.00ü\.7f\.00\.00$\.04à(½\.01\.00\.00\.00\.00\.00\.00z\.00\.00\.00\.10\.10\.00\.00\.02\.00\.00\.00 ".
    Syntax::sntxf: "" cannot be followed by "\.00\.10\.00\.00\.00\.00\.00\.00\.02\.00\.00\.00\.00\.00\.00\.00\.00\.00ä(\.bd\.01\.00\.00©Jß\.b9z\.00\.00\.00\.01\.01\.00\.00\.00\.00\.00\.00Ç\.b3\.01{ü\.7f\.00\.00\.00\.00à(\.bd\.01\.00\.00\.02\.00\.00\.00\.bd\.01\.00\.00\.00\.10\.00\.00\.00\.00\.00\.00\.00\.00\.00\.00ü\.7f\.00\.00$\.04à(½
    

Here is my entire model (if you run this model, you should get the same errors):

\[Alpha] = 0.86;
\[Beta] = 0.6;
g = 0.0005;
\[Theta] = 2*Pi;
\[Gamma] = 0.22;
\[Epsilon] = -0.6;
\[Omega] = 7.34074;

p[x_, y_, t_, ta_, f_, fa_, u_] := (E^(-\[Omega])*(\[Epsilon] + 1)*(((y - (f + fa) - (t + ta) x)^(-\[Gamma] + 1))/(-\[Gamma] + 1) - u))^(1/(\[Epsilon] + 1));
q[x_, y_, t_, ta_, f_, fa_, u_] := E^(\[Omega] + \[Epsilon]*Log[p[x, y, t, ta, f, fa, u]] + \[Gamma]*Log[y - (f + fa) - (t + ta) x]);
S[x_, y_, t_, ta_, f_, fa_, u_] := (1/(p[x, y, t, ta, f, fa, u] (\[Beta]) (g)))^(1/(\[Beta] - 1));
r[x_, y_, t_, ta_, f_, fa_, u_] := (p[x, y, t, ta, f, fa, u] (g)) ((1/(p[x, y, t, ta, f, fa, u] (\[Beta]) (g)))^(\[Beta]/(\[Beta] - 1))) - 1 ((1/(p[x, y, t, ta, f, fa, u] (\[Beta]) (g)))^(1/(\[Beta] - 1)));
h[x_, y_, t_, ta_, f_, fa_, u_] := (g) S[x, y, t, ta, f, fa, u]^(\[Beta]);
Density[x_, y_, t_, ta_, f_, fa_, u_] := h[x, y, t, ta, f, fa, u]/q[x, y, t, ta, f, fa, u];
L[xbar_, y_, t_, ta_, f_, fa_, u_] := \[Theta]*\!\(\*SubsuperscriptBox[\(\[Integral]\), \(0\), \(xbar\)]\(x*\ Density[x, y, t, ta, f, fa, u] \[DifferentialD]x\)\);

Population = 800000;
y = 70000;
t = 350;
f = 3000;
ta = 250;
fa = 1000;
ra = 45000;

Lu[u_] := (solution = FindRoot[{r[xbar, y, t, ta, f, fa, u] - ra == 0}, {xbar, 50}, AccuracyGoal -> 1]; xbar /. solution);

fu[u_] := N[L[Evaluate[Lu[u]], y, t, ta, f, fa, u] - Population];

findRoot[fun_, lower_, upper_, eps_] := Module[{ul = lower, uh = upper, count = 0}, While[And[Abs[fun[ul]] > eps, count < 10], If[fun[(uh + ul)/2] > 0, ul = (uh + ul)/2, uh = (uh + ul)/2]; count = count + 1]; 
Print["Iterations: ", count,
    " Population: ", Population, " people",
    " utility: ", N[ul],
    " City boundary (xbar): ", Lu[N[ul]], " km",
    " Average house price (pbar): ", pbar[Lu[N[ul]], y, t, ta, f, fa, N[ul], Population], " euros",
    " Price at 5 km from the centre p(5): ", p[5, y, t, ta, f, fa, N[ul]]/30000, " euros",
    " Price at 10 km from the centre p(10): ", p[10, y, t, ta, f, fa, N[ul]]/30000, " euros",
    " Average density: ", 2*Population/(\[Theta]*Lu[N[ul]]^2), " people per ?",
    " Average floor to area ratio hbar: ", hbar[Lu[N[ul]], y, t, ta, f, fa, N[ul], Population],
    " Density at 5 km from the centre Density(5): ", Density[5, y, t, ta, f, fa, N[ul]], " people per ?",
    " Density at 20 km from the centre Density(20): ", Density[20, y, t, ta, f, fa, N[ul]], " people per ?",
    Plot[{Density[x, y, t, ta, f, fa, N[ul]]}, {x, 0, Lu[N[ul]]}]]]; 
findRoot[fu, -50000, 50000, 1];

Any tips on any of these errors will be greatly appreciated!

POSTED BY: Victor Nielsen
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