Example #1
0
def run_optimization(sim_res, time, price, pv, bldg):
    """
    This function runs an optimization problem
    """

    from pyjmi.optimization.casadi_collocation import MeasurementData
    from collections import OrderedDict

    # get current directory
    curr_dir = os.path.dirname(os.path.abspath(__file__))

    # compile FMU
    path = os.path.join(curr_dir, "..", "Models", "ElectricalNetwork.mop")
    model_name = compile_fmux(
        'ElectricNetwork.NetworkBatteryMngmtOpt_Money',
        path,
        compiler_options={"enable_variable_scaling": True})

    # Load the model
    model_casadi = CasadiModel(model_name)

    # Get the inputs that should be eliminated from the optimization variables
    eliminated = OrderedDict()
    data_price = np.vstack([t_data, price])
    eliminated['price'] = data_price

    data_pv1 = np.vstack([t_data, np.squeeze(pv[:, 0])])
    eliminated['pv1'] = data_pv1
    data_pv2 = np.vstack([t_data, np.squeeze(pv[:, 1])])
    eliminated['pv2'] = data_pv2
    data_pv3 = np.vstack([t_data, np.squeeze(pv[:, 2])])
    eliminated['pv3'] = data_pv3

    data_bldg1 = np.vstack([t_data, np.squeeze(bldg[:, 0])])
    eliminated['bldg1'] = data_bldg1
    data_bldg2 = np.vstack([t_data, np.squeeze(bldg[:, 1])])
    eliminated['bldg2'] = data_bldg2
    data_bldg3 = np.vstack([t_data, np.squeeze(bldg[:, 2])])
    eliminated['bldg3'] = data_bldg3

    measurement_data = MeasurementData(eliminated=eliminated)

    # define the optimization problem
    opts = model_casadi.optimize_options()
    opts['n_e'] = 50
    opts['measurement_data'] = measurement_data
    opts['init_traj'] = sim_res.result_data

    # get the results of the optimization
    res = model_casadi.optimize(options=opts)

    plotCompare(sim_res, res)
Example #2
0
def run_optimization(sim_res,
                     stop_time=3600 * 24 * 6,
                     opt_problem='ElectricNetwork.OptimizationDistrict_E',
                     n_e=12):
    """
    This function runs an optimization problem
    """

    from pyjmi.optimization.casadi_collocation import MeasurementData
    from collections import OrderedDict

    # Get the weather data and other inputs for the building model
    time = np.linspace(0, stop_time, 36 * stop_time / 3600, True)
    (Tamb, Tgnd, sRadS, sRadN, sRadW, sRadE, ihg_1, ihg_2, ihg_3,
     price) = getData(time, plot=False)

    # get current directory
    curr_dir = os.path.dirname(os.path.abspath(__file__))

    # compile FMU
    path = os.path.join(curr_dir, "..", "Models", "ElectricalNetwork.mop")
    op_model = transfer_optimization_problem(
        opt_problem, path, compiler_options={"enable_variable_scaling": True})

    # Get the inputs that should be eliminated from the optimization variables
    eliminated = OrderedDict()

    data_ihg_1 = np.vstack([time, ihg_1])
    eliminated['ihg_1'] = data_ihg_1

    data_ihg_2 = np.vstack([time, ihg_2])
    eliminated['ihg_2'] = data_ihg_2

    data_ihg_3 = np.vstack([time, ihg_3])
    eliminated['ihg_3'] = data_ihg_3

    data_Tamb = np.vstack([time, Tamb])
    eliminated['Tamb'] = data_Tamb

    data_Tgnd = np.vstack([time, Tgnd])
    eliminated['Tgnd'] = data_Tgnd

    data_sRadE = np.vstack([time, sRadE])
    eliminated['solGlobFac_E'] = data_sRadE

    data_sRadN = np.vstack([time, sRadN])
    eliminated['solGlobFac_N'] = data_sRadN

    data_sRadS = np.vstack([time, sRadS])
    eliminated['solGlobFac_S'] = data_sRadS

    data_sRadW = np.vstack([time, sRadW])
    eliminated['solGlobFac_W'] = data_sRadW

    data_price = np.vstack([time, price])
    eliminated['price'] = data_price

    measurement_data = MeasurementData(eliminated=eliminated)

    # define the optimization problem
    opts = op_model.optimize_options()
    opts['n_e'] = n_e
    opts['measurement_data'] = measurement_data
    opts['init_traj'] = sim_res.result_data
    opts["IPOPT_options"]["max_iter"] = 10000

    # Get the results of the optimization
    res = op_model.optimize(options=opts)

    #plot_sim_res(res)

    return res
