Error code while accessing custom parameter values from excel file - anylogic

I am tryig to build a discrete agent based model.
I have a set of agents with custom parameters, these parameters are loaded via an excel file (this part works, I can view the agents). All agents are created at once at the model start-up.
Now I want the agents to move through the system based on these parameters.
I have build a dummy-model with a selectOutputIn and two SelectOutputOut blocks and a function.
I want the agent to move to selectOutputOutBasic if a string-parameter has a certain value.
The function code is:
if (agent.variation == "Basic")
return selectOutputOutBasic;
else return selectOutputOut;
Anylogic builds the model, but when I try to run it, I get the following error corde:
Exception during discrete event execution:
class com.anylogic.engine.Agent cannot be cast to class test.Order (com.anylogic.engine.Agent and test.Order are in unnamed module of loader 'app')
java.lang.ClassCastException: class com.anylogic.engine.Agent cannot be cast to class test.Order (com.anylogic.engine.Agent and test.Order are in unnamed module of loader 'app')
at test.Main$1.choice(Main.java:1)
at com.anylogic.libraries.processmodeling.SelectOutputIn.b(Unknown Source)
at com.anylogic.libraries.processmodeling.SelectOutputIn.b(Unknown Source)
at com.anylogic.libraries.processmodeling.SelectOutputIn$1.outputBlock(Unknown Source)
at com.anylogic.libraries.processmodeling.InputBlock$1.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutPort.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutPort.b(Unknown Source)
at com.anylogic.libraries.processmodeling.OutPort.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutputBlock.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutputBlock.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutputBlock$2.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutputBlock$2.action(Unknown Source)
at com.anylogic.libraries.processmodeling.AsynchronousExecutor_xjal$a.execute(Unknown Source)
at com.anylogic.engine.LibraryEventHandler$b.execute(Unknown Source)
at com.anylogic.engine.Engine.m(Unknown Source)
at com.anylogic.engine.Engine.jj(Unknown Source)
at com.anylogic.engine.Engine.c(Unknown Source)
at com.anylogic.engine.Engine$b.run(Unknown Source)

Turns out, those who can read have an advantage...
I found the solution to my problem in this post, thanks # Dat Boi!
Try going to the service properties. Under the "Advanced" tab, is
Agent Type selected as "MyAgent" or as "Agent"? Similarly, go to the
source properties and check the tab Agent and make sure "MyAgent" is
selected.

Related

How do I move AnyLogic agents from one space to another?

