       Manipulation Problem

• To: mathgroup at smc.vnet.net
• Subject: [mg111216] Manipulation Problem
• From: Osman Tuna <osmantunagokgoz at yahoo.com>
• Date: Fri, 23 Jul 2010 07:22:55 -0400 (EDT)

```Dear Members,

The following code is ok but when I use Manipulate command, I can't stop evaluation...

----------------
(*Firstly, we generate a random initial populations for our units, let's say cities*)
list = RandomInteger[{100, 5000}, 20(*# of cities*)];

For[

(*Let's indicate # of steps; fragmentation and or growing *)i = 1,
i < 50(*# of steps*), i++,

(*If our random real number will be smaller than 0.1, one of the our \
cities would be divided, and the populations of cities after division \
will increase between 0.5% and 1%*)
If[RandomReal[] < 0.1, j = RandomInteger[{1, Length[list]}];
a = list[[j]]; b = a*RandomReal[]; c = a - b;
list = Cases[
IntegerPart[(RandomReal[{1.005, 1.01}, (Length[list] + 1)])*
Join[Delete[list, j], IntegerPart[{c, b}]]], Except],

(*If our random real number will be bigger or equal to 0.1,
our cities will grow without division,
please remember that random real number is between 0 and 1*)
list = IntegerPart[list*RandomReal[{1.005, 1.01}]]]]; list

----------------------------
With Manipulation;
(*Firstly, we generate a random initial populations for our units, let's say cities*)
Manipulate[
list = RandomInteger[{100, 5000}, noc(*# of cities*)];

For[

(*Let's indicate # of steps; fragmentation and or growing *)i = 0,
i < nos(*# of steps*), i++,

(*If our random real number will be smaller than 0.1,
one of the our cities would be divided,
and the populations of cities after division will increase between \
0.5% and 1%*)
If[RandomReal[] < 0.1, j = RandomInteger[{1, Length[list]}];
a = list[[j]]; b = a*RandomReal[]; c = a - b;
list = Cases[
IntegerPart[(RandomReal[{1.005, 1.01}, (Length[list] + 1)])*
Join[Delete[list, j], IntegerPart[{c, b}]]], Except],

(*If our random real number will be bigger or equal to 0.1,
our cities will grow without division,
please remember that random real number is between 0 and 1*)
list = IntegerPart[list*RandomReal[{1.005, 1.01}]]]];
ListLogLogPlot[Reverse[Sort[IntegerPart[list]]], PlotRange -> All],

{{noc, 50, "# of Initial Cities"}, 20, 100,
5}, {{nos, 1000, "# of Steps"}, 400, 2000, 200}
]

-------------

How can I solve this problem?

Best...

Osman Tuna GÃ¶kgÃ¶z

```

• Prev by Date: Re: Displaying a list of variables together with their names
• Next by Date: Re: Show left hand side
• Previous by thread: Mathematica developer
• Next by thread: Experimental Data Analyst