question

Leah R avatar image
0 Likes"
Leah R asked Leah R commented

How to browse through a global table ?

Hi everyone,

I want to import my Arrivals Source from Excel into my Flexsim model.

One constraint is that each patient uses specific staff resources. Thus, I need to transform the string “Surgeon1” from my Excel file to the pointer “/Surgeon1” in my Flexsim source.

I have thus decided to proceed as follow:

  1. Import the Excel file in a Global Table G1
  2. Build a table G2 where the string values related to staff are transformed into pointers thank to Model.find() and the rest is just copied and pasted.


For now, my code looks like that :

/**Custom Code*/

Object current = param(1); 
Object patient = current;
treenode activity = param(2);
Token token = param(3);
treenode processFlow = ownerobject(activity);

Table G1 = Table("ImportExcel");
Table G2 = Table("SourceFlexsim");

int nb_rows_max = G1.numRows;         
int nb_columns_max = G1.numCols;    


int index_col_G1 =1;
int index_row_G1 =1;


for (int index_col_G1 =1; index_col_G1 <= nb_columns_max; index_col_G1+=1);
{    
    for (int index_row_G1; index_row_G1 <=nb_rows_max; index_row_G1+=1);
    {
        G2[index_row_G1][index_col_G1] = G1[index_row_G1][index_col_G1];
    }
};


However, only the first cell G1[1][1] is being copied in G2. Could you help me find a solution?

Also, will the model.find() method work in your opinion ?


Thanks in advance,

Leah

FlexSim 21.1.1
global table
1619701136871.png (40.0 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Clair A avatar image
0 Likes"
Clair A answered Leah R commented

Hi Leah,

One easier way would be to get rid of surgeon names, and just use a number to identify which surgeon you want to pick.

In the attached example 2020-04-29 SurgeonID.fsm, there is a group of 2 surgeons:

In the schedule, I have added a numeric label named SurgeonID.

Here the first patient will meet with surgeon #2 and the second patient with surgeon #1:

To acquire the correct staff I use this statement:

This means I look in the group of surgeons at the rank of the surgeon ID. Note that SurgeonID #1 will match Surgeon1 if surgeons in the group are in the correct order.

With this method, the arrival schedule don't use pointer labels and I think that it will be easier to import the same table from Excel.


· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Leah R avatar image Leah R commented ·

Thank you, that's amazing ! I'm going to try that asap !

0 Likes 0 ·