In my AnyLogic model, Container agents are moved around within the Main agent to various locations.
Main contains several instances of Block agents at specific locations. Block contains a multi-bridge overhead crane which is supposed to pick up the Container and move it to local storage.
When the Container is placed at an Attractor within range of the Block's crane, a process inside the Block is called.
This process contains Entry, MoveByCrane, and Exit blocks.
In the MoveByCrane block, at the seize step, AnyLogic is giving me the following error:
Exception during discrete event execution
root.blocks[0].moveContainerIn.seize:
The agent root.containers[0] and the crane com.anylogic.engine.markup.OverheadCrane#50b7349f have different spaces
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.libraries.material_handling.MHLBlock_xjal.error(Unknown Source)
at com.anylogic.libraries.material_handling.SeizeCrane.j(Unknown Source)
at com.anylogic.libraries.material_handling.SeizeCrane.k(Unknown Source)
at com.anylogic.libraries.material_handling.SeizeCrane.getHookDestinationPoint(Unknown Source)
at com.anylogic.libraries.material_handling.SeizeCrane.a(Unknown Source)
at com.anylogic.libraries.material_handling.SeizeCrane.a(Unknown Source)
at com.anylogic.libraries.material_handling.SeizeCrane$1.onEnter(Unknown Source)
at com.anylogic.libraries.processmodeling.Delay.b(Unknown Source)
at com.anylogic.libraries.processmodeling.Delay.b(Unknown Source)
at com.anylogic.libraries.processmodeling.Delay$9.onEnter(Unknown Source)
at com.anylogic.libraries.processmodeling.InputBlock$1.b(Unknown Source)
at com.anylogic.libraries.processmodeling.InPort.a(Unknown Source)
at com.anylogic.libraries.processmodeling.InPort.receiveImmediately(Unknown Source)
at com.anylogic.libraries.processmodeling.InputBlock$1.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutPort.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutPort.b(Unknown Source)
at com.anylogic.libraries.processmodeling.OutputBlock.forwardReadyEntityNotification(Unknown Source)
at com.anylogic.libraries.processmodeling.InputBlock$1.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutPort.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutPort.b(Unknown Source)
at com.anylogic.libraries.processmodeling.OutPort.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutputBlock.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutputBlock.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutputBlock$2.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutputBlock$2.action(Unknown Source)
at com.anylogic.libraries.processmodeling.AsynchronousExecutor_xjal$a.execute(Unknown Source)
at com.anylogic.engine.LibraryEventHandler$b.execute(Unknown Source)
at com.anylogic.engine.Engine.c(Unknown Source)
at com.anylogic.engine.Engine.hi(Unknown Source)
at com.anylogic.engine.Engine.f(Unknown Source)
at com.anylogic.engine.Engine$b.run(Unknown Source)
All of the Block agents are located at different coordinates within main. They each have their own coordinate reference/origin. (The location (0,0) in the block is not the same as (0,0) in main.) Is this the meaning of the term "spaces" in the error message?
Is there a way to move an agent from one space to another?
Should I remove (sink) the agent from one space and create a new one in the other?
Yes.
Easiest way is to use Enter and Exit blocks in Main and your agent types and send the agents across different spaces this way. In the Enter properties, specify a location within the agent type and it will make your arriving agent "switch" to the new space.
If you are not using process modelling blocks, you need to call setEnvironment() and then define the agent location within its new environment using setLocation(...)

Anylogic - Error when drawing animation frame with custom GIS routes

I am using a GIS map for a waterway transportation system and have to use my own GIS Route (not automatically generated). I use the moveTo block but each time the agent arrives at the GIS Point I get an error message saying:
"Error while drawing animation frame. Possibly caused by dynamic properties of animation shapes. The picture will be restored when (and if) the error goes away."
The following message appears in the console:
Error during drawing animation frame:
java.lang.RuntimeException: root:
gisRoute8 (GISRoute) : Offset (9539.429153529953) is greater than length (687.4357796935112)
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.markup.GISMarkupElement.error(Unknown Source)
at com.anylogic.engine.markup.GISRoute$1.n(Unknown Source)
at com.anylogic.engine.markup.AbstractCurve.n(Unknown Source)
at com.anylogic.engine.markup.AbstractCurve.getPositionAtOffset(Unknown Source)
at com.anylogic.engine.markup.GISRoute.getPositionAtOffset(Unknown Source)
at com.anylogic.engine.markup.SimpleDirection$2.getPositionAtOffset(Unknown Source)
at com.anylogic.engine.markup.AbstractNetwork.n(Unknown Source)
at com.anylogic.engine.markup.AbstractNetwork.n(Unknown Source)
at com.anylogic.engine.markup.AbstractNetwork.n(Unknown Source)
at com.anylogic.engine.markup.AbstractNetwork.getPosition(Unknown Source)
at com.anylogic.engine.markup.AbstractNetwork.getPositionAtOffset(Unknown Source)
at com.anylogic.engine.markup.AbstractNetwork.getPositionAtOffset(Unknown Source)
at com.anylogic.engine.b.i(Unknown Source)
at com.anylogic.engine.ih.updatePosition(Unknown Source)
at com.anylogic.engine.ExtAgentWithSpatialMetricsDelegate.updatePosition(Unknown Source)
at com.anylogic.libraries.processmodeling.l.updatePosition(Unknown Source)
at com.anylogic.engine.Agent.h(Unknown Source)
at com.anylogic.engine.Agent.getX(Unknown Source)
at com.anylogic.engine.ih.getLat(Unknown Source)
at com.anylogic.engine.presentation.ShapeEmbeddedObjectPresentation.updateDynamicPropertiesStructural(Unknown Source)
at com.anylogic.engine.presentation.ShapeAgentGroup_xjal.updateDynamicPropertiesStructural(Unknown Source)
at com.anylogic.engine.presentation.ShapeGroup.updateDynamicPropertiesStructural(Unknown Source)
at com.anylogic.engine.Presentable.n(Unknown Source)
at com.anylogic.engine.Presentable.updateShapeDynamicProperties(Unknown Source)
at com.anylogic.engine.gui.SVGFrameProducer.n(Unknown Source)
at com.anylogic.engine.gui.ExperimentHost$1.l(Unknown Source)
at com.anylogic.engine.gui.ExperimentHost$1.n(Unknown Source)
at com.anylogic.engine.gui.SVGFrameCollector.l(Unknown Source)
at com.anylogic.engine.gui.SVGFrameCollector.c(Unknown Source)
at java.base/java.lang.Thread.run(Thread.java:834)
This happens everytime an agent arrives at a GIS Point from a custom made GIS Route, while automatically generated GIS Routes work. Am I doing something wrong or is this a known bug?
There is an error in AnyLogic 8.7.2 when using custom-GIS-routes: the default setting for the GIS Map to get routes from an OSM server conflicts with agents which are using a custom GIS Network for routing. (Confirmed with AnyLogic support and due for fix in 8.7.3.)
If you are only using custom GIS Routes, you can workaround this by setting the GIS Map (Routing section) so that routes are Straight lines (so that no routing servers are used).
(The error message is stating that it somehow thinks the target point (or some intermediate point en-route) is beyond the extent of the GIS Route network. Initially they are just 'temporary' animation errors but, if you attempt to do a subsequent movement, you get a hard error --- so it seems like the agent has somehow been positioned in a point beyond the confines of the GIS network.)

