0% found this document useful (0 votes)
38 views

Homework #5 1.: Table 1: Training Cost Matrix For Each Task and Employee Combination

The document discusses three topics: 1. An integer linear programming problem to optimally assign tasks to employees based on a cost matrix. The optimal solution with a total cost of 12 is presented. 2. A dynamic programming approach using Bellman's equation to find the shortest path between nodes in a network. Code is shown to implement the algorithm. Shortest paths for sample destinations are presented. 3. An optimal power flow problem to minimize generation costs subject to flow and generator constraints. Python code implements the linear program and the optimal solution is displayed. Optimal pricing is also discussed.

Uploaded by

Malik Khaled
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Homework #5 1.: Table 1: Training Cost Matrix For Each Task and Employee Combination

The document discusses three topics: 1. An integer linear programming problem to optimally assign tasks to employees based on a cost matrix. The optimal solution with a total cost of 12 is presented. 2. A dynamic programming approach using Bellman's equation to find the shortest path between nodes in a network. Code is shown to implement the algorithm. Shortest paths for sample destinations are presented. 3. An optimal power flow problem to minimize generation costs subject to flow and generator constraints. Python code implements the linear program and the optimal solution is displayed. Optimal pricing is also discussed.

Uploaded by

Malik Khaled
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Homework #5

1.
Table 1: Training Cost Matrix for each task and employee combination

Task1 Task2 Task3 Task4


Emp1 3 7 11 8
Emp2 0 4 4 6
Emp3 0 4 10 9
Emp4 0 0 6 5

Linear program:
Objective function:
min(∑#!$% ∑#"$% c!" x!" )
Figure 1: CVXPY code for objective function

Constraints:
∑#!$% x!" >= 1, j = 1,2,3,4,5,6 ensuring each employee has at least one task assigned
∑#"$% x!" >= 1, i = 1,2,3,4,5,6 ensuring each task is assigned to at least one employee

Figure 2: CVXPY code for constraints

Table 2: Task Assignment Matrix Computed for given combination of Task and Employee

Task1 Task2 Task3 Task4


Emp1 1 0 1 0
Emp2 0 0 0 1
Emp3 0 1 0 0
Emp4 0 0 0 1

Total cost computed/ objective value = 12

Cost calculation matrix (CT*X) and sum of the matrix values is 12:

Figure 3: Cost calculation matrix computed

1
Homework #5

Figure 4: Python code for optimization

2
Homework #5

Figure 5: Solver output generated from code above

3
Homework #5

2. Dynamic programming principle using Bellman’s equation:


Given nodes and edges:
Table 3: Node Origin - Destination list for edges

Node Node Edge Distance


(Origin) (Destination)
1 2 1-2 4
1 3 1-3 5
1 4 1-4 4
2 3 2-3 1
2 4 2-4 -2
3 4 3-4 2
3 5 3-5 6
3 6 3-6 6
4 5 4-5 1
4 6 4-6 2
5 6 5-6 5

Determine:
Objective function:
d[j] = min{d[i] + c!" } ∶ (i, k) exitsts}

in case of node 1 above the value of i would be 1 and j would be {2,3,4,6}

Table 4: Algorithm to implement Bellman's equation (source: Optimization in Operations Research, Ronald L Rardin)

Step 0: Initialization: With S as source initialize optimal path lengths


0 if k = source
d# [𝑘] ← 9
+∞

Step 1: Evaluation: For each k evaluate


d[j] = min{d[i] + c!" } ∶ (i, k) exitsts}
Step 2: Stopping: Terminate if dt[k] = dt-1[k] for every k or if t = number of nodes in the graph
Step3: Advance: If some dt[k] changed and t < number of nodes, increment to t <- t+1 and return to Step1

Figure 6: Code block showing the implementation of above algorithm

4
Homework #5

Table 5: Implementation of dynamic programming algorithm above and shortest path for different destinations

Iteration Trace and shortest path to node 6 Iteration Trace and shortest path to node 5 Iteration Trace and shortest path to node 4

In the table above we can see that the all nodes in the given network are evaluated prior to determination
of shortest path between a given pair of origin and destination.

Observation & Feedback: This approach might be very useful for limited number of nodes but can be
computationally intensive and an overkill if we have to evaluate a larger set of nodes even though figuratively
nodes are very close but the good thing about this approach is that it evaluates every edge prior to determination
of all edges.

5
Homework #5

Figure 7: Full code for implementation of Bellman's equation

6
Homework #5

3.
a.
Objective: Minimize ∑Gi=1cipi∑i=1Gcipi
Subject to:
Flow Conservation:
∑j∈O(i)fij∑j∈O(i)fij - ∑j∈I(i)=pi∑j∈I(i)=pi for i∈G i∈G (for generator node)

∑j∈O(i)fij∑j∈O(i)fij - ∑j∈I(i)=−di∑j∈I(i)=−di for i∈Di∈D (for consumer node)

∑j∈O(i)fij∑j∈O(i)fij - ∑j∈I(i)=0∑j∈I(i)=0 for i∈N/(G∪D) i∈N/(G∪D)
(for node other than generators or consumer nodes, which does not exists in this problem)

Constraint linking branch flow and nodal potential


$ f_{ij} = B{ij}(𝜃{i} -𝜃{j}) for all (i,j)∈E(i,j)∈E

Flow Limit Constraint:


−Fij<=fij<=Fij
Generator Physical limit constraints:
pmin<=pi<=pmax for all i∈Gi∈G
where: The amount of generation of generator i as pi and the demand of consumer j as dj

7
Homework #5

b.

Figure 8: Python script to implement the above

8
Homework #5

Figure 9: Solver output

Optimal solution:

c.
Optimal pricing:

You might also like