MPC Control In Building
Domain: engineering — Energy, Power & Nuclear Engineering

Summary: Develop and evaluate baseline, energy-saving MPC, and demand-response MPC cooling control for a single-family EnergyPlus house model.

Task prompt:
You are a building-controls engineer developing model predictive control (MPC)
for a single-family house cooling system.

## Input

Use the task input directory `base/input`. It contains:

- `SFH.idf`: the EnergyPlus 22.1.0 building model.
- `Denver_current_TMY.epw`: the weather file.
- `task_spec.json`: deterministic controller, tariff, reporting, and output-contract details.
- `runtime_env/pyproject.toml`: Python dependencies useful for MPC, RC-model fitting, and reporting.

You must use the provided IDF and EPW. Do not substitute a different building,
weather year, timestep, or tariff.

EnergyPlus 22.1.0 is pre-installed on the VM. See
`base/software/README.md` for the absolute binary path and a
sample invocation. Use the `-x` flag to run ExpandObjects automatically
(the IDF contains HVACTemplate objects).

## Task

Build and evaluate an MPC controller using EnergyPlus as the virtual testbed.

1. Run a deterministic baseline on-off HVAC controller from July 1 through
   July 28 at 15-minute intervals. Use occupied cooling setpoint 24 C, 2 C
   unoccupied setback, 0.5 C deadband, flow states 0.0/0.1/0.3 kg/s, supply
   air temperature 13 C, COP 3.0, and the occupancy schedule randomized with
   seed 142857.
2. Train a 3R2C thermal model from the simulated data.
3. Build two MPC policies: one for energy-cost saving and one for demand
   response / on-peak load reduction.
4. Deploy both MPC policies against EnergyPlus or an equivalent closed-loop
   EnergyPlus-generated co-simulation trace.
5. Report July 28 performance: cooling energy, electric energy, tariff cost,
   peak cooling load, peak-period average load, comfort degree-hours, load
   shifting behavior, and RC-model calibration quality.

The time-of-use tariff is:

- 0.06 USD/kWh during 00:00-11:59 and 20:00-23:59.
- 0.12 USD/kWh during 12:00-16:59.
- 0.25 USD/kWh during 17:00-19:59.

## Required Output

Write these artifacts under `base/output`:

1. `baseline_data.csv`: 15-minute baseline time series for July 1-July 28.
2. `mpc_energy_saving_data.csv`: 15-minute closed-loop time series for the
   energy-saving MPC.
3. `mpc_demand_response_data.csv`: 15-minute closed-loop time series for the
   demand-response MPC.
4. `mpc_actions_energy_saving.csv`: July 28 MPC actions for energy saving.
5. `mpc_actions_demand_response.csv`: July 28 MPC actions for demand response.
6. `rc_log_energy_saving.json`: fitted RC-model diagnostics.
7. `rc_log_demand_response.json`: fitted RC-model diagnostics.
8. `metrics_comparison.csv`: rows named `baseline`, `mpc_energy_saving`, and
   `mpc_demand_response`, with columns `cooling_kwh`, `elec_kwh`, `cost_usd`,
   `peak_load_kw`, `peak_hour_avg_kw`, and `discomfort_dh`.
9. `results_summary.json`: concise narrative and machine-readable summary of
   baseline, MPC, savings, and RC calibration.

The data CSVs must include at least these columns: `hour`, `cooling_w`,
`t_zone`, and `setpoint`. They should also include outdoor temperature, solar,
occupancy, and controller/action fields where available.


Required actions:

Software: EnergyPlus 22.1.0
Python
uv
pandas
numpy
scipy
cvxpy

Input files: