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

Funny warning in co-models #1999

Closed AlexisDrogoul closed 8 years ago

AlexisDrogoul commented 8 years ago

Steps to reproduce

  1. Open "Urbanization and Traffic Comodel"

    Expected behavior

There shouldn't be any warning

Actual behavior

Funny warning instead (a bit like those on Windows OS !): r1 of type road is assigned a value of type road, which will be casted to road...

System and version

Latest GIT version

modeling - toy models comodels urban and traffic urbanization and traffic comodel gaml - gama runtime 2016-09-21 08-35-05

hqnghi88 commented 8 years ago

It is the same case for list. list rrr<-list(Traffic."Adapter"[0].simulation.road); The only working case is the using of "agent" instead of species name from micro-model. list rrrr<-list(Traffic."Adapter"[0].simulation.road); I am a bit loss in the compilation of types. I dig more.

AlexisDrogoul commented 8 years ago

Bad news: there are two types named road (one in the imported micro-model, the other in the comodel). Good news: they both reference the same instance of species description. So, either we use the "parent" mechanism of the types managers, letting the comodel one inherit from the imported model ones, or we simply patch the isAssignable method to return true when two different types refer to the same species. I'm a bit worried to have two types with the same name in a model, but this might be the quickest way to fix this issue.

hqnghi88 commented 8 years ago

Dear Alexis, I saw that it have 2 types named "road" and surely it point to the same species, but I did not find out how to separate it in the level of syntax. I have proposed but it may be to complex to implement: adding the prefix to the type, e.g. Traffic."Adapter".road r1; to distinct with the existing type road of comodel.

If not, the patch of isAssignable() is a significant solution for me in the following case: Considering the micro-models are the legacy-models, so in most of the cases, these models have the species with the same common names (like road, building). Currently, the using of such kind micro-model still not works (may be new issue).

AlexisDrogoul commented 8 years ago

Hmmm.. I dont really get it. That's because Traffic.road doesn't work as a type, that's it ? So the two types point to the same species, but they should represent two different populations ?

hqnghi88 commented 8 years ago

Dear Alexis, Yes, Traffic.Road does not work as a type. If it work, it will solve another issue that I have mentioned: several micro-models would have species of the same name (many model have the roads, buildings....) and we did not have a solution to distinct them. It should have only 1 type and it must be Traffic.Road and represent 1 populations of Road in micro-model. The existing type "Road" in comodel is so ambiguous if it can point to micro-model's population without any prefix.

AlexisDrogoul commented 8 years ago

Hi, regarding the syntax, I can propose you Traffic<road> instead of Traffic.road. Not sure yet if we can evaluate this correctly, but at least it is on par with the other definitions of types.

hqnghi88 commented 8 years ago

Dear Alexis, Can we have the reverse road? Because I imagine: "list < int > myvar"; // is a LIST variable and the element type is integer "Traffic < road > r"; // is a TRAFFIC variable and the element type is road

"road < Traffic > r"; // is a ROAD variable and it come from Traffic model

AlexisDrogoul commented 8 years ago

Hum... I dont get it. The semantics of the < is not completely fixed (for instance species<road> means any species subclassing road) and it seems to me more logical to firstly describe the container (in that case, Traffic, a model) and then the contents (in that case road). Dont you agree ? Besides, what would "a TRAFFIC variable and the element type is road" represent ? Traffic is not a list nor a map ...

hqnghi88 commented 8 years ago

I am ok with the "species < road > means any species subclassing road".

"a TRAFFIC variable and the element type is road" represent what I could be confused with the syntax of list < int > .

AlexisDrogoul commented 8 years ago

Well, since models are not containers (lists, maps, matrices, etc.) there can't be any confusion in my opinion.

AlexisDrogoul commented 8 years ago

Another question is what to do with road once we make these changes. Should we register it as a type in the co-model or not ?

hqnghi88 commented 8 years ago

Dear Alexis, road in co-model should not be registered. I preferred to use explicitly the origin of species , from which micro-models. road is a species declared in co-model Traffic is a species declared in micro-model traffic Urban is a species declared in micro-model urban

AlexisDrogoul commented 8 years ago

Sorry -- I'm lost. For me, Traffic should be a species of the co-model, and road a species (a type) of Traffic. Or maybe I got your explanation wrong ?

hqnghi88 commented 8 years ago

No, you are right, GitHub eliminate my all < and > I meant: road is a species declared in co-model Traffic < road > is a species declared in micro-model traffic Urban < road > is a species declared in micro-model urban

hqnghi88 commented 8 years ago

I agree , Traffic is a species (alias of model traffic) of the co-model, but Traffic < road > must directly point to the species "road" in micro-model instead of having a false type road in co-model as now.