Page 697 - ExtendSim User Guide

P. 697

```
The explanation for how this equation is structured is as follows:
EndTime is a global variable representing the end time of the run, in this case 480 minutes. DeliveryTimes is how frequently the deliveries are repeated, or every 240 minutes. If you were to divide the endTime value of 480 by the deliveryTimes value of 240, it would result in 2 deliveries a day, which appears correct. However, if you instead divide by 250, you get only 1.92 deliveries, even though you still have 2 deliveries, one at the beginning of the day and one at 250 minutes. There will always be a delivery at the beginning of the day, so you need to add 1 to deliveryTimes and truncate any fractional result with the int() function. This results in 2.92, which when truncated gives 2, the correct answer.
If you had a delivery every 480 minutes, there would be 2 deliveries, but the last one would happen at the same time as the stand closes. To remedy this, reduce the endTime by 1, prevent- ing the 480 minute case (the maximum limit) from causing 2 deliveries.
The entire objective function can now be entered in the Optimizer block’s Objectives tab:
Delete the default equation from the Equation pane.
Define a new variable for the number of deliveries by entering it in the Equation pane (don’t forget the semicolons that are needed to end the statement):
Integer numDeliveries;
Below that variable definition, enter the equation that converts deliveryTimes into numDe- liveries:
numDeliveries = int((endTime-1)/deliveryTimes + 1);
Below the conversion equation, enter the cost equation:
MaxProfit = 2.50*numSold - numDeliveries*(1000.0+delTankSize*1.00)
- emptyTime*100;
The variable definition and the two equations are the objective function for the Optimizer.
Analysis 671
Optimization
How To
```