Node cannot have more than one incoming/outgoing edge

I am trying to start using jbpm and I am following this tutorial.
http://www.mastertheboss.com/jbpm5/jbpm-5-tutorial-first-example?start=1
On the second page I have to add a diverge gateway, converge gateway, constrains, change the type to XOR, and create a variable "money". When I try running the program I get the following error.
java.lang.IllegalArgumentException: This type of node cannot have more than one incoming connection!
at org.jbpm.workflow.core.node.ActionNode.validateAddIncomingConnection(ActionNode.java:50)
at org.jbpm.workflow.core.impl.NodeImpl.addIncomingConnection(NodeImpl.java:100)
at org.jbpm.workflow.core.impl.ConnectionImpl.connect(ConnectionImpl.java:76)
at org.jbpm.workflow.core.impl.ConnectionImpl.<init>(ConnectionImpl.java:71)
at org.jbpm.bpmn2.xml.ProcessHandler.linkConnections(ProcessHandler.java:293)
at org.jbpm.bpmn2.xml.ProcessHandler.end(ProcessHandler.java:145)
at org.drools.xml.ExtensibleXmlParser.endElement(ExtensibleXmlParser.java:422)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.endElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(Unknown Source)
at org.drools.xml.ExtensibleXmlParser.read(ExtensibleXmlParser.java:301)
at org.drools.xml.ExtensibleXmlParser.read(ExtensibleXmlParser.java:180)
at org.jbpm.compiler.xml.XmlProcessReader.read(XmlProcessReader.java:46)
at org.jbpm.compiler.ProcessBuilderImpl.addProcessFromXml(ProcessBuilderImpl.java:262)
at org.drools.compiler.PackageBuilder.addProcessFromXml(PackageBuilder.java:673)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:709)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:51)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:40)
at com.sample.ProcessMain.readKnowledgeBase(ProcessMain.java:31)
at com.sample.ProcessMain.main(ProcessMain.java:20)
Exception in thread "main" java.lang.IllegalArgumentException: Could not parse knowledge.
at org.drools.builder.impl.KnowledgeBuilderImpl.newKnowledgeBase(KnowledgeBuilderImpl.java:79)
at com.sample.ProcessMain.readKnowledgeBase(ProcessMain.java:32)
at com.sample.ProcessMain.main(ProcessMain.java:20)
0 02/04 10:05:21,243[main] ERROR builder.impl.KnowledgeBuilderImpl.newKnowledgeBase - ProcessLoadError: unable to parse xml : Exception class java.lang.IllegalArgumentException : This type of node cannot have more than one incoming connection!
I tried debugging, by deleting nodes/edges until I got different errors. If I delete a whole branch, the error will be that gateways need 1+ edges. If I delete edges from one of the branches it will say that the script has more than one incoming/outgoing edge. It seems to be that the second script with different id and name, is being confused with the first or there are edges that I cannot see.
Extra Questions:
1. How do i know which node it is referring to? (I am using eclipse, and the links that normally would send you to a code line do not show anything)
Screenshot of the problem:
![http://imgur.com/0gL5twY][1]
Can you share your process diagram image?
It is making reference to an ActionNode which is usually a Script Node.
I will recommend you using the web process designer which is much better in terms of features and validations.
Regards

error while loadin applet in web application

I want to run my applet on web application, but i got some error which i mentioned below please help me to get out of this problem
Java Plug-in 1.7.0
Using JRE version 1.7.0-ea-b116 Java HotSpot(TM) Client VM
User home directory = C:\Users\HONEY
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------
java.lang.RuntimeException: java.lang.NoClassDefFoundError: mp3$1
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: mp3$1
at mp3.<init>(mp3.java:93)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$12.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: mp3$1
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 16 more
Caused by: java.io.IOException: open HTTP connection failed:http://viscous10.webng.com/mp3/mp3$1.class
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 21 more
Exception: java.lang.RuntimeException: java.lang.NoClassDefFoundError: mp3$1
but it happens only if i run applet with events
and in simple applet i never occurred
This error means the Java runtime cannot find the .class file for an anonymous inner class of your mp3 class. Anonymous inner classes are named OuterClass$1, OuterClass$2, OuterClass$3 and so on. An example of the definition of an anonymous inner class:
button1.addActionListener(
new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent e)
{
// do something
}
}
);
As it seems you are using inner classes, be aware that your mp3.java source file creates various .class files and make sure all of these .class files are available for the runtime environment (via copying, or adding them in a .jar file, etc).
to run the applet on web browser
write java code run the application on java
make the class file by using cmd prompt
give proper path and run your java file on cmd prompt to create class file
make html file add applet code in it <applet code=file.class archive =file.zip/jar></applet>
enabled java console from control panel
run the html file and refresh the window
NOTE: make sure class file, html file,zip or jar file having same name for avoiding any confusion

