Hello, Plant Simulation Community.
I'am having trouble with showing a variable in my model that shows the parameter I want to optimize with GA.
Attached is the model. The method "EndSim" calculates the "Total_Delay" which I want to be shown on the variable (just like the TotalSetupTimes).
I was able to show this variable on a table, but I can't use it as an optimizer parameter.
Does anyone have a suggestion for this ?
Solved! Go to Solution.
I think there are several problems here.
1) You have Total_Delay variable object in the frame. However you declare a variable with the same name in EndSim method - it is used in calculations. It means that root.Total_Delay never gets any value. Just delete this line from EndSim:
2) With GA you should use ONE value for the fitness function. If you want to consider two variables, you can combine them with weight factors in the table (or with user method), e.g.:
Fitness = Var1*1 + Var2*0.5
You cannot see two variables separately in resulting function.
3) Fitness function should never get negative values. That is important in your case and also in the case if you use negative weights, e.g.
Fitness = Revenue * 1 + Costs * (-1)
4) In your model delays for each order can be positive and negative. It means that if order_1 has delay=+1 hour and order_2 had delay=-1 hour, total delay is zero (and GA treats it as optimum value). One possible solution is to use absolute values of delay. For example, in your case:
obj["Delay",1] := abs (obj["Due_Date",1]- obj["Finish",1]);
This also makes total delay positive.
Also it make sense to use "for" cycle in EndSim to make your code shorter:
For local ln := 1 to obj.YDim loop
obj["Delay",ln] := abs (obj["Due_Date",ln]- obj["Finish",ln]);
Thanks a lot for the considerations. You actually answered doubts of mine I hadn't commented.
- The module for Delay calculation makes much more sense when optimizing the system.
- Shortening the code: thanks !
- The variable is now showing the results for delay;
I will now try to apply the GA taking into account your suggestions.