Replies: 0 comments 3 replies
-
Dear,
I admit it is not clear what you need here...
Note that when you are using a batch experiment, you have the facet repeat
that let you define the number of simulation for one parameter set...
It seems close to what you are calling nested experiments, right ?
cheers
Benoit
Le sam. 18 mars 2023 à 14:04, leenr01 ***@***.***> a écrit :
… Is there a way to perform an optimization on several simulations?
I defined a GUI experiment that creates three simulations each
representing a city. I measure an average value across these cities that I
want to minimize.
The problem is that any optimization is by itself an experiment (batch
type) that creates its own simulations.
Also, unfortunately, GAMA doesn't seem to support nested experiments.
—
Reply to this email directly, view it on GitHub
<https://github.com/gama-platform/gama/discussions/3676>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAL3WSWTP2ZH5N3MD5LXKN3W4WXFTANCNFSM6AAAAAAV7OYSWU>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
-
Dear,
It seems indeed to be complicate here...
But by the way, which parameters do you want to explore to maximize this
value ?
Other question : do you really want to maximize the number of prey for each
step of the simulation? You want to find a set of parameters that makes
all_preys at each step to each maximum value ?
I admit that it would seem very surprising to me if you can find such a set.
Cheers
Benoit
Le mar. 21 mars 2023 à 14:09, leenr01 ***@***.***> a écrit :
… Dear Benoit,
Thank you for your reply.
Not exactly.
Simply, I created several simulations that interact with each other using
GUI experiment and I defined a value that is shared between them. Is there
a way to optimize this value?
My model is quite long and complex. So, I created an analogy using model 9
in predator-prey. It is a simple model that creates three environments each
with a different initial number of preys.
The code is pasted here. Can we maximize the variable "all_preys" using an
optimization method inside GAMA?
------------------------------
model test2
global {
int simulation_ID <- 0;
map<int, int> nb_preys_init_list <- [1::500, 2::10, 3::3];
int nb_preys_init <- nb_preys_init_list at 1;
int nb_predators_init <- 20;
float prey_max_energy <- 1.0;
float prey_max_transfer <- 0.1;
float prey_energy_consum <- 0.05;
float predator_max_energy <- 1.0;
float predator_energy_transfer <- 0.5;
float predator_energy_consum <- 0.02;
float prey_proba_reproduce <- 0.01;
int prey_nb_max_offsprings <- 5;
float prey_energy_reproduce <- 0.5;
float predator_proba_reproduce <- 0.01;
int predator_nb_max_offsprings <- 3;
float predator_energy_reproduce <- 0.5;
int nb_preys -> {length(prey)};
int nb_predators -> {length(predator)};
int all_preys;
init {
create prey number: nb_preys_init;
create predator number: nb_predators_init;
}
reflex stop_simulation when: (nb_preys = 0) or (nb_predators = 0) {
do pause;
}
}
species generic_species {
float size <- 1.0;
rgb color;
float max_energy;
float max_transfer;
float energy_consum;
float proba_reproduce;
int nb_max_offsprings;
float energy_reproduce;
image_file my_icon;
vegetation_cell my_cell <- one_of(vegetation_cell);
float energy <- rnd(max_energy) update: energy - energy_consum max:
max_energy;
init {
location <- my_cell.location;
}
reflex basic_move {
my_cell <- choose_cell();
location <- my_cell.location;
}
reflex eat {
energy <- energy + energy_from_eat();
}
reflex die when: energy <= 0 {
do die;
}
reflex reproduce when: (energy >= energy_reproduce) and (flip(proba_reproduce)) {
int nb_offsprings <- rnd(1, nb_max_offsprings);
create species(self) number: nb_offsprings {
my_cell <- myself.my_cell;
location <- my_cell.location;
energy <- myself.energy / nb_offsprings;
}
energy <- energy / nb_offsprings;
}
float energy_from_eat {
return 0.0;
}
vegetation_cell choose_cell {
return nil;
}
aspect base {
draw circle(size) color: color;
}
aspect icon {
draw my_icon size: 2 * size;
}
aspect info {
draw square(size) color: color;
draw string(energy with_precision 2) size: 3 color: #black;
}
}
species prey parent: generic_species {
rgb color <- #blue;
float max_energy <- prey_max_energy;
float max_transfer <- prey_max_transfer;
float energy_consum <- prey_energy_consum;
float proba_reproduce <- prey_proba_reproduce;
int nb_max_offsprings <- prey_nb_max_offsprings;
float energy_reproduce <- prey_energy_reproduce;
image_file my_icon <- image_file("../includes/data/sheep.png");
float energy_from_eat {
float energy_transfer <- 0.0;
if(my_cell.food > 0) {
energy_transfer <- min([max_transfer, my_cell.food]);
my_cell.food <- my_cell.food - energy_transfer;
}
return energy_transfer;
}
vegetation_cell choose_cell {
return (my_cell.neighbors2) with_max_of (each.food);
}
}
species predator parent: generic_species {
rgb color <- #red;
float max_energy <- predator_max_energy;
float energy_transfer <- predator_energy_transfer;
float energy_consum <- predator_energy_consum;
float proba_reproduce <- predator_proba_reproduce;
int nb_max_offsprings <- predator_nb_max_offsprings;
float energy_reproduce <- predator_energy_reproduce;
image_file my_icon <- image_file("../includes/data/wolf.png");
float energy_from_eat {
list<prey> reachable_preys <- prey inside (my_cell);
if(! empty(reachable_preys)) {
ask one_of (reachable_preys) {
do die;
}
return energy_transfer;
}
return 0.0;
}
vegetation_cell choose_cell {
vegetation_cell my_cell_tmp <- shuffle(my_cell.neighbors2) first_with (!(empty(prey inside (each))));
if my_cell_tmp != nil {
return my_cell_tmp;
} else {
return one_of(my_cell.neighbors2);
}
}
}
grid vegetation_cell width: 50 height: 50 neighbors: 4 {
float max_food <- 1.0;
float food_prod <- rnd(0.01);
float food <- rnd(1.0) max: max_food update: food + food_prod;
rgb color <- rgb(int(255 * (1 - food)), 255, int(255 * (1 - food)))
update: rgb(int(255 * (1 - food)), 255, int(255 * (1 - food)));
list<vegetation_cell> neighbors2 <- (self neighbors_at 2);
}
experiment prey_predator type: gui {
output {
display main_display {
grid vegetation_cell border: #black;
species prey aspect: icon;
species predator aspect: icon;
}
}
init {
loop i from: 1 to: 2 {
create simulation with: [
nb_preys_init :: nb_preys_init_list at (i+1),
simulation_ID :: i
];
}
}
reflex global_nb_preys when: every(1#cycle){
int sum <- 0;
loop s over: simulations {
sum <- sum + s.nb_preys;
}
all_preys <- sum; // IS THERE A WAY TO MAXIMIZE all_preys in GAMA?
}
}
—
Reply to this email directly, view it on GitHub
<https://github.com/gama-platform/gama/discussions/3676#discussioncomment-5380982>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAL3WSWSMFEFVHFJAVQQMGLW5GSCJANCNFSM6AAAAAAV7OYSWU>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there a way to perform an optimization on several simulations?
I defined a GUI experiment that creates three simulations each representing a city. I measure an average value across these cities that I want to minimize.
The problem is that any optimization is by itself an experiment (batch type) that creates its own simulations.
Also, unfortunately, GAMA doesn't seem to support nested experiments.
Beta Was this translation helpful? Give feedback.
All reactions