question

Steven Chen avatar image
0 Likes"
Steven Chen asked Steven Chen commented

Error in Financial Analysis

Hello,

In my model, I attempt to perform a financial analysis (Financial Analysis of Machines) on the profitability of different numbers of machines. For this purpose, I created a financial analysis chart and a parameter table. The chart financially analyses machines collected from the value set in the table.

An error occurred in the chart of the financial analysis. The value in the table (pictured) sets to be 3, whereas nothing changes in the chart according to dependency.
1648793051747.png

Conversely, it is not the case in the "Utilisation Analysis of Machines" state chart. A correspondence between this chart and the table is visible.

More details about the model are obtainable in the attached file.

Thank you for your time and review


Financial Analysis Model.fsm


FlexSim 22.0.1
parameters tablefinancial analysis
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

·
Jordan Johnson avatar image
0 Likes"
Jordan Johnson answered Steven Chen commented

This seems like something we could improve. I'll add an issue to the dev list about it.

As a workaround, you can change the OnSet code of the parameter to add the new objects:

treenode reference = param(1);
Variant newValue = param(2);
Variant oldValue = param(3);
int isReset = param(4);

{ // ************* PickOption Start ************* //
/***popup:ParamSetNodeValue*/
/**Delete and Copy Group Members*/
if (/***tag:condition*//**/isReset/**/) {
    Array objects = reference.as(Group).toFlatArray();
    
    if (objects.length == 0) {
        mpt("Error setting parameter " + c.up.up.name + " - Not enough objects in object set"); mpr();
    } else {
        for (int i = 2; i <= objects.length; i++) {
            objects[i].destroy();
        }
        
        treenode firstObj = objects[1];
        int total = Math.max(1, newValue);
        for (int i = 2; i <= total; i++) {
            treenode newObj = createcopy(firstObj, firstObj.up);
            newObj.name = firstObj.name + "_" + i;
            applicationcommand("recreateObjectConnections", newObj, firstObj);
            
            treenode oldStored = stored(firstObj);
            treenode newStored = stored(newObj);
            for (int i = 1; i <= content(oldStored); i++) {
                treenode linkedObj = rank(oldStored, i).find("+/~");
                if (linkedObj && isclasstype(linkedObj, "StatisticObject") && !isclasstype(linkedObj, "GenericChart")) {
                    function_s(linkedObj, "addMember", newObj);
                }
            }
        }
    }
}

} // ******* PickOption End ******* //

Most of the code is the same. The new code is found beneath the call the "recreateObjectConnections". The basic idea is to check the stored node of the original object, and if it's linked to a Statistics Object that isn't a Generic Chart, then call its addMember function, adding the new object.

· 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.

Steven Chen avatar image Steven Chen commented ·

Hi Jordan,

Thank you for your insightful explanation and correction to the code, with the problem in the chart solved.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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