Example #3
0
def run_demo(with_plots=True):
    """
    This example demonstrates how to solve parameter estimation problmes.

    The data used in the example was recorded by Kristian Soltesz at the 
    Department of Automatic Control. 
    """

    curr_dir = os.path.dirname(os.path.abspath(__file__))

    # Load measurement data from file
    data = loadmat(curr_dir + '/files/qt_par_est_data.mat', appendmat=False)

    # Extract data series
    t_meas = data['t'][6000::100, 0] - 60
    y1_meas = data['y1_f'][6000::100, 0] / 100
    y2_meas = data['y2_f'][6000::100, 0] / 100
    y3_meas = data['y3_d'][6000::100, 0] / 100
    y4_meas = data['y4_d'][6000::100, 0] / 100
    u1 = data['u1_d'][6000::100, 0]
    u2 = data['u2_d'][6000::100, 0]

    # Plot measurements and inputs
    if with_plots:
        plt.figure(1)
        plt.clf()
        plt.subplot(2, 2, 1)
        plt.plot(t_meas, y3_meas)
        plt.title('x3')
        plt.grid()
        plt.subplot(2, 2, 2)
        plt.plot(t_meas, y4_meas)
        plt.title('x4')
        plt.grid()
        plt.subplot(2, 2, 3)
        plt.plot(t_meas, y1_meas)
        plt.title('x1')
        plt.xlabel('t[s]')
        plt.grid()
        plt.subplot(2, 2, 4)
        plt.plot(t_meas, y2_meas)
        plt.title('x2')
        plt.xlabel('t[s]')
        plt.grid()

        plt.figure(2)
        plt.clf()
        plt.subplot(2, 1, 1)
        plt.plot(t_meas, u1)
        plt.hold(True)
        plt.title('u1')
        plt.grid()
        plt.subplot(2, 1, 2)
        plt.plot(t_meas, u2)
        plt.title('u2')
        plt.xlabel('t[s]')
        plt.hold(True)
        plt.grid()

    # Build input trajectory matrix for use in simulation
    u = N.transpose(N.vstack((t_meas, u1, u2)))

    # compile FMU
    fmu_name = compile_fmu('QuadTankPack.Sim_QuadTank',
                           curr_dir + '/files/QuadTankPack.mop')

    # Load model
    model = load_fmu(fmu_name)

    # Simulate model response with nominal parameters
    res = model.simulate(input=(['u1', 'u2'], u), start_time=0., final_time=60)

    # Load simulation result
    x1_sim = res['qt.x1']
    x2_sim = res['qt.x2']
    x3_sim = res['qt.x3']
    x4_sim = res['qt.x4']
    t_sim = res['time']

    u1_sim = res['u1']
    u2_sim = res['u2']

    assert N.abs(res.final('qt.x1') - 0.05642485) < 1e-3
    assert N.abs(res.final('qt.x2') - 0.05510478) < 1e-3
    assert N.abs(res.final('qt.x3') - 0.02736532) < 1e-3
    assert N.abs(res.final('qt.x4') - 0.02789808) < 1e-3
    assert N.abs(res.final('u1') - 6.0) < 1e-3
    assert N.abs(res.final('u2') - 5.0) < 1e-3

    # Plot simulation result
    if with_plots:
        plt.figure(1)
        plt.subplot(2, 2, 1)
        plt.plot(t_sim, x3_sim)
        plt.subplot(2, 2, 2)
        plt.plot(t_sim, x4_sim)
        plt.subplot(2, 2, 3)
        plt.plot(t_sim, x1_sim)
        plt.subplot(2, 2, 4)
        plt.plot(t_sim, x2_sim)

        plt.figure(2)
        plt.subplot(2, 1, 1)
        plt.plot(t_sim, u1_sim, 'r')
        plt.subplot(2, 1, 2)
        plt.plot(t_sim, u2_sim, 'r')

    # Compile the Optimica model to an XML file
    model_name = compile_fmux("QuadTankPack.QuadTank_ParEstCasADi",
                              curr_dir + "/files/QuadTankPack.mop")

    # Load the model
    model_casadi = CasadiModel(model_name)
    """
    The collocation algorithm minimizes, if the parameter_estimation_data
    option is set, a quadrature approximation of the integral

    \int_{t_0}^{t_f} (y(t)-y^{meas}(t))^T Q (y(t)-y^{meas}(t)) dt

    The measurement data is given as a matrix where the first
    column is time and the following column contains data corresponding
    to the variable names given in the measured_variables list.

    Notice that input trajectories used in identification experiments
    are handled using the errors in variables method, i.e., deviations
    from the measured inputs are penalized in the cost function, rather
    than forcing the inputs to follow the measurement profile exactly.
    The weighting matrix Q may be used to express that inputs are typically
    more reliable than than measured outputs.
    """

    # Create measurement data
    Q = N.diag([1., 1., 10., 10.])
    data_x1 = N.vstack([t_meas, y1_meas])
    data_x2 = N.vstack([t_meas, y2_meas])
    data_u1 = N.vstack([t_meas, u1])
    data_u2 = N.vstack([t_meas, u2])
    unconstrained = OrderedDict()
    unconstrained['qt.x1'] = data_x1
    unconstrained['qt.x2'] = data_x2
    unconstrained['u1'] = data_u1
    unconstrained['u2'] = data_u2
    measurement_data = MeasurementData(Q=Q, unconstrained=unconstrained)

    opts = model_casadi.optimize_options()

    opts['n_e'] = 60

    opts['measurement_data'] = measurement_data

    res = model_casadi.optimize(algorithm="LocalDAECollocationAlg",
                                options=opts)

    # Load state profiles
    x1_opt = res["qt.x1"]
    x2_opt = res["qt.x2"]
    x3_opt = res["qt.x3"]
    x4_opt = res["qt.x4"]
    u1_opt = res["qt.u1"]
    u2_opt = res["qt.u2"]
    t_opt = res["time"]

    # Extract optimal values of parameters
    a1_opt = res.final("qt.a1")
    a2_opt = res.final("qt.a2")

    # Print and assert optimal parameter values
    print('a1: ' + str(a1_opt * 1e4) + 'cm^2')
    print('a2: ' + str(a2_opt * 1e4) + 'cm^2')
    a_ref = [0.02656702, 0.02713898]
    N.testing.assert_allclose(1e4 * N.array([a1_opt, a2_opt]),
                              [0.02656702, 0.02713898],
                              rtol=1e-4)

    # Plot
    if with_plots:
        plt.figure(1)
        plt.subplot(2, 2, 1)
        plt.plot(t_opt, x3_opt, 'k')
        plt.subplot(2, 2, 2)
        plt.plot(t_opt, x4_opt, 'k')
        plt.subplot(2, 2, 3)
        plt.plot(t_opt, x1_opt, 'k')
        plt.subplot(2, 2, 4)
        plt.plot(t_opt, x2_opt, 'k')

        plt.figure(2)
        plt.subplot(2, 1, 1)
        plt.plot(t_opt, u1_opt, 'k')
        plt.subplot(2, 1, 2)
        plt.plot(t_opt, u2_opt, 'k')
        plt.show()
