Artem Nazarenko
Artem Nazarenko

Reputation: 71

AnyLogic Error while trying to move agents in hierarchical model

Task description: Model containing two types of agents, one type of agents is living in other. Trying to move agents among agents of higher order, I used following code (finding the random connected agent, then trying to increase its population and then defining the position inside):

City destinationCity = (City) city.getRandomConnectedAgent();
this.goToPopulation(destinationCity.population);
double newX = uniform(-50, 50);
double newY = uniform(-50, 50);
this.setXY(newX, newY);

Code is successfully compiled, however anylogic itself throws an error:

java.lang.RuntimeException: root.cities[0].population[40]:
INTERNAL ERROR: moving shape from one owner directly to another: com.anylogic.engine.presentation.ShapeEmbeddedObjectPresentation@566dc332 -> com.anylogic.engine.presentation.ShapeEmbeddedObjectPresentation@f8b9090
    at com.anylogic.engine.Engine.error(Unknown Source)
    at com.anylogic.engine.Agent.error(Unknown Source)
    at com.anylogic.engine.Utilities.error(Unknown Source)
    at com.anylogic.engine.Utilities.error(Unknown Source)
    at com.anylogic.engine.internal.ac.l(Unknown Source)
    at com.anylogic.engine.presentation.Shape.l(Unknown Source)
    at com.anylogic.engine.presentation.Shape3D.l(Unknown Source)
    at com.anylogic.engine.presentation.ShapeTopLevelPresentationGroup.setOwner_xjal(Unknown Source)
    at com.anylogic.engine.Agent.setOwnerShape_xjal(Unknown Source)
    at com.anylogic.engine.presentation.ShapeEmbeddedObjectPresentation.setEmbeddedObject_xjal(Unknown Source)
    at com.anylogic.engine.presentation.ShapeEmbeddedObjectPresentation.<init>(Unknown Source)
    at hierarchicalmodel__mobility_.City._population_presentation_createShapeWithStaticProperties_xjal(City.java:366)
    at hierarchicalmodel__mobility_.City$1.createShapeWithStaticProperties_xjal(City.java:388)
    at com.anylogic.engine.presentation.ShapeAgentPopulationGroup.createShapes(Unknown Source)
    at com.anylogic.engine.presentation.ShapeAgentPopulationGroup.updateDynamicProperties(Unknown Source)
    at com.anylogic.engine.presentation.ShapeGroup.updateDynamicProperties(Unknown Source)
    at com.anylogic.engine.Presentable.l(Unknown Source)
    at com.anylogic.engine.Presentable.updateShapeDynamicProperties(Unknown Source)
    at com.anylogic.engine.presentation.ShapeEmbeddedObjectPresentation.updateDynamicProperties(Unknown Source)
    at com.anylogic.engine.presentation.ShapeAgentPopulationGroup.updateDynamicProperties(Unknown Source)
    at com.anylogic.engine.presentation.ShapeGroup.updateDynamicProperties(Unknown Source)
    at com.anylogic.engine.Presentable.l(Unknown Source)
    at com.anylogic.engine.Presentable.updateShapeDynamicProperties(Unknown Source)
    at com.anylogic.engine.presentation.Panel.d(Unknown Source)
    at com.anylogic.engine.presentation.Panel.j(Unknown Source)
    at com.anylogic.engine.presentation.Panel$c.run(Unknown Source)

The problem lies inside this line, without this line agents are moving, however parameter for population number remains unchanged:

this.goToPopulation(destinationCity.population);

Will be grateful for any help (probably you know different way of moving agents among agents of higher order)!

Upvotes: 2

Views: 1881

Answers (1)

Gregory  Monahov
Gregory Monahov

Reputation: 721

This is a bug of AnyLogic 8.0-8.2. AFAIK, the error appears in case if target population is located at Main. There is workaround: put the target population inside dummy agent at Main (see screenshot): goToPopulation bug workaround

The bug should be fixed in AnyLogic 8.3 or 8.4.

Upvotes: 2

Related Questions