To enable optimization, you must ensure that each simulation ends. By default, a simulation never ends; therefore the optimization engine gets no samples of the objective function. To ensure that each simulation ends, you must specify a simulation stop condition.
Note that a simulation may involve several replications. A sample of the objective function is the result of a simulation/iteration rather than a replication.
In general, a simulation stop condition should be specified in such a way that the value of the objective function is significant when simulation stops. The model should be stable, transient processes should be finished, and statistics should be representative.
The most common and simple simulation stop conditions is stopping at the specified model time.
How-To video: Optimization experiment