Im new on Anylogic and is building an Student Service simulation, in it I thought a senario that if student coming to service center with simple question, staff can solve that quickly, otherwise it takes staff more time. I use a statechart to implement the question type of student:enter image description here
and I set corrpesond delay time as:
enter image description here
Once I try to build, complier give me an error:
enter image description here
What does it mean? Can anyone tell me how to solve that?
you have to use the short version of the if statement which returns a value
if(condition) else DOESNT return anything
instead use this:
agent.inState(agent.simpleQuestion) ? triangular(1,2,3) : triangular(3,4,5)
or instead you could do the same but you should create a function and add the function to the time delay
timeDelay(agent)
and in the function you would do
if(agent.inState(agent.simpleQuestion))
return triangular(1,2,3);
else
return triangular(3,4,5);
Related
In following up related to my previous question previous question, when a schedule programmatically is created, where I run the function at the start-up of my main (see image 1), I want to change the transporterfleet (image2) schedule based on this. But when I do this by the initschedule function the next error is given " The parameter capacitySchedule cannot be changed dynamically". So my question is how can you use a programmatically created schedule use in the capacity definition of a transporter fleet?
Later added in response to Benjamin
In the Capacity field, write schedule == null ? 0. : schedule.getValue()
This will link it to your programmatic schedule, but only after it has been created (which is not done right at the start of the model but an instance later).
I am currently working on a parking place simulation. Before entering the parking place, a car has to cross a border. To simulate that, I added a "carMoveToBorder" block, where the car moves to a stopline. Then I added a service block to simulate the time getting served by the borderService. Now that I am having a car network, I dont really know how to specify the location of the delay or the queue inside the service block. I tried specifying the location of the delay by entering the name of the stopLine but I got an error message saying: Type mismatch: cannot convert from Agent to AnimationStaticLocationProvider
Pictures are below.
Help is appreciated.
Thank you for your time.
borderServicePicture1
borderServicePicture2
why dont you try to use Delay instead of Service. One of the difference between them is that Service has embedded queue. But maybe in your case the car will never use that queue, i mean if its right in front of border but not quite there, it means its still in CarMoveToBorder block. And i guess in Delay you just dont have to set any agent location. (btw, what happens if you leave agent location blank in Service?)
Is there a way to raise a flag on the Navmesh navigation end, or to use a callback when it finish?
I want to run a function when my objection reach to the desire position, I can check on every frame update if the navigation has finished but I want a more elegant and efficient solution.
Thanks.
It depends what you mean by "ends", if you want to know when a path is no longer available for the NavAgent, you can use pathStatus, for example you could write:
if(myNavAgent.pathStatus != NavMeshPathStatus.PathComplete) {
// Do stuff
}
If you me reaching a location such as a "waypoint" you can use myNavAgent.remainingDistance then check if it is less than a certain value.
Here's the unity NavAgent scriptingAPI doc link: https://docs.unity3d.com/ScriptReference/AI.NavMeshAgent.html
If this doesn't work, let me know!
I have Thought the same question and i couldn't find a callback, However i managed to solve with triggers. For example if my agent goes point a, i put trigger that position and when my agent touches it i stopped agent.
I am very new at Anylogic. I have a simple model, using the Fluid dynamics library: two tanks and a valve between them. The valve have to open at a rate, say X, only when the amount in the first tank, say tank_1, were twice of the amount of the second tank, say tank_2
Could you please help me with that?
Regards
You probably have more conditions on what to use with the valve depending on different things. But it's a bad idea to make something occur when then tank_1 is exactly 2 times larger than tank_2... Instead, create a boolean variable that tells you if the current situation is that tank_1 is over or below 2*tank_2. Let's call it "belowTank2". I will assume tank_1 is below 2*tank_2 in the beginning of the simulation. so belowTank2 is true.
Then you create an event that runs cyclically every second or even more often if you want and you use the following code:
if(belowTank2){
if(tank_1.amount()>2*tank_2.amount()){
valve.set_openRate(0.1);
belowTank2=false;
}
}else{
if(tank_1.amount()<2*tank_2.amount()){
valve.set_openRate(0.3);
belowTank2=true;
}
}
So this means that whenever tank_1 surpases 2*tank_2, it will trigger the rate change on the valve. And it will trigger again a change when it's below 2*tank_2
I am trying to use MATLAB in order to know for every single time that a function is called, Matlab returns a specific value.what kind of command i can use that do this for me.
for example for first call return 1000 and for second time return 2000.
Try with the profiler. You will know the number of times that a function is called and the time that has taken.
In the main function:
profile on
To stop it:
profile off
And to show the statistics:
profile viewer
Hope it helps!