Error in applet in the navigator with fingerprint reader

First thank you very much for your time, I have a problem with the development of an applet to control users via fingerprint, as developed in eclipse using the DigitalPersona SDK, the problem is when I run it from a web page browser,
Exception in thread "AWT-EventQueue-2" java.lang.RuntimeException: com.digitalpersona.onetouch.jni.JniException
at com.digitalpersona.onetouch.capture._impl.DPFPCaptureFactoryImpl$CaptureImpl.startCapture(DPFPCaptureFactoryImpl.java:187)
at CDesVerifinger.formComponentShown(CDesVerifinger.java:76)
at CDesVerifinger.access$1(CDesVerifinger.java:73)
at CDesVerifinger$1.componentShown(CDesVerifinger.java:64)
at java.awt.Component.processComponentEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: com.digitalpersona.onetouch.jni.JniException
at com.digitalpersona.onetouch.jni.AcquisitionLibrary.getInstance(AcquisitionLibrary.java:50)
at com.digitalpersona.onetouch.jni.Acquisition.<init>(Acquisition.java:45)
at com.digitalpersona.onetouch.capture._impl.DPFPCaptureFactoryImpl$CaptureImpl.startCapture(DPFPCaptureFactoryImpl.java:104)
... 16 more
Thank you very much for any help
good day
You need to add the dptojni.jar to the library of your project, it is in c:/programs files/digital persona/bin/java. Or you can get the class jniException and add it to your project.
Having the same problem, here is someone telling that is necessary put
capturer.setPriority(DPFPCapturePriority.CAPTURE_PRIORITY_LOW);
after calling createCapture to solve it. I will try this answer now.
You have to sign the jar files. That's what I did, and now it's working.
Make sure you have instatiated the DPFPCapture object before calling the setCapturePriority method and also make sure you stop capture after you have finished using the capture object