State variable values in observed time stages W/i/ and in previous time stages W/i−1/, and values of decision variable (Qd)/i/, as well as returns per various stages (Pel)/i/, are calculated in the course of the process. Optimal electric power of the (PV) generator, which is obtained as an output result, should meet the demands of the consumers throughout the whole observed period.