I have am model which simulates a distribution network.
I have a population of agents (customers), develop from a database (address -> Gis Location and the order time)
Also I have a order agent, which has a parameter "customer"
I have a source in the customer agent to generate orders and the code at source exit: agent.customer = this;
In the source I've set Arrival deffined by: Arrival table in Database and refer to the customer -> order time. My problem is, that I currently generating in every source of this population every order. How can I set up the source/model, that I generate at a specifc customer only the orders from this one?
Unfortunately, a Source object can only ingest the whole table and there is not function to filter records. One way to go about partitioning Order agents is by creating all of them in a single source somewhere in the model and then using Exit to send them to an Enter object within a specific Customer agent. To summarise:
There is a single Source that reads the 'Orders' table for all customers
Each record has a field with 'customer id' so when agent gets created it has a property of which customer it belongs to
Source object feeds all new Order agents into an Exit object
Each Customer agent has an id and an Enter object
Source's Exit object contains code which finds Customer agent based on 'customer id' property and then calls customer.enter.take(agent) to send the Order agent into the right Customer agent
More information about here: Enter and Exit.
Related
The model I am working on is set up as follows. It contains four agent types:
Patient
SmallHospital
MediumHospital
BigHospital
. All these agents are located in Main. SmallHospital and MediumHospital agents are connected in a network to BigHospitals using link to agent objects e.g.: mediumHospitalLink and bigHospitalLink.
When generated, Patients move, via a statechart in Patient, to nearest hospital agent (regardless of type, using this function in Patient). The hospital agent to which the Patient moved to is stored in a parameter in Patient called p_myFirstHospital. This parameter has type 'Agent' as I do not beforehand to which hospital type the agent will be move to. This results in no error and functions as expected.
However, I want to move the Patient-agent to a second hospital after a while. If the Patient is currently in a smallHospital, it should move to the mediumHospital to which the smallHospital is linked to, and likewise, if the Patient is in a mediumHospital, it should move to a bigHospital to which the mediumHospital is linked to.
I expected that I would be able to call from within Patient the following code to access those agents:
p_myFirstHospital.mediumHospitalLink.getConnectedAgent();
or through a simple function I created. It should retrieve the agent from the Link to agents located in the hospital agent stored in p_myFirstHospital.
Unfortunately, this does not work. The compiler returns the following error message:
Description: smallHospitalLink cannot be resolved or is not a field. Location: model/Patient/f_DetermineSecondHospital - Function
Am I missing some Java or AnyLogic subtleties? Your help and suggestions are very welcome.
That's because p_myFirstHospital is of type Agent
So you need to make java magic as follows:
case1:
p_mySecondHospital=((SmallHospital)p_myFirstHospital).mediumHospitalLink.getConnectedAgent();
case2:
p_mySecondHospital=((MediumHospital)p_myFirstHospital).mediumHospitalLink.getConnectedAgent();
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...
I am creating a data flow task which will be extracting data from a source table and will be updating a destination table as follows:
1) Use the unique id in the source record to find the record you want to update in the destination table.
2) If the ID does not exist in the destination table, check whether the email of the source record exists in the destination table instead.
a) If the email exists, update the destination record through the email. Also update the unique id of that destination record.
b) If the email does not exist, insert a new record to the destination table.
So, with simple words, I am creating a task that will be updating a table on its unique id and if it does not have a match, it will be attempting to update on its email. If it still does not find a match, it will be inserting a new record.
This means that I will have two updates running in parallel as you can see in the image (the two circled components will be running in parallel)
SSIS_Data_Flow_Task
Now, this generates a deadlock issue because of those two updates.
I have tried using With (NOLOCK) but this hint is for reading data, not updating it. I also have searched for delay tasks to delay one of the two data pipelines until the other is finished.
Any ideas? Could I maybe design my data flow task differently in order to avoid having multiple parallel updates in the first place?
Any help will be greatly appreciated.
with these type of flows i always work with a work table (dest table id, work type (U or I), ...). in a first step i fill a table with work that needs to be done, then i apply the work.
I have forwarded travel expense approval task from one manager to
another manager in sap fiori. Can anyone tell me how to get the
current approver?
Thanks
Are you able to use ABAP? Then this might solve your issue.
You need to enhance ABAP logic for this certain scenario in fiori.
determine your workflow, workitem id (wi_id)
determine current agent via
CALL FUNCTION 'RH_USERS_OF_WI_READ' "Get Current Agents (Users) for Work Item
EXPORTING
wi_id = " swwuserwi-wi_id
TABLES
user_tab = " swhactor
EXCEPTIONS
NOTHING_FOUND = 1 "
. " RH_USERS_OF_WI_READ
use HROBJID of swhactor to determine personnel number or central person
read name of HROBJID e.g. via infotype table PA0001 (e.g. field ENAME)
Suppose I have two objects
1.Account- standard object[it has a field name Status_c which is a picklist having value inprogress and closed]
2.Client_c - custom object[it also have same field name Status__c which is a picklist having value inprogress and closed]
and Client__c has lookup to Account name which means Account has a related list of client object .
My question is :
I want to write a trigger where if I put account status to "closed" I can not put client status to "closed",it should throw an error message on client object or if I put client status to closed I can not put account status to closed vice versa.
Can any one please help me to write a trigger on this??
Conceptually, I think what you are looking to do is set up Validation Rules on both of those objects. Your validation rule on Client_c should be pretty simple: TEXT(Status_c) == 'Closed' && TEXT(Account_c.Status_c) == 'Closed'
The more interesting piece is how you handle making sure none of your related items are Closed when you move the Account to Closed. I tend to prefer creating a field on the Account that keeps track of the status of the related items (checkbox) that basically tells me whether it is valid for me to change my status or not. In this case, the validation rule becomes pretty simple. In order to set that boolean value, I end up using a Trigger on Client__c that basically just grabs all the Accounts when a Client is being modified in the batch (taking into account both inserts, upserts, and deletes):
SELECT Account__c.Id FROM Client__c WHERE Id =: Trigger.new OR Id =: Trigger.old
Then create a Set of all the Account Ids (in this example, named accounts), and run a query to retrieve ALL Clients related to those Ids (in a single query to ensure you don't hit SOQL limits).
SELECT Account__c.Id, Status__c FROM Client__c WHERE Account__c.Id =: accounts
From the results of this, you will iterate over all of the entries, tossing them into a Map keyed by the Account Id where the value is a List of Clients. When you are done, run a query to get all accounts based on the "accounts" list from earlier (which was just a list of strings, not actual Accounts), subsequently iterate over all the Clients associated with that Account, and if a Client is marked as Closed, you will update the metadata of that Account accordingly. If no Clients are closed, the Account will be marked as such. Once you are finished, run an update statement to update the list of Accounts that you have modified.