Marcelle
Marcelle

Reputation: 11

Creating resources for ResourcePool with specific parameters throughout simulation Anylogic

I am modelling an inventory management system in Anylogic by means of Discrete Event Simulation.

Throughout the model, new resources are added according to a dataset in excel. I modelled this with a source block. In the source block, several parameters of the agent are added to the resource agent, which I need in the rest of my model (for instance purchase date, level of source activity etc.). I now want these agents to be added to my resource pool while keeping the parameters. However, since they are entering the model in a source block, I am not sure how to model/code this.

I tried to seize the sources after the enterblock, but this does not work. I also have tried to specificy the capacity of the ResourcePool with a variable 'varNumberResources', which is adjusted each time after a resource leaves the enterblock, however then the parameters are not added to the agent in the resourcePool.

Upvotes: 0

Views: 167

Answers (2)

Mr.Simon
Mr.Simon

Reputation: 1

There is a method that could achieve your goal. Do not create the rescource agents by source, create it by rescource pool block.

Step1:drage a null population whoose type is the rescources,create a int variable index=1 which is the row num in your datatable;

enter image description here

Step2:Set rescource pool,as the picture sghows choose "Add units to":custom population and set the "Population" you created in step1;In the "On new unit" action add the code below;

unit.set_Index(index);//set the index for the new rescources you created
index++;

enter image description here

Step3: write a function initional the rescource parament in the modle start up

for(Rescource r:rescources_pop)
{
    // select the parement by rescources index
    List< Tuple > r_info_list =
    selectFrom( rescources_table ).
    where( rescources_table.index.eq( r.index ) ).
    list();
    
    // set paraments
    Tuple tup=r_info_list.get(0);
    r.set_purchase_date(tup.get( rescources_table.purchase_date ));
}

Upvotes: 0

Felipe
Felipe

Reputation: 9431

you can't add custom resources to a resourcePool, so the only way you can do it is by using the set_capacity(n) method.

And you will then have to use "on new unit" from the actions of your resourcePool in order to define this new resource characteristics

Also you can't add resources using a source or an enter blocks. So don't do that. By setting the capacity of the resourcePool, the new resources will be added automatically to the model, but you will need to use the on new unit action to do anything with them

Upvotes: 0

Related Questions