def run_demo(with_plots=True):
    """
    Demonstrate how to solve a simple parameter estimation problem.
    """
    
    # Locate model file
    curr_dir = os.path.dirname(os.path.abspath(__file__));
    model_path = curr_dir + "/files/ParameterEstimation_1.mop"
    
    # Compile the model into an FMU and FMUX
    fmu = compile_fmu("ParEst.SecondOrder", model_path)
    fmux = compile_fmux("ParEst.ParEstCasADi", model_path)
    
    # Load the model
    sim_model = load_fmu(fmu)
    opt_model = CasadiModel(fmux)
    
    # Simulate model with nominal parameters
    sim_res = sim_model.simulate(final_time=10)
        
    # Extract nominal trajectories
    t_sim = sim_res['time']
    x1_sim = sim_res['x1']
    x2_sim = sim_res['x2']

    # Get measurement data with 1 Hz and add measurement noise
    sim_model = load_fmu(fmu)
    meas_res = sim_model.simulate(final_time=10, options={'ncp': 10})
    x1_meas = meas_res['x1']
    noise = [0.01463904, 0.0139424, 0.09834249, 0.0768069, 0.01971631, 
             -0.03827911, 0.05266659, -0.02608245, 0.05270525, 0.04717024,
             0.0779514]
    t_meas = N.linspace(0, 10, 11)
    y_meas = x1_meas + noise

    if with_plots:
        # Plot simulation
        plt.close(1)
        plt.figure(1)
        plt.subplot(2, 1, 1)
        plt.plot(t_sim, x1_sim)
        plt.grid()
        plt.plot(t_meas, y_meas, 'x')
        plt.ylabel('x1')
        
        plt.subplot(2, 1, 2)
        plt.plot(t_sim, x2_sim)
        plt.grid()
        plt.ylabel('x2')
        plt.show()
    
    # Create MeasurementData object
    Q = N.array([[1.]])
    unconstrained = OrderedDict()
    unconstrained['sys.y'] = N.vstack([t_meas, y_meas])
    measurement_data = MeasurementData(Q=Q, unconstrained=unconstrained)
    
    # Set optimization options
    opts = opt_model.optimize_options()
    opts['measurement_data'] = measurement_data
    opts['n_e'] = 16
    
    # Optimize
    opt_res = opt_model.optimize(options=opts)

    # Extract variable profiles
    x1_opt = opt_res['sys.x1']
    x2_opt = opt_res['sys.x2']
    w_opt = opt_res.final('sys.w')
    z_opt = opt_res.final('sys.z')
    t_opt = opt_res['time']
    
    # Assert results
    assert N.abs(opt_res.final('sys.x1') - 1.) < 1e-2
    assert N.abs(w_opt - 1.05)  < 1e-2
    assert N.abs(z_opt - 0.47)   < 1e-2
    
    # Plot optimization result
    if with_plots:
        plt.close(2)
        plt.figure(2)
        plt.subplot(2, 1, 1)
        plt.plot(t_opt, x1_opt, 'g')
        plt.plot(t_sim, x1_sim)
        plt.plot(t_meas, y_meas, 'x')
        plt.grid()
        plt.subplot(2, 1, 2)
        plt.plot(t_opt, x2_opt, 'g')
        plt.grid()
        plt.plot(t_sim, x2_sim)
        plt.show()
        
        print("** Optimal parameter values: **")
        print("w = %f" % w_opt)
        print("z = %f" % z_opt)
