AnyLogic: Populate Time Color Plot with one row per agent - simulation

In AnyLogic 8, how do I create a Time Color Plot which has one row for each agent in a pool of agents?
As explained in an answer to this question, I can create a separate dataset for each row, and then have the Time Color Plot display one row for each dataset. But this requires hardcoding the number of datasets (and thus the number of agents), whereas I want to create a model with a variable number of agents and thus a variable number of rows in the Time Color Plot.
This AnyLogic cloud model includes a Time Color Plot where each forklift in a pool of agents has its own row in a Time Color Plot. Unfortunately, because it is a cloud model, I cannot download the model to investigate how it is built.
How do I create a Time Color Plot where each row corresponds to an agent in a pool of agents (like in that linked cloud model)?

You can simply add the datasets programmatically using
chart.addDataSet();
Here is the code for the model you referenced where the chart starts off empty (except for the color setup) and you simply add the bars during run time.
You can also remove them as needed.

Related

Resource layout creation in Anylogic

I am using creating my equipments as resourcepools which are created within a rectangular node as a zoning region. During the model run I will increase or decrease the equipment quantity using a slider. I have set the settings to destroy the units when capacity is reduced (as guided in this thread Removing agent when resourcepool capacity reduced). However, after reducing the capacity, the first few rows of resources are destroyed and when the capacity is increased again, new equipments are built from the last row within the node, leaving the first few rows permanently empty. How can I rearrange the layout to always fill up the empty regions first?
You need to take control of positioning the agents yourself. Use the "on unit creation" code box to 'unit.setXY(...)' and position them where needed. Note that AnyLogic does also not care about positioning agents on top of each other. So if you want to have a concept of "this space is taken" you need to model that explicitly as well, best via a custom agent type itself.

Time plot does not update

I have two agents:RE and SUB.
Agent RE is the content and Agent SUB is the container.
The container SUB moves to a gis point and picks up RE and I want to know the number of RE that picked up by the container.
I tried to use time plot to obtain the number and visualize it, with code agent.contents().size().
But the time plot did not update after I run the model.Do you have any solution to this?
enter image description here
enter image description here
/wYAkZ.png
Appreciate for any help!
enter image description here
enter image description here
Based on your screenshot you are trying to plot the size of the container element inside the pickup object (which will always be empty) and not the size of the container agent that is used in the pickup object.
See the simple example model below
As you can see when an object exists the pickup block I add the size of the contents it is carrying to the dataset.
Since I am adding the data manually to the data set I have disabled all auto-updating on the data set
as well as the chart
For the simple example I have set the container agent (the top source) to sent agents about every minute, and for the agents that will be loaded into the container to arrive about every second.
Here are the results

Tableau: stacked column with line

I'm trying to graph workload (by day) stacking hours from tasks. I'd like to add a line indicating daily capacity of the relevant resource. I have a table for tasks and table for daily resource capacity.
When adding capacity as an independent data source, I get an error indicating I need a relationship to the primary data source.
If I join the data (on date and resource), I can get a capacity line to show, but only by adding it to the secondary axis, which leads to mismatching of scales (unless I lock in the same maximum scale for both primary and secondary axes). This works, but it's less than ideal :
a) it requires foreknowledge of maximum load,
b) lower usage resources barely move off the horizontal axis,
c) it seems to force the capacity line to use the same color palette as the column chart, plotting each time period with a different color.
Does anyone have any better suggestions?
So both axes are hours? You can synchronise the two axes to make it dynamic. Just right click on the axis on the right and there should be a check box titled "synchronize dual axes". Check that and it will sync both of them and will responded to changes dynamically.
You can also then hide the axis marks for hours on the right to make it look better. Again right click the axis and deselect the "Show Header" option.

Changing Map Color based on parameter

I'm working on a dashboard which shows me election results across election years.
I've created a parameter which has 3 values (strings) - 3 different election years. There are 3 categorical variables (winning party in each constituency) in my shape file which are associated with each of these parameters. I can drag the pill of these variables to color and get the resulting map.
I want to be able to choose an election year and have the color change accordingly in the map based on winners. How can I do this?
why not use a filter for election year instead of a parameter, with it set as a single selection, this will let the user select just one year, and the map would be coloured accordingly.
Created a variable EY which has election years and which goes into filter.
Created a calculated field dependent on EY which changes based on election year and put this pill into color. So map color changes when I change EY now!

Need more control over Pentaho PI chart slices

Pentaho gives you the option of easily generating a PI chart using it's report designer. I have a query that can return the following values
Over Inflated
Under Inflated
Within Specification
These values will each represent a slice within the PI chart. I have two problems.
Problem number 1
I have a query returning the following,
Over Inflated
Within Specification
Within Specification
Over Inflated
Over Inflated
Over Inflated
Note that the results do not include a single value that is equal to Under Inflated. This will result in a pie chart as indicated below.
I need the pie chart to indicate to the user that there is also a third slice represented within this chart (Under Inflated). Even though the value for Under Inflated records is 0%.
Problem number 2
Pentaho gives you the option to specify the colors of the slices. I need to link the colors of the slices to a specific value. For instance Over Inflated should be displayed as red, Under Inflated should be displayed as orange and Within Specification should be displayed as green.
Is there any way in Pentaho to do this?
There is no easy way to bind colours in PRD other than by ensuring the data is in a consistent sort, and defining the colours in that order - i.e. it wont always work.
However saying that you can bind the actual data values if you use a beanshell chart processing script.
To get the 0% slice appear you just ensure your data set returns it. So the best way to do this is just to outer join from your dimensions to the actual data, then you'll always get the 3 values - even if one is zero.
If you want more/ultimate control you could move to ccc charts. PRD is moving to ccc charts in the future anyway - but unfortunately the only way to use these currently would be to link via CGG - not a perfect scenario (not least of all because that needs a running server too). But a possibility.