gama-platform / gama.old

Main repository for developing the 1.x versions of GAMA
GNU General Public License v3.0
304 stars 99 forks source link

Make experiments inherit parameters and outputs from their parent #1677

Closed RCura closed 8 years ago

RCura commented 8 years ago

I think this could be usefull to manage a lot of experiments, wether it's GUI or batch.

This would allow to have some common parameters/displays in a "base experiment", and to have some variations of this experiment to change values/outputs for each use case.

For example, could be something like this :

experiment base_experiment type: batch repeat:20 until: (time >= 100){
    parameter 'blob' var: blob among: [1];
    parameter 'bleb' var: bleb among: ["base"];
}

experiment test1 parent: base_experiment{
    parameter 'bleb' var: bleb among: ["extra"];
}
// Same repeat, same until, same value for blob, and a different value for bleb

experiment test2 parent: base_experiment{
    parameter 'foo' var: foo among: [1,2];
}
// Same repeat, same until, same value for blob and bleb, and a new varying variable foo
AlexisDrogoul commented 8 years ago

Hi,

It already works, since experiments are species, but neither the outputs or inputs (parameters) are inherited, which effectively limits seriously the interest of doing so.

I will try to come up with a solution soon.

Cheers Alexis

RCura commented 8 years ago

On a second thought, it would be even more usefull to have the i/o as attributes of the experiment agent, as this would also allow to easily save their values to a csv/inspect them on a batch/headless model.

AlexisDrogoul commented 8 years ago

Having them as pure attributes would be a bit confusing, I guess, and difficult to manage, as their names can contain spaces.

However, I would be in favor of introducing several attributes (in line with gama-platform/gama2#9 ), like parameters, displays, monitors, inspectors, which would be maps (where the key would be the name of the item as declared by the user and the value its current value -- we have to decide what this 'value' would be for displays, however, but since gama-platform/gama2#9 plans to add commands for displays, I guess the display object (i.e. the drawing surface) should be the value).

So there are basically two things to do right now:

AlexisDrogoul commented 8 years ago

The first enhancement has been implemented and I have added the second to gama-platform/gama2#9. Parameters are now inherited (an info marker is added if they are redefined, and a compilation error raised if they are incompatible -- different types, etc.). Outputs are also inherited (both normal and permanent ones). In case they are defined in both experiments, they are merged with priority given to the redefinition. An info marker is also added in case of redefinition.

RCura commented 8 years ago

That's a very nice enhancement Alexis, thanks for it :)