sync sample package
Browse files
record_b1af9b72-1212-402e-bca1-f05ca247533e.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"optimization_code": "import cvxpy as cp\nimport numpy as np\n\ndef optimize_profile_tracking():\n demand = np.array([5.5, 5.2, 5.0, 5.4, 6.2, 6.8, 6.4, 5.8])\n renewable = np.array([1.0, 1.2, 1.8, 2.4, 1.7, 0.8, 0.3, 0.2])\n target_import = np.array([4.3, 4.0, 3.6, 3.4, 4.2, 5.0, 5.4, 5.0])\n n = len(demand)\n dt = 0.25\n\n energy_min, energy_max = 0.8, 7.2\n initial_energy = 4.4\n charge_max = discharge_max = 2.0\n eta_charge = eta_discharge = 0.90\n ramp_limit = 0.75\n tracking_penalty = 120.0\n throughput_cost = 0.8\n\n charge = cp.Variable(n, nonneg=True)\n discharge = cp.Variable(n, nonneg=True)\n energy = cp.Variable(n + 1)\n charging_mode = cp.Variable(n, boolean=True)\n deviation_above = cp.Variable(n, nonneg=True)\n deviation_below = cp.Variable(n, nonneg=True)\n\n battery_net_output = discharge - charge\n net_import = demand - renewable + charge - discharge\n constraints = [\n energy[0] == initial_energy,\n energy[n] == initial_energy,\n energy_min <= energy,\n energy <= energy_max,\n charge <= charge_max * charging_mode,\n discharge <= discharge_max * (1 - charging_mode),\n net_import - target_import == deviation_above - deviation_below,\n ]\n for t in range(n):\n constraints.append(\n energy[t + 1] == energy[t]\n + eta_charge * charge[t] * dt\n - discharge[t] * dt / eta_discharge\n )\n for t in range(1, n):\n constraints += [\n battery_net_output[t] - battery_net_output[t - 1] <= ramp_limit,\n battery_net_output[t - 1] - battery_net_output[t] <= ramp_limit,\n ]\n\n tracking_cost = tracking_penalty * dt * cp.sum(\n deviation_above + deviation_below\n )\n cycling_cost = throughput_cost * dt * cp.sum(charge + discharge)\n problem = cp.Problem(cp.Minimize(tracking_cost + cycling_cost), constraints)\n problem.solve(solver='SCIP')\n\n if problem.status not in (cp.OPTIMAL, cp.OPTIMAL_INACCURATE):\n raise RuntimeError(f'Optimization failed: {problem.status}')\n\n return {\n 'objective_usd': float(problem.value),\n 'net_import_mw': np.round(net_import.value, 3).tolist(),\n 'charge_mw': np.round(charge.value, 3).tolist(),\n 'discharge_mw': np.round(discharge.value, 3).tolist(),\n 'energy_mwh': np.round(energy.value, 3).tolist(),\n 'tracking_deviation_mw': np.round(\n deviation_above.value + deviation_below.value, 3\n ).tolist(),\n }\n\nif __name__ == '__main__':\n print(optimize_profile_tracking())",
|
| 3 |
+
"scheduling_problem": "Dispatch an 8 MWh flow battery in eight 15-minute intervals to track a requested site net-import profile. Site demand is [5.5, 5.2, 5.0, 5.4, 6.2, 6.8, 6.4, 5.8] MW, renewable generation is [1.0, 1.2, 1.8, 2.4, 1.7, 0.8, 0.3, 0.2] MW, and the target net import is [4.3, 4.0, 3.6, 3.4, 4.2, 5.0, 5.4, 5.0] MW. The battery starts and ends at 4.4 MWh, must remain between 0.8 and 7.2 MWh, and has 2 MW charge and discharge limits. Use 90% charging and discharging efficiencies. Limit the change in battery net output between adjacent intervals to 0.75 MW. Minimize absolute net-import tracking error weighted at 120 USD/MWh of deviation, plus a throughput cost of 0.8 USD/MWh. Use a 0.25-hour time step, permit net export if the schedule requires it, and prevent simultaneous charging and discharging. Implement the mixed-integer optimization in CVXPY with SCIP."
|
| 4 |
+
}
|
record_c50f070b-cb20-453f-8019-f256a2703b5c.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"optimization_code": "import cvxpy as cp\nimport numpy as np\n\ndef optimize_arbitrage():\n prices = np.array([34, 30, 28, 31, 45, 72, 88, 61], dtype=float)\n n = len(prices)\n dt = 1.0\n capacity = 12.0\n energy_min, energy_max = 1.2, 10.8\n initial_energy = 6.0\n charge_max = discharge_max = 3.0\n eta_charge = eta_discharge = 0.90\n throughput_cost = 1.5\n\n charge = cp.Variable(n, nonneg=True)\n discharge = cp.Variable(n, nonneg=True)\n energy = cp.Variable(n + 1)\n charging_mode = cp.Variable(n, boolean=True)\n\n constraints = [\n energy[0] == initial_energy,\n energy_min <= energy,\n energy <= energy_max,\n energy[n] >= 6.0,\n charge <= charge_max * charging_mode,\n discharge <= discharge_max * (1 - charging_mode),\n ]\n for t in range(n):\n constraints.append(\n energy[t + 1] == energy[t]\n + eta_charge * charge[t] * dt\n - discharge[t] * dt / eta_discharge\n )\n\n energy_cost = dt * cp.sum(cp.multiply(prices, charge - discharge))\n cycling_cost = throughput_cost * dt * cp.sum(charge + discharge)\n problem = cp.Problem(cp.Minimize(energy_cost + cycling_cost), constraints)\n problem.solve(solver='SCIP')\n\n if problem.status not in (cp.OPTIMAL, cp.OPTIMAL_INACCURATE):\n raise RuntimeError(f'Optimization failed: {problem.status}')\n\n return {\n 'objective_usd': float(problem.value),\n 'charge_mw': np.round(charge.value, 3).tolist(),\n 'discharge_mw': np.round(discharge.value, 3).tolist(),\n 'energy_mwh': np.round(energy.value, 3).tolist(),\n }\n\nif __name__ == '__main__':\n print(optimize_arbitrage())",
|
| 3 |
+
"scheduling_problem": "Optimize an eight-hour energy-arbitrage schedule for a vanadium flow battery using the hourly electricity prices [34, 30, 28, 31, 45, 72, 88, 61] USD/MWh. The battery has 12 MWh of usable capacity, must remain between 1.2 and 10.8 MWh, starts at 6 MWh, and must finish with at least 6 MWh. Limit charging and discharging to 3 MW each. Use a 1-hour time step, 90% charging efficiency, and 90% discharging efficiency. Prevent simultaneous charging and discharging. Minimize energy purchase cost minus discharge revenue, with a throughput cost of 1.5 USD/MWh charged or discharged. Implement the mixed-integer optimization in CVXPY using SCIP and return the dispatch and state-of-charge schedule."
|
| 4 |
+
}
|
record_d8619c25-57b7-4807-85c5-6c5499af5b0c.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"optimization_code": "import cvxpy as cp\nimport numpy as np\n\ndef optimize_peak_shaving():\n demand = np.array([4.0, 4.2, 4.5, 5.8, 6.2, 5.0], dtype=float)\n solar = np.array([0.5, 1.0, 2.5, 3.5, 2.0, 0.3], dtype=float)\n price = np.array([42, 38, 35, 76, 91, 55], dtype=float)\n n = len(demand)\n dt = 1.0\n\n energy_min, energy_max = 1.0, 9.0\n initial_energy = 5.0\n charge_max = discharge_max = 2.5\n eta_charge = eta_discharge = 0.90\n import_limit = 8.0\n demand_charge = 18.0\n throughput_cost = 1.0\n\n charge = cp.Variable(n, nonneg=True)\n discharge = cp.Variable(n, nonneg=True)\n energy = cp.Variable(n + 1)\n charging_mode = cp.Variable(n, boolean=True)\n curtailment = cp.Variable(n, nonneg=True)\n grid_import = cp.Variable(n, nonneg=True)\n peak_import = cp.Variable(nonneg=True)\n\n constraints = [\n energy[0] == initial_energy,\n energy[n] == initial_energy,\n energy_min <= energy,\n energy <= energy_max,\n charge <= charge_max * charging_mode,\n discharge <= discharge_max * (1 - charging_mode),\n curtailment <= solar,\n grid_import <= import_limit,\n grid_import <= peak_import,\n ]\n for t in range(n):\n constraints += [\n energy[t + 1] == energy[t]\n + eta_charge * charge[t] * dt\n - discharge[t] * dt / eta_discharge,\n grid_import[t] == demand[t] - solar[t] + curtailment[t]\n + charge[t] - discharge[t],\n ]\n\n energy_cost = dt * cp.sum(cp.multiply(price, grid_import))\n demand_cost = demand_charge * peak_import\n cycling_cost = throughput_cost * dt * cp.sum(charge + discharge)\n problem = cp.Problem(\n cp.Minimize(energy_cost + demand_cost + cycling_cost), constraints\n )\n problem.solve(solver='SCIP')\n\n if problem.status not in (cp.OPTIMAL, cp.OPTIMAL_INACCURATE):\n raise RuntimeError(f'Optimization failed: {problem.status}')\n\n return {\n 'total_cost_usd': float(problem.value),\n 'grid_import_mw': np.round(grid_import.value, 3).tolist(),\n 'solar_curtailment_mw': np.round(curtailment.value, 3).tolist(),\n 'charge_mw': np.round(charge.value, 3).tolist(),\n 'discharge_mw': np.round(discharge.value, 3).tolist(),\n 'energy_mwh': np.round(energy.value, 3).tolist(),\n 'peak_import_mw': float(peak_import.value),\n }\n\nif __name__ == '__main__':\n print(optimize_peak_shaving())",
|
| 3 |
+
"scheduling_problem": "Schedule a 10 MWh flow battery over six one-hour intervals to reduce electricity costs and the billing-period import peak at a site with demand [4.0, 4.2, 4.5, 5.8, 6.2, 5.0] MW and on-site solar output [0.5, 1.0, 2.5, 3.5, 2.0, 0.3] MW. The import tariff is [42, 38, 35, 76, 91, 55] USD/MWh, and the demand charge is 18 USD per MW of maximum grid import for this modeled period. The battery starts and ends at 5 MWh, has an allowed energy range of 1 to 9 MWh, and is limited to 2.5 MW charging and 2.5 MW discharging. Use 90% charging and discharging efficiencies, a 1-hour time step, and a cycling cost of 1 USD/MWh throughput. Allow solar curtailment, prohibit grid export, and prevent simultaneous charging and discharging. Minimize energy charges, demand charges, and cycling cost using CVXPY with SCIP."
|
| 4 |
+
}
|