Example #5
0
def run_demo(with_plots=True):
    """
    This example demonstrates how to solve parameter estimation problmes.

    The data used in the example was recorded by Kristian Soltesz at the 
    Department of Automatic Control. 
    """
    # Load measurement data from file
    data_path = os.path.join(get_files_path(), "qt_par_est_data.mat")
    data = loadmat(data_path, appendmat=False)

    # Extract data series
    t_meas = data['t'][6000::100, 0] - 60
    y1_meas = data['y1_f'][6000::100, 0] / 100
    y2_meas = data['y2_f'][6000::100, 0] / 100
    y3_meas = data['y3_d'][6000::100, 0] / 100
    y4_meas = data['y4_d'][6000::100, 0] / 100
    u1 = data['u1_d'][6000::100, 0]
    u2 = data['u2_d'][6000::100, 0]

    # Plot measurements and inputs
    if with_plots:
        plt.close(1)
        plt.figure(1)
        plt.subplot(2, 2, 1)
        plt.plot(t_meas, y3_meas)
        plt.title('x3')
        plt.grid()
        plt.subplot(2, 2, 2)
        plt.plot(t_meas, y4_meas)
        plt.title('x4')
        plt.grid()
        plt.subplot(2, 2, 3)
        plt.plot(t_meas, y1_meas)
        plt.title('x1')
        plt.xlabel('t[s]')
        plt.grid()
        plt.subplot(2, 2, 4)
        plt.plot(t_meas, y2_meas)
        plt.title('x2')
        plt.xlabel('t[s]')
        plt.grid()

        plt.close(2)
        plt.figure(2)
        plt.subplot(2, 1, 1)
        plt.plot(t_meas, u1)
        plt.hold(True)
        plt.title('u1')
        plt.grid()
        plt.subplot(2, 1, 2)
        plt.plot(t_meas, u2)
        plt.title('u2')
        plt.xlabel('t[s]')
        plt.hold(True)
        plt.grid()

    # Build input trajectory matrix for use in simulation
    u = N.transpose(N.vstack([t_meas, u1, u2]))

    # Compile and load FMU
    model_path = os.path.join(get_files_path(), "QuadTankPack.mop")
    fmu_name = compile_fmu('QuadTankPack.Sim_QuadTank', model_path)
    model = load_fmu(fmu_name)

    # Simulate model response with nominal parameter values
    res = model.simulate(input=(['u1', 'u2'], u),
                         start_time=0.,
                         final_time=60.)

    # Load simulation result
    x1_sim = res['qt.x1']
    x2_sim = res['qt.x2']
    x3_sim = res['qt.x3']
    x4_sim = res['qt.x4']
    t_sim = res['time']
    u1_sim = res['u1']
    u2_sim = res['u2']

    # Check simulation results for testing purposes
    assert N.abs(res.final('qt.x1') - 0.05642485) < 1e-3
    assert N.abs(res.final('qt.x2') - 0.05510478) < 1e-3
    assert N.abs(res.final('qt.x3') - 0.02736532) < 1e-3
    assert N.abs(res.final('qt.x4') - 0.02789808) < 1e-3
    assert N.abs(res.final('u1') - 6.0) < 1e-3
    assert N.abs(res.final('u2') - 5.0) < 1e-3

    # Plot simulation result
    if with_plots:
        plt.figure(1)
        plt.subplot(2, 2, 1)
        plt.plot(t_sim, x3_sim)
        plt.subplot(2, 2, 2)
        plt.plot(t_sim, x4_sim)
        plt.subplot(2, 2, 3)
        plt.plot(t_sim, x1_sim)
        plt.subplot(2, 2, 4)
        plt.plot(t_sim, x2_sim)

        plt.figure(2)
        plt.subplot(2, 1, 1)
        plt.plot(t_sim, u1_sim, 'r')
        plt.subplot(2, 1, 2)
        plt.plot(t_sim, u2_sim, 'r')

    # Load optimization problem
    op = transfer_to_casadi_interface("QuadTankPack.QuadTank_ParEstCasADi",
                                      model_path)

    # Create measurement data object for optimization
    Q = N.diag([1., 1., 10., 10.])
    data_x1 = N.vstack([t_meas, y1_meas])
    data_x2 = N.vstack([t_meas, y2_meas])
    data_u1 = N.vstack([t_meas, u1])
    data_u2 = N.vstack([t_meas, u2])
    unconstrained = OrderedDict()
    unconstrained['qt.x1'] = data_x1
    unconstrained['qt.x2'] = data_x2
    unconstrained['u1'] = data_u1
    unconstrained['u2'] = data_u2
    measurement_data = MeasurementData(Q=Q, unconstrained=unconstrained)

    # Set optimization options and optimize
    opts = op.optimize_options()
    opts['n_e'] = 60
    opts['measurement_data'] = measurement_data
    opts['init_traj'] = res.result_data
    opts['nominal_traj'] = res.result_data
    res = op.optimize(options=opts)

    # Load state profiles
    x1_opt = res["qt.x1"]
    x2_opt = res["qt.x2"]
    x3_opt = res["qt.x3"]
    x4_opt = res["qt.x4"]
    u1_opt = res["qt.u1"]
    u2_opt = res["qt.u2"]
    t_opt = res["time"]

    # Extract estimated values of parameters
    a1_opt = res.final("qt.a1")
    a2_opt = res.final("qt.a2")

    # Print and assert estimated parameter values
    print('a1: ' + str(a1_opt * 1e4) + 'cm^2')
    print('a2: ' + str(a2_opt * 1e4) + 'cm^2')
    a_ref = [0.02656702, 0.02713898]
    N.testing.assert_allclose(1e4 * N.array([a1_opt, a2_opt]),
                              [0.02656702, 0.02713898],
                              rtol=1e-4)

    # Plot estimated trajectories
    if with_plots:
        plt.figure(1)
        plt.subplot(2, 2, 1)
        plt.plot(t_opt, x3_opt, 'k')
        plt.subplot(2, 2, 2)
        plt.plot(t_opt, x4_opt, 'k')
        plt.subplot(2, 2, 3)
        plt.plot(t_opt, x1_opt, 'k')
        plt.subplot(2, 2, 4)
        plt.plot(t_opt, x2_opt, 'k')

        plt.figure(2)
        plt.subplot(2, 1, 1)
        plt.plot(t_opt, u1_opt, 'k')
        plt.subplot(2, 1, 2)
        plt.plot(t_opt, u2_opt, 'k')
        plt.show()
