COMOKIT / COMOKIT-Model

A GAMA (http://gama-platform.org) model on the assessment and comparisons of intervention policies against the CoVid19 pandemics
https://comokit.org
GNU General Public License v3.0
25 stars 18 forks source link

Use projet_path to redefine all the global variable #21

Closed benoitgaudou closed 4 years ago

benoitgaudou commented 4 years ago

Up to now, all the file paths are determined from the location of the experiment that is launched.

To avoid error and give more flexibility to modeler in their definition of experiment, we should use project_path to define path.

chapuisk commented 4 years ago

project_path is only accessible within an experiment, while case_study path is used in the global to initialize the simulation ...

chapuisk commented 4 years ago

I have almost finish struggling with path dependency but still have a strange behavior: see the TODO in Parameters.gaml action build_data_set_path (line 254) @AlexisDrogoul @benoitgaudou

chapuisk commented 4 years ago

@ptaillandier found a workaround applying the const: true facets for the default values. However, the problem remain the same for non-constant variables. As a consequence, you cannot choose you case_study. In fact it is even more weird, because the variable case_study is correctly initialized whereas datasets_folder is nil, even if a value have been assigned

AlexisDrogoul commented 4 years ago

It is a bit obscure, but I guess the order in which the variables are initialised plays a role here. I would bet that GAMA does not find the dependencies between the call to build_data_set_path and the two default variables. Can you try two things ?

  1. Remove all the world. prefixes, which are not really useful
  2. Pass to build_data_set_path two parameters (the default values) and use them in the function rather than using directly the global variables.

Tell me if any of these changes modify the behaviour.

chapuisk commented 4 years ago

@AlexisDrogoul I already try these two solutions: for the first one, variable are nil whatever I can do, whereas the second solution is ok but does not provide a solution. The main issue is when you try to give non constant variables (case_study and datasets_folder) a value which is partly recognize by Gama ... I push the model as it is, so you can try by yourself (with nasty write statement in build_data_set_path)

AlexisDrogoul commented 4 years ago

No, the issue is in the computation of dependencies between the variables, which determines the order in which they are initialised. That's why the second solution works: you force the order of initialisation explicitly by using the two constants in the call to the function (these 2 constants must be initialised before calling the function, whereas they must not if they are simply used in the function). This is a bug in GAMA, but the second solution should work well while I'm figuring out how to fix it in GAMA (w/o breaking the compilation phase with recursive functions).

chapuisk commented 4 years ago

Bug fix (https://github.com/gama-platform/gama/commit/81f6d2f1c47a69f491ded784b0ead20775b1eed5)