The main purpose of this example is to show how the cumulative value of a reward defined for an object can be modified by the execution of an action. The main function to accomplish this is called set_cr . We can also obtain the current value of the amount of reward accumulated using the get_cr function. Note: these functions can be used only in simulation.
The model is shown in Figure . In that figure, a source sends packets to a finite exponential queue. The behavior of the source is described in Figure . While in state where the variable state is equal to zero, the source generates packets at an exponential rate. From Figure , the state variable status can only change its value when the elapsed time since the last change is at least 10. This elapsed time is stored in the reward elapsed_time.
The description of the Server_Queue object is shown in Figure .
NOTE: get_cr gets the total value of the corresponding rate reward accumulated so far, and set_cr sets the cumulative rate reward value. We can use get_ir to get the total value of the corresponding impulse reward accumulated so far and set_ir to set the impulse reward cumulative value. Again, these functions can be used only in simulation.
: If you need some information about the value of any variable during simulation you can use set_cr to generate a trace containing the values.
Imagine you want to know the values assumed by the queue during simulation. Suppose this state var is called QUEUE. How to do it step by step:
rate_reward = NAME_RELATED condition=(FALSE) value=0;This reward will not accumulate by itself. Instead, you need to specify its value with the set_cr command.
(1) var_float = get_simul_time(); (2) if (get_simul_time () > var_time) { do_something; }
printf ("Debug message1: %d %f \n", int_var, float_var);
fprintf (stderr, "Debug message2: %d %f \n", int_var, float_var); fprintf (stdout, "Debug message3: %d %f \n", int_var, float_var);
Guilherme Dutra Gonzaga Jaime 2010-10-27