Anylogic - delay dependent on resources - anylogic

I am trying to create a service that varies depending on the resources that are used.
For example if a nurse were to carry out the service it could take 10 - 35 mins, whereas if this is carried out by another member of staff it could take 5-25 minutes.
I have had a go - as in the picture below, however, what I've written doesn't seem to be working.
Resource dependent delays
Any help would be massively appreciated!

First, since the parameter "Delay time" accepts a value, you need to replace if-else statement with conditional expression "? :". The syntax is the following: condition ? value if true : value if false.
Moreover, your should use another condition to check if the agent has a resource unit from "Nurse":
agent.resourceUnitOfPool(Nurse) != null ? triangular(10, 15, 35) :
triangular(5, 10, 25)

Related

How can I return true in COBOL

So I am making a program that checks if a number is divisible by another number or not. If it is its supposed to return true, otherwise false. Here's what I have so far.
P.S : I'm using IBM (GnuCOBOL v2.2 -std=ibm-strict -O2) to run this.
IDENTIFICATION DIVISION.
PROGRAM-ID. CHECKER.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 BASE PIC 9(5).
01 FACTOR PIC 9(2).
01 RESULT PIC 9(5).
88 TRU VALUE 0 .
88 FAL VALUE 1 THRU 99 .
PROCEDURE DIVISION.
CHECK-FOR-FACTOR SECTION.
IF FUNCTION MOD(BASE, FACTOR) = 0 THEN
SET TRU TO TRUE
ELSE
SET FAL TO TRUE
END-IF.
END PROGRAM CHECKER.
It gives me error saying invalid use of level 88. I'm sure I'm making a mistake, and I've searched for couple of days and I can't seem to find anything that can help me with it. Any ideas if it is possible in COBOL or does COBOL handle all the boolean stuff some other way ?
(Kindly do not reply with look up level 88 or some other stuff like that, I have already looked them up and they haven't been helping)
To return TRUE from a program you'd need an implementation that has boolean USAGE, define that in LINKAGE and specify it in PROCEDURE-DIVISION RETURNING true-item and also use CALL 'yourprog' RETURNING true-item.
Your specified environment GnuCOBOL doesn't have a boolean USAGE in 2021 and can't handle RETURNING phrase of PROCEDURE DIVISION in programs.
But you can use a very common extension to COBOL which is available in both IBM and GnuCOBOL:
Before the program ends MOVE RESULT TO RETURN-CODE (which is a global register) and in the calling program check its value (and reset it to zero).
Then it is only up to you what value means "true" (in your program it is 0).
As an alternative you could create a user-define function (FUNCTION-ID instead of PROGRAM-ID and use the RETURNING phrase to pass your result) - but that would mean you need to use IF FUNCTION instead of CALL + IF RETURN-CODE in each caller.

Trying to use dynamic and action parameters

recently I stumbled upon one of the videos of Benjamin Schumann titled: What are dynamic and action parameters and when should you use them in your AnyLogic model.
I tried to further adjust the functions of dynamic and action based parameters for a problem of mine. Just to give a heads up, I am fairly new to Anylogic (only worked through that one book, and some minor projects and tutorials) and been decent in Java (been a few years since I've been actively working in Java but currentlystarting to get back in [still rusty]).
Regarding my actual problem, in the video Mr. Schumann has an agent with three parameters. One static, one dynamic and one action. In addition to that he has a variable (double) all set in his agent. On his main is a button to increment the value of the variable with the help of the parameters and to trace the lines in the console (= giving out a string if a certain threshold of the variable is passed).
I created a similar setting, however I happen to run into a lot of variable errors during time to time while compiling.
Here some example code snippets:
dynamic parameter p_Station of the type String
v_myFahrt < 222 ? "Wiesbaden Hbf" :
v_myFahrt < 442 ? "Wiesbaden-Biebrich Bahnhof Wiesbaden Ost" :
v_myFahrt < 663 ? "Wiesbaden-Mainz-Kastel Bahnhof" :
"Hochheim (Main) Bahnhof"
therefore my variable is called v_myFahrt, a double with the initial value of 0
action parameter p_durchFahrt with the default action:
v_myFahrt = v_myFahrt + 220;
and my Button on the main:
myAgent.p_durchFahrt();
traceln(myAgent.p_Station());
So basically it is a somewhat similar code as in the reference. I tried to than add another instance of the agent with a different set of "code" for the dynamic parameter (different Strings and values) as well as a different "code" for the action parameter (e.g. + 208 instead of + 220). To then wanting to trace the lines in the console with the button again.
I tried to add
myAgent1.p_durchFahrt(); traceln(myAgent1.p_Station());
to it.
But before I coul even run it, I keep getting the error "v_myFahrt cannot be resolved to a variable" for myAgent1. Inspecting the error it keeps referring to myAgent1 with the newly added code for p_Station and I can't seem to find a way around it.
What am I doing majorly wrong here?
it looks like you have created v_myFahrt in main, right? (that would explain your symptoms).
If yes, you should create it in MyAgent instead.

Tablix Expressions (Multiple Condition)

I'm currently experiencing
The Value expression for the textrun ‘Textbox137.Paragraphs[0].TextRuns[0]’ contains an error: [BC30198] ')' expected.
=(Variables!Seconds.Value <= 500,"PASS", "FAIL") OR (Variables!Seconds.Value < 0,"N/A","")
This is a results column. In event that seconds is negative number it will be N/A. which means anything less then 0.
any thoughts on my syntax.
Not really sure where to begin with this as the syntax is almost entirely wrong, unfortunately. From my best inference, I am guessing you want N/A if less than 0, PASS if less than or equal to 500, and FAIL for anything above that. I'm also not sure why you're using variables rather than populating your data with a query and using the Fields!... syntax, but that's another issue entirely. To fix your current issue, you've neglected to include the IIF function that you seem to be trying to use. I think the expression you'll want is the following.
=IIF(Variables!Seconds.Value < 0, "N/A", IIF(Variables!Seconds.Value <= 500, "PASS", "FAIL"))
This will first check the variable to see if it is less than 0, printing N/A if so. If false, it will evaluate the second IIF that will print PASS for less than 500 and FAIL for anything above 500.

How do each agent specify different parameters?

I am modeling the type of Customer agents. They are given parameters: they work (true / false) and have education (true / false).
There is a condition that agents in the block service fall where works == true and education == true. And all the others go to the exit.
enter image description here
How do each agent specify different parameters?
So the first thing to notice here is that your queue block does nothing and you could just remove it.
And to change the parameters of your agent, in your source, in the "on at exit" action you can write the values you want, for instance:
agent.works=false;
agent.education==true;
you can also create random values...
agent.works=randomTrue(0.5);
agent.education==randomTrue(0.5);
also, if you go to your agent's variable "works", in the default value, you can make it also random writing randomTrue(0.5)
where randomTrue defines how likely it is for your variable to be true (0.5 means 50% chance)

iReport - Concatenating two variables with different evaluation time

I have two variables
$V{from} has evaluation value set to Now and
$V{to} has evaluation value set to Group.
Both seems to be working fine.
Now I need to append them. Currently I have $V{fromTo} which has expression $V{from} + "-" + $V{to}. Its evaluation time value is Group. What I want is just to simply append the current values of the two first mentioned variables. The current expression gives me the result (e.g. from = 1, to = 45)
45-45
Seems like the expression is taking the value of $V{from} evaluated during group execution time also. Any idea how to do this?
(Note, requirement does not allow me to just simply drag the two fields, i badly needed to store it in one variable)
I had the same problem. I solved setting Evaluation Time to Auto in my Text Field.