Dependent Attributes possible?

49 views
Skip to first unread message

Markus Klug

unread,
Nov 13, 2022, 7:38:46 AM11/13/22
to Jaamsim Users Discussion Group
Dear all,

I have the following question:

In the model attached, I have added the following code in the "AttributeDefinitionList" of Queue1:

{ Dataset  'range(1, 1000)' }
{ SampleSize  size(this.Dataset) }
{ MeanDataset  sum(this.Dataset)/this.SampleSize }
{ VarianceDataSet  'sum(map(|x|((x-this.MeanDataset)^2/(this.SampleSize-1)), this.Dataset))' }

The attributes are depending on each other. After creation of the dataset, the further attributes can be calculated. Anyhow, they must be entered already line by line, every line being accepted for processing purpose within JaamSim to ensure, that the previous attribute exists before adding the next one.

When I store the file and load it later-on, the attributes are not considered. I get the following error:

*** INPUT ERROR *** Entity: Queue1, Keyword: AttributeDefinitionList - Could not find output 'Dataset' on entity 'Queue1'

Even when the attributes are still available (line 18) in the model source file, they are not loaded properly in the model any more.

Is there a possibility to have dependent attributes in a model?

Thanks in advance,
Markus
AttributeDefinitionList_Demo.cfg

Markus Klug

unread,
Nov 14, 2022, 2:57:09 AM11/14/22
to Jaamsim Users Discussion Group
Hi,

one additional remark. this also holds, if the attributes are defined in an object within a sub-model and the clones of this submodel are updated. The update needs to be done stepwise attribute by attribute.

Best regards,
Markus

Markus Klug

unread,
Nov 23, 2022, 8:36:50 AM11/23/22
to Jaamsim Users Discussion Group
Stupid me!!!

The documentation states clearly on page 77: "Do not reference any attributes, outputs, or custom outputs of any object in the InitValue expression." within the AttributeDefinitionList description. So, the mistake (bug) was sitting in front of the computer.

Solution: Define every attribute from scratch, which means instead of:

{ Dataset  'range(1, 1000)' }
{ SampleSize  size(this.Dataset) }
{ MeanDataset  sum(this.Dataset)/this.SampleSize }
{ VarianceDataSet  'sum(map(|x|((x-this.MeanDataset)^2/(this.SampleSize-1)), this.Dataset))' }

one gets everything by a small extension of the code:

{ Dataset  'range(1, 1000)' }
{ SampleSize  'DatasetLocal = range(1, 1000); size(DatasetLocal)' }
{ MeanDataset  'DatasetLocal = range(1, 1000); sum(DatasetLocal)/size(DatasetLocal)' }
{ VarianceDataSet  'DatasetLocal = range(1, 1000); averageDatasetLocal = sum(DatasetLocal)/size(DatasetLocal); sum(map(|x|((x-averageDatasetLocal)^2/(size(DatasetLocal)-1)), DatasetLocal))' }

Apologies for my stupid question!

Harry King

unread,
Nov 28, 2022, 8:38:56 PM11/28/22
to Jaamsim Users Discussion Group
Markus,

No need to apologize. This restriction is one I would like to lift at some point and you have just reminded me about it!

Harry

Reply all
Reply to author
Forward
0 new messages