├── data ├── README.md └── code1 /data: -------------------------------------------------------------------------------- 1 | | Plant | Max Capacity (MW) | Revenue per MW (\$) | 2 | | --------------- | ----------------: | ------------------: | 3 | | Solar\_Farm\_1 | 50 | 70 | 4 | | Wind\_Plant\_1 | 60 | 90 | 5 | | Hydro\_Plant\_1 | 40 | 60 | 6 | | Solar\_Farm\_2 | 30 | 65 | 7 | | Wind\_Plant\_2 | 20 | 80 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ⚡ Resource Allocation Optimization 2 | 3 | This project demonstrates how to solve a **resource allocation optimization problem** using Python and linear programming (via the `PuLP` library). The scenario focuses on allocating a limited amount of power (in megawatts) across various renewable energy plants to **maximize total revenue**. 4 | 5 | ## 📈 Problem Statement 6 | 7 | We are given a set of renewable energy plants with: 8 | - Maximum power generation capacities 9 | - Revenue earned per MW of power produced 10 | 11 | Given a fixed amount of total power (100 MW), we want to allocate power to these plants such that: 12 | 1. No plant exceeds its generation capacity. 13 | 2. Total power used does not exceed the available 100 MW. 14 | 3. Revenue is maximized. 15 | 16 | ## 🔢 Data 17 | 18 | | Plant | Max Capacity (MW) | Revenue per MW ($) | 19 | |---------------|------------------:|--------------------:| 20 | | Solar_Farm_1 | 50 | 70 | 21 | | Wind_Plant_1 | 60 | 90 | 22 | | Hydro_Plant_1 | 40 | 60 | 23 | | Solar_Farm_2 | 30 | 65 | 24 | | Wind_Plant_2 | 20 | 80 | 25 | 26 | - **Total Available Power**: 100 MW 27 | 28 | ## 🧠 Objective Function 29 | 30 | Maximize: 31 | 32 | -------------------------------------------------------------------------------- /code1: -------------------------------------------------------------------------------- 1 | # Install PuLP if not already installed: 2 | # pip install pulp 3 | 4 | from pulp import LpMaximize, LpProblem, LpVariable, lpSum 5 | 6 | # Example: Allocate resources to 3 projects with resource constraints 7 | 8 | # Projects 9 | projects = ["Project_A", "Project_B", "Project_C"] 10 | 11 | # Profit per unit resource allocated to each project 12 | profit = {"Project_A": 30, "Project_B": 20, "Project_C": 40} 13 | 14 | # Max resource allowed per project 15 | max_resource = {"Project_A": 30, "Project_B": 40, "Project_C": 20} 16 | 17 | # Total available resources 18 | total_resources = 60 19 | 20 | # Define the LP problem 21 | model = LpProblem("Resource-Allocation", LpMaximize) 22 | 23 | # Define variables 24 | resource_alloc = {p: LpVariable(f"alloc_{p}", lowBound=0, upBound=max_resource[p]) for p in projects} 25 | 26 | # Objective: Maximize total profit 27 | model += lpSum(profit[p] * resource_alloc[p] for p in projects), "Total_Profit" 28 | 29 | # Constraint: Do not exceed total available resources 30 | model += lpSum(resource_alloc[p] for p in projects) <= total_resources, "Resource_Limit" 31 | 32 | # Solve the model 33 | model.solve() 34 | 35 | # Output results 36 | print("Status:", model.status) 37 | for p in projects: 38 | print(f"Allocate to {p}: {resource_alloc[p].varValue} units") 39 | print("Total Profit:", model.objective.value()) 40 | --------------------------------------------------------------------------------