Example #6
0
def run_optimization(sim_res,
                     opt_problem='ElectricNetwork.BuildingMngmtOpt_E',
                     use_battery=False,
                     fixpars=None,
                     n_e=24):
    """
    This function runs an optimization problem
    """

    from pyjmi.optimization.casadi_collocation import MeasurementData
    from collections import OrderedDict

    # Get the weather data for the building model
    time = np.linspace(0, 3600 * 24 * 6, 24 * 6 * 6, True)
    (Tamb, Tgnd, sRadS, sRadN, sRadW, sRadE, ihg, price) = getData(time,
                                                                   plot=False)
    P_batt = 0.0 * np.ones(len(time))

    # get current directory
    curr_dir = os.path.dirname(os.path.abspath(__file__))

    # compile FMU
    path = os.path.join(curr_dir, "..", "Models", "ElectricalNetwork.mop")
    op_model = transfer_optimization_problem(
        opt_problem, path, compiler_options={"enable_variable_scaling": True})

    # Change parameters depending on the case
    if fixpars:
        # Set the values for the parameters
        op_model.set(fixpars.keys(), fixpars.values())

    # Get the inputs that should be eliminated from the optimization variables
    eliminated = OrderedDict()

    data_ihg = np.vstack([time, ihg])
    eliminated['u[1]'] = data_ihg

    data_Tamb = np.vstack([time, Tamb])
    eliminated['u[2]'] = data_Tamb

    data_Tgnd = np.vstack([time, Tgnd])
    eliminated['u[3]'] = data_Tgnd

    data_sRadE = np.vstack([time, sRadE])
    eliminated['u[4]'] = data_sRadE

    data_sRadN = np.vstack([time, sRadN])
    eliminated['u[5]'] = data_sRadN

    data_sRadS = np.vstack([time, sRadS])
    eliminated['u[6]'] = data_sRadS

    data_sRadW = np.vstack([time, sRadW])
    eliminated['u[7]'] = data_sRadW

    data_price = np.vstack([time, price])
    eliminated['price'] = data_price

    if not use_battery:
        data_Pbatt = np.vstack([time, P_batt])
        eliminated['P_batt'] = data_Pbatt

    measurement_data = MeasurementData(eliminated=eliminated)

    # define the optimization problem
    opts = op_model.optimize_options()
    opts['n_e'] = n_e
    opts['measurement_data'] = measurement_data
    opts['init_traj'] = sim_res.result_data
    opts["IPOPT_options"]["max_iter"] = 10000

    # Get the results of the optimization
    res = op_model.optimize(options=opts)

    plot_sim_res(res)

    return res
