I want to know how to write the algorithm into the child node

I want to know how to write the algorithm into the child node

a9080109
Explorer Explorer
37 Views
21 Replies
Message 1 of 22

I want to know how to write the algorithm into the child node

a9080109
Explorer
Explorer

[ FlexSim 22.0.16 ]

When I was reading some documents, I found a very powerful function. He wrote the ga algorithm into the child node. I want to know how to do it. Is there a simple type for reference? Like this

1685346412891.png

0 Likes
Accepted solutions (1)
38 Views
21 Replies
Replies (21)
Message 2 of 22

moehlmann_fe
Explorer
Explorer
Accepted solution

Add a new node to the tree (either through the rightclick menu of the previous or parent node or by using the shortcuts).

Set that node to contain text data (Rightclick -> Node -> Add Text Data). Then toggle the node as FlexScript (Rightclick -> Build -> Toggle Node as FlexScript)

You can then run the code in multiple ways.

treenode code = ...;
// Run the code now
code.evaluate(param1, param2, ...); nodefunction(code, param1, param2, ...); // Run the code at a later time delayednodefunction(code, param1, param2,);
Message 3 of 22

arunTTT2P
Explorer
Explorer

Adding on to Felix's answer you can also read the tree properties.

Message 4 of 22

a9080109
Explorer
Explorer

@Arun Kr @Felix Möhlmann

What I want to know is a case, and if possible, I hope to provide an example for me to learn, but I currently understand how to add data to the tree nodes, (and the algorithm inside is generated by gpt. If there is a better method, I hope can be provided), if not, you can use this algorithm first (but it cannot be executed smoothly at present)gpt1.fsm

0 Likes
Message 6 of 22

a9080109
Explorer
Explorer

@Kris Geisberger I am very interested in the content of your attachment. Can you please attach the file? I can't open the previous fileGA scheduling example (1).zipGA scheduling example (1).fsm




0 Likes
Message 7 of 22

a9080109
Explorer
Explorer

@Felix Möhlmann @Arun Kr Or the two have related files that can be attached

0 Likes
Message 8 of 22

ralf_gruber
Collaborator
Collaborator
Mark,

Post #6 in that same thread in the old forum contains the plain model. I does not help you though, because it was created in FlexSim version 4.5. It does not seamlessly upgrade to the current version of FlexSim.

You will have to have 4.5 installed along with the matching Visual Studio version to compile the model....FlexSim has come a long way since 🙂

Good luck


0 Likes
Message 9 of 22

a9080109
Explorer
Explorer

But I really want to know the details inside, so I want to ask if there is a similar way to achieve

0 Likes
Message 10 of 22

jason_lightfootVL7B4
Autodesk
Autodesk

If you have some algorithm you haven't written and want to try it -just put it in a user command and then you can reference it from anywhere you like rather than having to know the path to a specific node you need to execute. Or if it's in C then, still via a user command, put the code in a dll and link the user command to that. All of this information is in the documentation and we strongly encourage you to read through it to find these answers.

We provide methods of access to off the shelf optimizers - Optquest and via Python - so while you may have a student project to create an optimizer (many of which, and particularly GAs, are well documented elsewhere) your questions here should regard the architecture and environment of FlexSim, not the content of such an algorithm.

0 Likes
Message 11 of 22

a9080109
Explorer
Explorer

I don't quite understand the meaning of this sentence

If you have some algorithm you haven't written and want to try it -just put it in a user command and then you can reference it from anywhere you like rather than having to know the path to a specific node you need to execute.

0 Likes
Message 12 of 22

jason_lightfootVL7B4
Autodesk
Autodesk
With a user command - you just write this when you want to execute it:
myAlgorithm(<param1>,<param2>......)

plus you will specify the passed parameters which will prompt the user/you as you type.

Whereas having it on a node means you need to find the node and then execute it and you'll get no prompts for parameters and their types or context help.


0 Likes
Message 13 of 22

julie_weller
Not applicable

Hi @mark zhen , was Felix Möhlmann's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always comment back to reopen your question.

0 Likes
Message 14 of 22

a9080109
Explorer
Explorer

@Felix Möhlmann The thing I want to know now is that I can use the tree nodes to manipulate e.g. the processing time of the machine (I know I can set it directly but I want to understand how to write it in an easy way)

0 Likes
Message 15 of 22

joerg_vogel_HsH
Mentor
Mentor
@mark zhen , a processing time is a function. It executes a script to return exactly a single value for events to the FlexSim engine each time this function gets called.

You can parse values into this function, which gets returned.
Typically you can parse them by

  • label,
  • table cell,
  • pulled list value,
  • parameter,
  • calling a user command, which returns a number value,
  • evaluating a number treenode,
  • calling a treenode function returning itself a number,
  • calling a Process Flow sub process returning a number value,

I think you get an idea, that you can parse number values by already scripted code into this function. But you cannot write automatically generated source code to replace the function while a model runs at this node for process time.
You can try to evaluate a string that you compose in a node that itself returns a number. You call this string for evaluating it in such a Process Time function. But it must be a valid script code. And it is not allowed to delay this return value by waiting for an external event.

0 Likes
Message 16 of 22

jason_lightfootVL7B4
Autodesk
Autodesk

You shouldn't be writing to the treenodes directly - you should be using object.setProperty("ProcessTime"). That way template changes will propogate correctly to instances that inherit from the template.

You could also fix the processing time to read from a label and then just change the label value.

Message 17 of 22

a9080109
Explorer
Explorer

1687065758820.png

I have an idea now. For example, I have three different products, and I give different setting times respectively. Ex type1 is 10, type 2 is 20, and type 3 is 30. The logic I want is this. If my processing time is the previous time plus on this time

@mark zhen @Felix Möhlmann @Joerg Vogel @Jason Lightfoot

0 Likes
Message 18 of 22

jason_lightfootVL7B4
Autodesk
Autodesk
Are you trying to describe a setup time based on type? It's not clear from your sentence.
Message 19 of 22

a9080109
Explorer
Explorer

My initial thought was to use these syntaxes to change , but I don't quite know how to implement1687070681970.png

0 Likes
Message 20 of 22

jason_lightfootVL7B4
Autodesk
Autodesk
Is the template code (in gray) confusing you? If so hide it - this is very simple code.
0 Likes