<jupyter_start><jupyter_text>Minimal Example Numerical Unit Commitment OptimizationThe energy system modeled in this notebook consists of three units used to cover an electric load. Only one timestep (i.e. load) isconsidered. The units are described by a minimal power, a maximum power and linear production cost.<jupyter_code># Import of the library PuLP

from pulp import LpProblem, LpMinimize, LpVariable, LpInteger, LpStatus, value

# Problem definition
prob = LpProblem("Unit Commitment Sandbox Problem",LpMinimize)

# Definition of decision variables and their bounds
P1=LpVariable("P1", 0, 100)
P2=LpVariable("P2", 0, 400)
P3=LpVariable("P3", 0, 1000)

z1 = LpVariable("z1", 0, 1, LpInteger)
z2 = LpVariable("z2", 0, 1, LpInteger)
z3 = LpVariable("z3", 0, 1, LpInteger)

# Defintion of objective function that is to be minimized (cost function)
prob += 60*P1 + 25*P2 + 35*P3 + 7.9*P1 + 7.85*P2 + 9.56*P3, "Linear Production Cost"

# Minimum Power Constraints
prob += P1 >= z1*250, "Min Power Block 1"
prob += P2 >= z2*200, "Min Power Block 2"
prob += P3 >= z3*150, "Min Power Block 3"

# Maximum power constraints
prob += P1 <= z1*100, "Max Power Block 1"
prob += P2 <= z2*400, "Max Power Block 2"
prob += P3 <= z3*1000, "Max Power Block 3"

# Constraint that the sum of production must be the load (here 500 MW)
prob += P1 + P2 + P3 == 500, "Load constraint"

# Print what we have defined
print(prob)
# Solve the problem
prob.solve()

print("Solution status:", LpStatus[prob.status], "\n")

# Go through the variables and print name and solution value
for v in prob.variables():
    print(v.name, '=', v.varValue)
    
print(f'\nOBJECTIVE VALUE\n{prob.objective.value():.0f} EUR')<jupyter_output>Solution status: Optimal 

P1 = 0.0
P2 = 350.0
P3 = 150.0
z1 = 0.0
z2 = 1.0
z3 = 1.0

OBJECTIVE VALUE
18182 EUR
{'fraction_non_alphanumeric': 0.12121212121212122, 'fraction_numerical': 0.06887052341597796, 'mean_word_length': 4.587692307692308, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '118070', 'license': 'MIT', 'n_tokens_mistral': 728, 'n_tokens_neox': 640, 'n_words': 235, 'path': '3_minimal_example_optimization_solution.ipynb', 'repo_name': 'pdubucq/steamturbines', 'size': '1815'}