def run_optimization(sim_res,
                     opt_problem='ElectricNetwork.BuildingMngmtOpt_E'):
    """
    This function runs an optimization problem
    """

    from pyjmi.optimization.casadi_collocation import MeasurementData
    from collections import OrderedDict

    # Get the weather data for the building model
    time = np.linspace(0, 3600 * 24 * 6, 24 * 6 * 6, True)
    (Tamb, Tgnd, sRadS, sRadN, sRadW, sRadE, ihg, price) = getData(time,
                                                                   plot=False)

    # get current directory
    curr_dir = os.path.dirname(os.path.abspath(__file__))

    # compile FMU
    path = os.path.join(curr_dir, "..", "Models", "ElectricalNetwork.mop")
    op_model = transfer_optimization_problem(
        opt_problem, path, compiler_options={"enable_variable_scaling": True})

    # Get the inputs that should be eliminated from the optimization variables
    eliminated = OrderedDict()

    data_ihg = np.vstack([time, ihg])
    eliminated['u[1]'] = data_ihg

    data_Tamb = np.vstack([time, Tamb])
    eliminated['u[2]'] = data_Tamb

    data_Tgnd = np.vstack([time, Tgnd])
    eliminated['u[3]'] = data_Tgnd

    data_sRadE = np.vstack([time, sRadE])
    eliminated['u[4]'] = data_sRadE

    data_sRadN = np.vstack([time, sRadN])
    eliminated['u[5]'] = data_sRadN

    data_sRadS = np.vstack([time, sRadS])
    eliminated['u[6]'] = data_sRadS

    data_sRadW = np.vstack([time, sRadW])
    eliminated['u[7]'] = data_sRadW

    data_price = np.vstack([time, price])
    eliminated['price'] = data_price

    measurement_data = MeasurementData(eliminated=eliminated)

    # define the optimization problem
    opts = op_model.optimize_options()
    opts['n_e'] = 60 * 6
    opts['measurement_data'] = measurement_data
    opts['init_traj'] = sim_res.result_data

    # Get the results of the optimization
    res = op_model.optimize(options=opts)

    plot_sim_res(res)

    return res