Jahidul Hasan Razib
Jahidul Hasan Razib

Reputation: 312

How to map PED SOURCE new agents with Dbase Table in Anylogic?

I am working on a model, where I need to generate agents through pedsource block with parameters read from dbase table. Here is the dbase, enter image description here

Next, I created a Population of patients with agent type Patient. I mapped the agent parameters on patients population on Main Agent, See Image

enter image description here

I have set the add pedestrians to patient population, see image enter image description here

When I am running the model, I am getting the following error

Exception during discrete event execution:
root.pedSource:
Error when trying to initialize new agent
Caused by: Not unique database value!
java.lang.RuntimeException: root.pedSource:
Error when trying to initialize new agent
    at com.anylogic.engine.Engine.error(Unknown Source)
    at com.anylogic.engine.Agent.error(Unknown Source)
    at com.anylogic.libraries.processmodeling.Source.initializeNewEntity(Unknown Source)
    at com.anylogic.libraries.processmodeling.Enter.take(Unknown Source)
    at com.anylogic.libraries.processmodeling.Source.inject(Unknown Source)
    at com.anylogic.libraries.processmodeling.Source.executeActionOf(Unknown Source)
    at com.anylogic.engine.EventTimeout.execute(Unknown Source)
    at com.anylogic.engine.Engine.l(Unknown Source)
Error during drawing animation frame:
java.lang.NullPointerException
    at com.anylogic.engine.presentation.ShapeEmbeddedObjectPresentation.resetSVGState(Unknown Source)
    at com.anylogic.engine.presentation.k.resetSVGState(Unknown Source)
    at com.anylogic.engine.presentation.ShapeAgentPopulationGroup.resetSVGState(Unknown Source)
    at com.anylogic.engine.presentation.ShapeGroup.resetSVGState(Unknown Source)
    at com.anylogic.engine.gui.SVGFrameProducer.a(Unknown Source)
    at com.anylogic.engine.gui.SVGFrameProducer.a(Unknown Source)
    at com.anylogic.engine.gui.ExperimentHost$1.f(Unknown Source)
    at com.anylogic.engine.gui.ExperimentHost$1.f(Unknown Source)
    at com.anylogic.engine.gui.ExperimentHost$1.a(Unknown Source)
    at com.anylogic.engine.gui.SVGFrameCollector.a(Unknown Source)
    at com.anylogic.engine.gui.SVGFrameCollector.f(Unknown Source)
    at java.base/java.lang.Thread.run(Thread.java:834)

    at com.anylogic.engine.Engine.nb(Unknown Source)
    at com.anylogic.engine.Engine$f.run(Unknown Source)
Caused by: java.lang.RuntimeException: Not unique database value!
    at com.anylogic.engine.database.SelectQuery.a(Unknown Source)
    at com.anylogic.engine.database.SelectQuery.uniqueResult(Unknown Source)
    at com.anylogic.engine.database.SelectQuery.uniqueResult(Unknown Source)
    at medicalsupport.Main.setupParameters_patients_xjal(Main.java:1647)
    at medicalsupport.Main$_patients_Population.callSetupParameters(Main.java:322)
    at medicalsupport.Main$_patients_Population.callSetupParameters(Main.java:1)
    at com.anylogic.engine.AgentList.callSetupParameters(Unknown Source)
    at com.anylogic.engine.Agent.goToPopulation(Unknown Source)
    ... 8 more

Upvotes: 1

Views: 80

Answers (1)

Benjamin
Benjamin

Reputation: 12795

Your queries are wrong. Don't set the params in the population, set them in the PedSource "on exit" code box.

Something like ped.set_id(theValueYouNeedfromTheDbaseUsingaCorrectQuery)

To write a proper query, use the query wizard

Upvotes: 1

Related Questions