def simulator(model): """ -------------------------------------------------------------------------- template_simulator: integration options -------------------------------------------------------------------------- """ t_step_simulator = minutes/EPTimeStep # 10 min step # Choose options for the integrator opts = {"abstol":1e-10,"reltol":1e-10, "exact_jacobian":True, 'tf':t_step_simulator} # Choose integrator: for example 'cvodes' for ODEs or 'idas' for DAEs integration_tool = 'idas' # Choose the real value of the uncertain parameters that will be used # to perform the simulation of the system. They can be constant or time-varying def p_real_now(current_time): if current_time >= 0: p_real = NP.array([1.0]) else: p_real = NP.array([1.0]) return p_real # Choose the real value of the time-varing parameters def tv_p_real_now(current_time): current_time = current_time/(minutes/EPTimeStep) tv_p_real = disturbances[0,current_time] for i in range(1,7): tv_p_real = NP.append(tv_p_real, disturbances[i,current_time]) tv_p_real = NP.append(tv_p_real,0) tv_p_real = NP.append(tv_p_real,0) tv_p_real = NP.append(tv_p_real,0) return tv_p_real """ -------------------------------------------------------------------------- template_simulator: plotting options -------------------------------------------------------------------------- """ # Choose the indices of the states to plot plot_states = [0,1] # Choose the indices of the controls to plot plot_control = [2,4,5] # Plot animation (False or True) plot_anim = False # Export to matlab (for better plotting or postprocessing) export_to_matlab = False export_name = "mpc_result.mat" # Change this name if desired """ -------------------------------------------------------------------------- template_simulator: pass information (not necessary to edit) -------------------------------------------------------------------------- """ simulator_dict = {'integration_tool':integration_tool,'plot_states':plot_states, 'plot_control': plot_control,'plot_anim': plot_anim,'export_to_matlab': export_to_matlab,'export_name': export_name, 'p_real_now':p_real_now, 't_step_simulator': t_step_simulator, 'integrator_opts': opts, 'tv_p_real_now':tv_p_real_now} simulator_1 = core_do_mpc.simulator(model, simulator_dict) return simulator_1
def simulator(model): """ -------------------------------------------------------------------------- template_simulator: integration options -------------------------------------------------------------------------- """ # Choose the simulator time step t_step_simulator = 0.005 # Choose options for the integrator opts = {"abstol":1e-10,"reltol":1e-10, 'tf':t_step_simulator} # Choose integrator: for example 'cvodes' for ODEs or 'idas' for DAEs integration_tool = 'cvodes' # Choose the real value of the uncertain parameters that will be used # to perform the simulation of the system. They can be constant or time-varying def p_real_now(current_time): if current_time >= 0: p_real = NP.array([1.0,1.0]) else: p_real = NP.array([1.0,1.0]) return p_real # Choose the real value of the time-varing parameters def tv_p_real_now(current_time): tv_p_real = NP.array([1.0,1.0]) return tv_p_real """ -------------------------------------------------------------------------- template_simulator: plotting options -------------------------------------------------------------------------- """ # Choose the indices of the states to plot plot_states = [0,1,2] # Choose the indices of the controls to plot plot_control = [0, 1] # Plot animation (False or True) plot_anim = False # Export to matlab (for better plotting or postprocessing) export_to_matlab = True export_name = "mpc_result.mat" # Change this name if desired """ -------------------------------------------------------------------------- template_simulator: pass information (not necessary to edit) -------------------------------------------------------------------------- """ simulator_dict = {'integration_tool':integration_tool,'plot_states':plot_states, 'plot_control': plot_control,'plot_anim': plot_anim,'export_to_matlab': export_to_matlab,'export_name': export_name, 'p_real_now':p_real_now, 't_step_simulator': t_step_simulator, 'integrator_opts': opts, 'tv_p_real_now':tv_p_real_now} simulator_1 = core_do_mpc.simulator(model, simulator_dict) return simulator_1
def simulator(model): """ -------------------------------------------------------------------------- template_simulator: integration options -------------------------------------------------------------------------- """ # Choose the simulator time step t_step_simulator = 50.0/3600.0 # Choose options for the integrator opts = {"abstol":1e-10,"reltol":1e-10, 'tf':t_step_simulator} # Choose integrator: for example 'cvodes' for ODEs or 'idas' for DAEs integration_tool = 'cvodes' # Choose the real value of the uncertain parameters that will be used # to perform the simulation of the system. They can be constant or time-varying def p_real_now(current_time): if current_time >= 0: p_real = NP.array([950.0, 7.0]) else: p_real = NP.array([950.0, 7.0]) return p_real # Choose the real value of the time-varing parameters def tv_p_real_now(current_time): tv_p_real = NP.array([1.0,1.0]) return tv_p_real """ -------------------------------------------------------------------------- template_simulator: plotting options -------------------------------------------------------------------------- """ # Choose the indices of the states to plot plot_states = [3,9] # Choose the indices of the controls to plot plot_control = [0, 1,2] # Plot animation (False or True) plot_anim = False # Export to matlab (for better plotting or postprocessing) export_to_matlab = True export_name = "mpc_result.mat" # Change this name if desired """ -------------------------------------------------------------------------- template_simulator: pass information (not necessary to edit) -------------------------------------------------------------------------- """ simulator_dict = {'integration_tool':integration_tool,'plot_states':plot_states, 'plot_control': plot_control,'plot_anim': plot_anim,'export_to_matlab': export_to_matlab,'export_name': export_name, 'p_real_now':p_real_now, 't_step_simulator': t_step_simulator, 'integrator_opts': opts, 'tv_p_real_now':tv_p_real_now} simulator_1 = core_do_mpc.simulator(model, simulator_dict) return simulator_1
def simulator(model, zonenumber): """ -------------------------------------------------------------------------- template_simulator: integration options -------------------------------------------------------------------------- """ t_step_simulator = minutes / EPTimeStep # 10 min step # Choose options for the integrator opts = { "abstol": 1e-10, "reltol": 1e-10, "exact_jacobian": True, 'tf': t_step_simulator } # Choose integrator: for example 'cvodes' for ODEs or 'idas' for DAEs integration_tool = 'idas' # Choose the real value of the uncertain parameters that will be used # to perform the simulation of the system. They can be constant or time-varying def p_real_now(current_time): if current_time >= 0: p_real = NP.array([1.0]) else: p_real = NP.array([1.0]) return p_real # Choose the real value of the time-varing parameters def tv_p_real_now(current_time): current_time = current_time / (minutes / EPTimeStep) tv_p_real = disturbances[zonenumber, current_time] for i in range(len(zones_Heating), disturbances.shape[0]): tv_p_real = NP.append(tv_p_real, disturbances[i, current_time]) # dont care here about setp_ub/lb and u_AHU tv_p_real = NP.append(tv_p_real, 0) tv_p_real = NP.append(tv_p_real, 0) tv_p_real = NP.append(tv_p_real, 0) tv_p_real = NP.append(tv_p_real, 0) tv_p_real = NP.append(tv_p_real, 0) tv_p_real = NP.append(tv_p_real, 0) tv_p_real = NP.append(tv_p_real, 0) return tv_p_real """ -------------------------------------------------------------------------- template_simulator: plotting options -------------------------------------------------------------------------- """ # Choose the indices of the states to plot plot_states = [0] # Choose the indices of the controls to plot if model.name in eastSide: plot_tv_p = [-4] elif model.name in northSide: plot_tv_p = [-3] elif model.name in southSide: plot_tv_p = [-2] else: plot_tv_p = [-1] plot_control = [4, 5] # Plot animation (False or True) plot_anim = False # Export to matlab (for better plotting or postprocessing) export_to_matlab = False export_name = "mpc_result.mat" # Change this name if desired # saves all trajectories etc. save_simulation = True """ -------------------------------------------------------------------------- template_simulator: pass information (not necessary to edit) -------------------------------------------------------------------------- """ simulator_dict = { 'integration_tool': integration_tool, 'plot_states': plot_states, 'plot_tv_p': plot_tv_p, 'plot_control': plot_control, 'plot_anim': plot_anim, 'export_to_matlab': export_to_matlab, 'export_name': export_name, 'p_real_now': p_real_now, 't_step_simulator': t_step_simulator, 'integrator_opts': opts, 'tv_p_real_now': tv_p_real_now, 'save_simulation': save_simulation } simulator_1 = core_do_mpc.simulator(model, simulator_dict) return simulator_1