I have a population of agents as employees. They have a salary which has a formula to be calculated, so I defined it as dynamic variable, "salary". I want to know the average of the salaries, so I went to the statistics and defined:
Name: AvgSalary
Type: Average
Expression : item.Salary
The question is that I may need to assign this number to a variable so that it can be used in other formulas in other stages of my evaluation. How is that possible?
Many thanks in advance,
Your statistic object AvgSalary is already an object you can access. You defined it in the properties of the agent population so you can access it by baccling myAgentPopulation.AvgSalary() and it will always return the current value.
Hope this helps
Related
EX:
I have a population people with agent type Person with a parameter wrist_size.
In the agent type Person I've created another population =watches, agent type =Watch.
Now I want to create a variable in the lower agent type that will be based on the parameter of the upper agent.
length of the watch should be equal to the wrist_size of the person
What should code should I put to the variable?
Many thanks.
You can simply use people.wrist_size in the "initial value" field of Watch.length.
Each embedded population (here Watch within Person) gets a "link" up to their parent agent (here Person named people).
See https://anylogic.help/advanced/code/access.html#where-am-i-and-how-do-i-get-to for understanding model hierarchies.
OK... let me retry the question.
I'll just walk through the steps I (wrongly) assumed would work.
Create a data table in excel with passenger info (id, flight_time, type, class, qty...), note that the table is sorted by id... not flight_time.
Import this database into anylogic.
Create a population of agents (Passenger/Passengers) from the data table (one/row).
Create a schedule that addresses the Start Column as flight_time and Value column as qty (for this job I'm only sending one passenger at a time therefore qty = 1 for each row).
Set the pedSource to arrive according to schedule and to use the Passenger Agent as the New pedestrian.
So here is where I'm losing it. When I run this model the new Passengers do not have any parameters associated from the data table. The pedestrian id is some weird number (say 3000 or so). I can click on the Passengers icon during run time and scroll through the created agents (all of the parameter data is there and correctly assigned), but I'm not sure how to associate the new Agents in the run-time model with the population of Passengers agents.
Am I missing a step here? I was thinking that if I import a population of agents from a data table and then have each show up at a particular time in the model that I could then do some calculations with regard to each such as ped.exitTime = time() - ped.flightTime - ped.bufferTime.
I'm just not understanding why the table data is not available for use during run-time through ped? Is there another mapping step that must be performed to push the data to the ped agnets?
I'm at an impasse at this point. I hope this question is described more clearly and your feedback is appreciated.
Several things are wrong here.
You do not create agents in a pop first and then try to reuse them in a PedSource. The latter creates agents itself.
You don't seem to create pedestrians but just agents
you are not mapping the data to parameters
Quick guide to help:
create custom agent type "MyPed" . Make sure its "use in flowchart" property is set to "Pedestrian"
add 1 param into "MyPed" for each dbase table column
set your PedSource to "calls of inject()" function for its arrivals
delete your schedule, you cannot get the data you need
USe a DynamicEvent. Include 1 parameter argument for each dbase column. On Startup of main, loop across all dbase entries and create a dynamic event with the current row-data.
in the action of the DynEvent, call myPedSource.inject(1) and then manually fill that ped with the data from the arguments
This is not straightforward, especially the DynEvent stuff. So do more research in the AL help to understand these and how they work, check example models...
Is it possible to set a default, initial, value for a parameter in Tableau? Moreover, is i possible to have this contingent on the value of another parameter or dimension?
So for instance, having two time-series A and B with the same measures/dimensions etc., I would like to scale a specific measure within these using the above mentioned parameter. The initial scaling value, however, is supposed to be different depending on time-series A or B.
Any thoughts here?
Thank you
Parameters support a default/initial value. It is called 'current value' in the 'Create Parameter' window.
Parameter values can be changed only using user interaction. It's value cannot be changed using another parameter or dimension, but you can restrict the allowed values based on a dimension.
Above restriction is generally not an issue as you can create calculated fields that depends on other parameters or dimensions. This should be applicable in your case as well, but impossible to be sure without a data set sample.
I am just starting with Anylogic & Java. Could you please help me with my simple issue?
I have two windows: Main & Trucks
The trucks are entities generated on my model using a "source" within "Main".
I asked the model to create 10 trucks at the same time. It creates the trucks and then they move to another defined point at different speeds. When they arrive at the final point I want to know which truck arrived first (1, 2, ... or 10).
So... I am assuming that there is a way to assign a number to each truck when they are created. And I am also assuming I can read this number at the final point to know which one arrived first.
How can I do this?
Yes it is possible. Use a parameter. Truck is an agent and it can have multiple parameters. The easiest way to use parameters is to drag them from the Agent pallet into the Truck window. You define its name and type (in your case will be integer). When the truck is generated at the source you can give the parameter the value you want. If you want to have a sequential number, create a variable in your main window called ID with initial value 1 and then, in the source object, on the On Exit code area you type something like:
Agent.parameter = ID++;
Note that "parameter" should be the name of the parameter you created in Truck window.
Hope that helps.
In SSRS ,I'm trying to build a report using this Parameter screen. One of the parameters takes 5 values, shown below:
Src
However, it's not working.. and I'm not sure why. I also don't understand what's the difference between "Available values" and "default values" ? Any tips appreciated, thanks
Available values are those values that you allow that parameter to have. They are selectable from a drop down list. You can either specify them manually, as you have done, or populate the available values from a dataset.
Default Values holds the initial value that the parameter will be set to. This will be one of the available values. In your example you might set the default value to 0 to indicate a default of "No repsonse to survey". If all the parameters have default values then the report will run automatically.
Now you say it is not working but you don't define what not working means. Please edit your question to define what is happening and what you actually want to happen.
I'll take a quick guess that the values returned aren't being filtered by your parameter selection? If so, you have to use your parameter in the query or the Filter expression of your dataset.
For example, if your parameter is called Response then the dataset query should be something like
SELECT *
FROM Responses
WHERE ResponseValue = #Response