Project No. 1 Omar Hopkins

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 23

Project No.

1
Omar Hopkins

OR 210 - Models in Operations Research


Dr Dong Shaw
Fall 1999

Project 1

Introduction
The Matlab code used to solve the following problems is included in the appendix. Note that the
code for each program (function) was written for the specific program and their respective initial conditions.
The code is not written to solve the generalized problem type.
With respect to writing a macro that would allow a single push button solution of optimization
problem I have not been successful. The problem appears to come from one of the following area,

The macro recorder is not recognizing the Matlab functions. Although it appears that all
the relevant files have been loaded it may be that Excel has not fully loaded all the macro
references. I followed the instructions given by Matlab, but without success. I have also
tried to program the macro directly from within Visual Basic but have also not had any
success.

I will continue to see if I can identify a solution to this problem. Theoretically, it seems to be
possible - however the implementation is, as yet, somewhat problematic.

General Comments on Matrix Structure


These problems where typically structured as (highly) sparse matrices. Because these problems
were fairly modest in scope regular matrix commands were used. However, in the event of significantly
larger problems more attention to the use of sparse matrix format is recommended. The Matlab commands
are essentially the same.
Many of the problems that follow required the creation of additional variables - dummy variables.
These were used as counters or other similar function but did not appear in the objective function.

Instructions
The generalized instructions for running each of the problems are to select the Table(s) highlighted
in yellow with the input data. If the tables are labeled separately then two tables will need to be inputted into
the model. Paste the optimal solution, duel and objective function values as shown in the table. In some case
the dual will be broken up into more than one part then paste in the order shown by the dual table numbers
(e.g. D1, D2).

Omar Hopkins
Page 2 of 23

Project 1

Problem 18
The city of Busville contains three school districts. The number of minority and non-minority
students in each district is given by,
District
1
2
3

Minority Students
50
50
100

Non-minority Students
200
250
150

Of all students, 25%The local court has decided that each of the town's two high schools (Cooley
High and Walt Whitman High) must have approximately the same percentage of minority students (within
5%) as the entire town. The distances (in miles) between the school districts and the high schools are given
below,
District
1
2
3

Cooley High
1
2
1

W. Whitman High
2
1
1

Each high school must have an enrollment of 300-500 students. Use linear programming to
determine an assignment of students to schools that minimize the total distance students must travel to school.

The Solution:
The following spreadsheet application allows the use to evaluate various scenarios and generate
optimal solutions.
District

Minority
Students
50
100
100
20%
30%

1
2
3
Min
Max

Nonminority Cooley High W. Whitman


Students
High
200
1
2
250
2
1
150
1
1
70%
300
500
80%
300
500

Optimal Solution
District
1
2
3

D2 - Dual Solution
Cooley High
Minority Nonminority
50
200
0
0
87.5
150

D1 - Dual Solution
Minority Enroll
School Size

Omar Hopkins
Page 3 of 23

Cooley High
Min
Max
0
0
0
0

W. Whitman High
Minority Nonminority
0
0
50
250
12.5
0
W. Whitman High
Min
Max
0
0
0
0

Minority
1
1
1

Nonminority
1
1
1

Student-Miles (Obj Fn)


800

Project 1

Interpretation of the Dual


The dual indicates approximately how much the objective function would change per unit change in
the constraint.
In this problem increasing the number students will increase the number of student-miles traveled.
Likewise the changing the upper and lower bounds of the school size and minority fraction will not affect the
objective function.

Omar Hopkins
Page 4 of 23

Project 1

Problem 22
Alden Enterprises produces two products. Each product can be produced on one of two machines.
The length of time needed to produce each product (in hours), on each machine is shown in Table 51. Each
month, 500 hours of time are available on each machine. Each month, customers are willing to buy up to the
quantities of each product at the prices given Table 52. The company's goal is to maximize the revenue
obtained from selling units during the next two months. Formulate an LP to help meet this goal.
Table 51
Product 1
Product 2

Machine 1
4
7

Table 52

Machine 2
3
4

Demands
Month 1
100
140

Product 1
Product 2

Prices
Month 2
190
130

Month 1
55
65

Month 2
12
32

The Solution:
The following spreadsheet application allows the use to evaluate various scenarios and generate
optimal solutions.

Input
T51

T52

Prod 1
Prod 2
Constrain
t

Mach 1
4
7

Mach 2
3
4

500

500

Prod 1
Prod 2

Demands
Month 1 Month 2
100
190
140
130

Prices
Month 1
55
65

Month 2
12
32

Output

Dual Solution
Optimal Solution
Revenue
Availability
Demand
Sol'n
Month 1 Month 2 8714.286
Mach 1
Mach 2
Prod 1
Prod 2
Prod 1
100
0
Month 1
9.285714
0 17.85714
0
Prod 2
14.28571 71.42857
Month 2
4.571429
0
0
0

Interpretation of the Dual


The dual indicates approximately how much the objective function would change per unit change in
the constraint.
In this problem the dual solution indicates that if the availability of machine was increased the
objective function (revenue) could be increased. Machine 2 would have an immediate effect. This suggests
that additional capital investment should be in increasing the availability of machine 1. Likewise demand of
product one in the first period is constraining revenue stream. Advertising moneys would be best spent
increasing the demand of product 1 in the first period.

Omar Hopkins
Page 5 of 23

Project 1

Problem 23
Kiriakis Electronics produces three products. Each product must be processed on each of three types
of machines. When a machine is in use, it must be manned by a worker. The time (in hours) required to
process each product on each machine and the profit associated with each product are shown in Table 53. At
present, five type I machines, three type II machines, and four type III machines are available. The company
has ten workers available and must determine how many workers to assign to each machine. The plant is
open 40 hours per week, and each worker works 35 hours per week. Formulate an LP that will enable
Kiriakis to assign workers to machines in a way that maximizes weekly profits. (Note: A worker need not
spend the entire work week manning a single machine.)
Table 53
Machine 1
Machine 2
Machine 3
Profit

Product 1
2
3
4
6

Product 2
3
5
7
8

Product 3
4
6
9
10

The Solution:
The following spreadsheet application allows the use to evaluate various scenarios and generate
optimal solutions.
Table T1
Prod 1
Prod 2
Prod 3 #Available
Mach 1
2
3
4
5
Mach 2
3
5
6
3
Mach 3
4
7
9
4
Profit
$ 6.00 $ 8.00 $ 10.00
Table T2
Work Week (hrs)
Machine Week (hrs)

35
40

Profit
$ 233.33

Optimal Solution
Worker
1
2
3
4
5
6
7
8
9
10
D1 - Dual/Machines

1
7.78
0.00
0.00
0.00
0.00
35.00
0.00
0.00
35.00
0.00
0.00

Machine
2
11.67
0.00
0.00
35.00
35.00
0.00
35.00
0.00
0.00
0.00
0.00

D2 - Dual
Labor
3
15.56
35.00
35.00
0.00
0.00
0.00
0.00
35.00
0.00
35.00
0.00

0.67
0.67
0.67
0.67
0.67
0.67
0.67
0.67
0.67
0.67

Interpretation of the Dual


The dual indicates approximately how much the objective function would change per unit change in
the constraint.
Note that in this example the dual for labor and the dual for capital refer to the constraint of workerhours and machine-hours. For each additional worker-hour added the firm could expect to reap an additional
Omar Hopkins
Page 6 of 23

Project 1
profit of $0.67. Adding additional machine capacity will not increase profits for the firm. Thus for this firm
to increase profits it needs to hire more labor (the constraining factor).

Omar Hopkins
Page 7 of 23

Project 1

Problem 24
Gotham City Hospital serves cases from four diagnostic related groups (DRGs). The profit
contribution, diagnostic service use (in hours), bed-day use (in days), nursing care use (in hours) and drug use
(in dollars) are given in Table 54. At present the hospital has available each week 570 hours of diagnostic
services, 1000 bed-days, 50,000 nursing hours, and $50,000 worth of drugs. To meet the community's
minimum health care demands at least 10 DRG1, 15 DRG2, 40 DRG3, and 160 DRG4 cases must be handled
each week. Use LP to determine the hospital's optimal mix of DGR's.
Table 54
Profit
Diagnostic
Bed-day
Nursing Use
Drugs
Services
DRG1
2000
7
5
30
800
DRG2
1500
4
2
10
500
DRG3
500
2
1
5
150
DRG4
300
1
0
1
50

The Solution:
The following spreadsheet application allows the use to evaluate various scenarios and generate
optimal solutions.
T1
DRG1
DRG2
DRG3
DGR4
Maximum
Dual
Profit
$ 2,000.00 $ 1,500.00 $ 500.00 $ 300.00
D1
Diag Service
7
4
2
1
570
250
Bed-Days
5
2
1
0
1000
0
Nursing Hours
30
10
5
1
50000
0
Drugs ($)
800
500
150
50
50000
1
Minimum
10
15
40
160
Optimal Sol'n
Dual - D2

10
-550

50
0

40
-150

220
0

Total Profit
$ 181,000.00

Interpretation of the Dual


The dual indicates approximately how much the objective function would change per unit change in the
constraint.
From the dual we can see that of the four basic resources, bed-days and nursing hours are not
constraints on total profit. However Diagnostic Services are a substantial constraint on profit. Therefore
additional resources should be invested in this area. Likewise the minimum service constraints of DRG1 and
DRG2 are reducing profit (negative dual). Therefore, were possible, those service should be substituted with
the services of DRG2 and DRG4.

Omar Hopkins
Page 8 of 23

Project 1

Problem 43
Silicon Valley Corporation (Silvco) manufactures transistors. An important aspect of the
manufacture of transistors is the melting of the element germanium (a major component of a transistor) in a
furnace. Unfortunately, the melting process yields germanium of highly variable quality.
There are two methods that can be used to melt germanium; method 1 cost $50 per transistor, and
method 2 costs $70 per transistor. The qualities of germanium obtained by methods 1 and 2 are shown in
Table 61. Silvco can refire melted germanium in an attempt to improve its quality. It costs $25 to refire the
melted germanium for one transistor. The results of the refiring process are shown in Table 62. Silvco has
sufficient furnace capacity to melt or refire germanium for at most 20,000 transistors per month. Silvco's
monthly demands are for 1000 grade 4 transistors, 2000 grade 3 transistors, 3000 grade 2 transistors, 3000
grade 1 transistors. Use LP to minimize the cost of producing the needed transistors.
Grade of Melted Germanium

Percent Yielded by Melting


Method 1
30
30
20
15
5

Defective
Grade 1
Grade 2
Grade 3
Grade 4
Refired Grade of
Germanium
Defective
Grade 1
Grade 2
Grade 3
Grade 4

Method 2
20
20
25
20
15

Percent Yielded by Refiring


Grade 1
Grade 2
0
0
30
0
30
40
20
30
20
30

Defective
30
25
15
20
10

Grade 3
0
0
0
50
50

The Solution:
The following spreadsheet application allows the use to evaluate various scenarios and generate
optimal solutions.
From the optimal solution we can see that refiring is not a preferred production strategy.
T1

Yield

Defective
G1
G2
G3
G4
Firing Cap
Cost
Solution

M1

M2

G1

30%
30%
20%
15%
5%
1
50

20%
20%
25%
20%
15%
1
70

30%
25%
15%
20%
10%
1
25

0%
30%
30%
20%
20%
1
25

Refire
G2 G3
0%
0%
40%
30%
30%
1
25

0%
0%
0%
50%
50%
1
25

G4 Production
Objective
0%
0%
0%
0%
1%
1
25

11,428.57 2,857.14 0.00 0.00 0.00 0.00 0.00

Omar Hopkins
Page 9 of 23

0
3000
3000
2000
1000
20000

Dual
0.00
0.00
228.57
0.00
85.71
0.00
Objective Fn
$ 771,428.57

Project 1

Interpretation of the Dual


The dual indicates approximately how much the objective function would change per unit change in the
constraint.
We can see from the solution that the constraints that drive the objective function are the production
objectives of the G2 and G4 grade transistors. Thus Silvco might attempt to increase demand for Transistors
G1 and G3. The goal for Silvco would be to attempt to have no excess production of any grade transistor.

Omar Hopkins
Page 10 of 23

Project 1

Problem 49
Transeast Airlines flies on the following route: LA-Houston-NY-Miami-LA. The length (in miles)
of each segment of this trip is as follows: LA-Houston, 1500 miles; Houston-NY, 1700 miles; NY-Miami,
1300 miles; Miami-LA, 2700 miles. At each stop, the plane may purchase up to 10,000 gallons of fuel. The
price of fuel at each city is as follows: LA $0.88, Houston $0.15, NY $1.05, Miami $0.95. The plane's fuel
tank can hold at most 12,000 gallons. To allow for the possibility of circling over a landing site, we require
that the ending fuel level for each leg of the flight be at least 600 gallons. The number of gallons used per
mile on each leg of the flight is

1 average fuel level on leg of flight 2000


To simplify matters, assume that the average fuel level on any leg of the flight is

Fuel level at the start of leg fuel level at end of leg


2
Formulate an LP that can be used to minimize the fuel cost incurred in completing the schedule.

The Solution:
The following spreadsheet application allows the use to evaluate various scenarios and generate
optimal solutions.

To
TX
NY
FL
CA
Fuel Cost
Min Fuel
Max Fuel
Max Pur

CA
1500

TX

From
NY

FL

1700
1300
0.88
600
12000
10000

2700
0.95
600
12000
10000

0.15
600
12000
10000

1.05
600
12000
10000

Fuel Purchases
Gallons
3120
10000
Minimum Cost of Operation

1590

10000
$ 15,414.96

0.00
0.00
0.00
1.56

0.00
0.00
-1.11
6.34

Duel Solutions
Min Fuel
9.74
Max Fuel
0.00
Max Pur
0.00
Miles
1.41

1.51
0.00
-0.27
0.74

Interpretation of the Dual


The dual indicates approximately how much the objective function would change per unit change in
the constraint.
The dual solutions indicate that allowing purchases in excess of 10,000 gallons at Texas and/or
Florida could further reduce costs. In additional raising minimum fuel requirements at California or Texas
would also increase operational costs. Needless to say, re-estimating the mileage upwards between any two
Omar Hopkins
Page 11 of 23

Project 1
points will increase total fuel costs. Maximum fuel capacity of the jet does not seem to affect the overall cost
of flight operations.

Omar Hopkins
Page 12 of 23

Project 1

Problem 53
E.J. Korvair Department Store has $1000 in available cash. At the beginning of each of the next 6
months, E.J. will receive revenues and pay bills as shown in Table 66. It is clear that E.J. will have a shortterm cash flow problem until the store receives revenues from the Christmas shopping season. To solve this
problem E.J. must borrow money.
At the beginning of July, E.J. may take out a six-month loan. Any money borrowed for a six-month
period must be paid back at the end of December along with 9% interest (early payback does not reduce the
interest cost of the loan). E.J. may also meet cash needs through month-to-month borrowing. Any money
borrowed for a one-month period incurs an interest cost of 4% per month. Use LP to determine how E.J. can
minimize the cost of paying its bills on time.
Table 66
July
August
September
October
November
December

Revenues
1000
2000
2000
4000
7000
9000

Bills
5000
5000
6000
2000
2000
1000

The Solution:
The following spreadsheet application allows the use to evaluate various scenarios and generate
optimal solutions.

T1
Initial Cash
July
August
September
October
November

Revenue
$1,000.00
$1,000.00
$2,000.00
$2,000.00
$4,000.00
$7,000.00

December

$9,000.00 $1,000.00 $

T2
6-month
Interest/life
9%

Bills
$5,000.00
$5,000.00
$6,000.00
$2,000.00
$2,000.00

Loans
1-month
4%

Income (Debt)
By month
$ (3,000.00)
$ (3,000.00)
$ (4,000.00)
$ 2,000.00
$ 5,000.00
8,000.00

Cumulative
Surplus (Debt)

Loan Amts

$ (3,000.00) 1-Month $
$ (6,000.00) Loans
$
$ (10,000.00)
$ 4,000.00
$ (8,000.00)
$ 2,000.00
$ (3,000.00)
$
$

5,000.00

$
6-Month
Loan $ 6,000.00

Dual/Amt
Due
0
0.01
0.04
0.04
0
0

Total Loan Cost


780.00

Interpretation of the Dual


The dual indicates approximately how much the objective function would change per unit change in
the constraint.
The dual shows that if the loan amounts were to increase between August and October (particularly
September-October) each dollar increase would result in an increase in the total cost of covering the cash
flow shortfall.

Omar Hopkins
Page 13 of 23

Project 1

Problem 55
Donald Rump is the international funds manager for Countribank. Each day Donald's job is to
determine how the bank's current holdings of dollars, pounds, marks, and yen should be adjusted to meet the
day's currency needs. Today the exchange rates between various currencies are given in Table 67. At the
beginning of the day Countribank has the currency holdings given in Table 68. At the end of the day,
Countribank must have at least the amounts of each currency given in Table 69. Donald's goal is to each day
transfer funds in a way that makes currency holdings satisfy the previously listed minimums, and maximizes
the dollar value of the currency holdings at the end of the day.
To figure out the dollar value of, say, one pound, average the two conversion rates.
Table 67
To
From
Dollars
Pounds
Marks
Yen
Dollars
1
0.58928
1.743
138.3
Pounds
1.697
1
2.9579
234.7
Marks
0.57372
.33808
1
79.346
Yen
0.007233
0.00426
0.0126
1
Table 68
Currency
Dollars
Pounds
Marks
Yen

Starting
Units (10x9)
8
1
8
0

Table 69
Currency
Dollars
Pounds
Marks
Yen

Ending
Units (10x9)
6
3
1
10

The Solution:
The following spreadsheet application
optimal solutions.
T1
Dollars
Pounds
Dollars
1
0.58928
Pounds
1.697
1
Marks
0.5732
0.33808
Yen
0.007233
0.00426
Start
8.00E+09 1.00E+09
End
6.00E+09 3.00E+09

allows the use to evaluate various scenarios and generate


Marks
Yen
1.743
138.3
2.9579
234.7
1
79.346
0.0126
1
8.00E+09 0.00E+00
1.00E+09 1.00E+10

Optimal & Dual Solution


Final Holdings
6E+09
3E+09
1E+09 3.626E+11
Dual/Start
1.0001736 1.6973103 0.5738167 0.0072343
Dual/End
-0.000174 -0.000288 -0.000355
0
Value of Optimal Holdings
1.43E+10

Interpretation of the Dual


The dual indicates approximately how much the objective function would change per unit change in
the constraint.

Omar Hopkins
Page 14 of 23

Project 1
The dual solution indicates that increasing the starting amount of any currency will increase the end
value of the holdings (which makes intuitive sense). The dual solution also indicates that yen holdings
increase the dollar value of the account at the end of the day. The other currencies (with their negative dual
values) will reduce the account value.
Note that there seemed to be a very small buy/sell gap. A larger gap might have had more
pronounced effects on the relative value of the different currencies.

Omar Hopkins
Page 15 of 23

Project 1

Appendix - Matlab Code


Note that the following code was run as separate programs. For the purposes of presentation they
have been co-joined.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Project No. 1
%%
%% Omar Hopkins
%%
%% OR 210 - Models in Operations Research %%
%% Fall 1999 - Dr. Dong Shaw
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Problem 18
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Problem 18
% Matrix Analyzer
function [x,y1,y2,z]=P18(T1)
% Set up objective function
c1=T1(1:3,3);
c2=T1(1:3,4);
c3=zeros(1,2);
c=[c1',c1',c2',c2',c3];
d=ones(1,14);
% Set up "A" Matrix
% Note columns 13/14 are dummy variables for school population
O6=ones(1,6);
Z6=zeros(1,6);
Z12=zeros(4,12);
I2=eye(2);
NI2=I2*-1;
I6=eye(6);
Z62=zeros(6,2);
Min=NI2*T1(4,1);
Max=NI2*T1(5,1);
O3=ones(1,3);
Z3=zeros(1,3);
A1=[I6,I6,Z62];
A2=[O3,Z3,Z6;Z6,O3,Z3];
A3=[A2,Min;A2,Max];
A4=[I2;I2];
A5=[Z12,A4];
A6=[O6,Z6;Z6,O6];
A7=[A6,NI2];
A=[A7;A5;A3;A1];
% Set up constraints
b1=zeros(2,1);
for i=1:2
for j=1:2
b2=[b2;T1(3+j,2+i)];
end
Omar Hopkins
Page 16 of 23

Project 1
end
b3=zeros(4,1);
for i=1:2
for j=1:3
b4=[b4;T1(j,i)];
end
end
b=[b1;b2;b3;b4];
e3=ones(2,1)*3;
e2=ones(2,1)*2;
e1=ones(2,1);
e=[e3;e2;e1;e2;e1;e3;e3;e3];
[status,x,y,z]=lp_solver(A,b,c,'min',e,d);
% Format Output
x1=x(1:3,:);
x2=x(4:6,:);
x3=x(7:9,:);
x4=x(10:12,:);
x=[x1,x2,x3,x4];
y21=[y(1,3),y(1,5)];
y22=[y(1,4),y(1,6)];
y31=[y(1,7),y(1,8)];
y32=[y(1,9),y(1,10)];
y2=[y21,y22;y31,y32];
y11=y(1,11:13);
y12=y(1,14:16);
y1=[y11',y12'];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Problem 22
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [x,y,z] = P22(T51,T52)
% Problem set up
price=T52(:,3:4);
price=price';
[m,n]=size(price);
% Set up c matrix
c=reshape(price, 1, m*n);
%Set up A matrix
for j=1:2
PM=[eye(2)]*T51(1,j);
AA=[AA;PM];
end
for j=1:2
PM=[eye(2)]*T51(2,j);
AB=[AB;PM];
end
A=[AA,AB];
I=eye(4);
A=[A;I];
Omar Hopkins
Page 17 of 23

Project 1

%Set up b matrix
constraint1=T51(3,:);
for i=1:2
for j=1:2
b1=[b1;T51(3,i)];
end
end
constraint2=T52(:,1:2);
constraint2=constraint2';
[m,n]=size(constraint2);
b2=reshape(constraint2,m*n,1);
b=[b1;b2];
[status,X,Y,z]=lp_solver(A,b,c);
X=X';
x1=X(1,1:2);
x2=X(1,3:4);
x=[x1;x2];
Y=Y';
Y1=Y(1:4,1);
Y2=Y(5:8,1);
y1=[Y1(1:2,1),Y1(3:4,1)];
y2=[Y2(1:2,1),Y2(3:4,1)];
y=[y1,y2];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Problem 23
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [x,y1,y2,z]=P23(T1,T2)
% Problem Set Up
% Obj Fn
c1=T1(4,1:3);
c2=zeros(1,30);
c=[c2,c1];
d=ones(1,33);
% A Matrix
A1=T1(1:3,1:3)*-1;
I=eye(10);
A2=[ones(1,10),zeros(1,20);
zeros(1,10),ones(1,10),zeros(1,10);
zeros(1,20),ones(1,10)];
A3=zeros(13,3);
A4=[I,I,I];
A5=[A2;A2;A4];
A6=[A1;A3];
Omar Hopkins
Page 18 of 23

Project 1
A=[A5,A6];
% Constraints
b1=T1(1:3,4)*T2(2,1);
b2=ones(10,1)*T2(1,1);
b3=zeros(3,1);
b=[b3;b1;b2];
e1=ones(3,1)*3;
e2=ones(13,1);
e=[e1;e2];
[status,x,y,z]=lp_solver(A,b,c,'max',e,d);
x1=x(1:10,:);
x2=x(11:20,:);
x3=x(21:30,:);
x=[x1,x2,x3];
y=y';
y1=y(4:6,:);
y1=y1';
y2=y(7:16,:);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Problem 24
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [x,y1,y2,z]=P24(T1)
% Set Up Objective Function
c=T1(1,1:4)
d=ones(1,4);
% Set Up "A" Matrix
A1=T1(2:5,1:4);
A2=eye(4);
A=[A1;A2]
% Set Up Constraints
b1=T1(2:5,5);
b2=T1(6,1:4);
b=[b1;b2']
e1=ones(4,1)*1;
e2=ones(4,1)*2;
e=[e1;e2];
[status,x,y,z]=lp_solver(A,b,c,'max',e,d)
% Reshape results
x=x';
y1=y(:,1:4);
y1=y1';
y2=y(:,5:8);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Problem 43
%%
Omar Hopkins
Page 19 of 23

Project 1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [x,y,z]=P43(T1)
%Problem Set Up
%Note a large number of dummy variables have been set up
%Model only allows for _one_ refiring.
% Obj Function Set Up
c1=T1(7,1:7);
z110=zeros(1,10);
c=[c1,z110];
d=ones(1,17);
% Matrix "A" Set Up
A1=T1(1:5,1:2);
A2=T1(1:5,3:7);
z55=zeros(5,5);
I5=eye(5);
NI5=-1*I5;
z52=zeros(5,2);
FC=T1(6,1:7);
A11=[FC,z110];
A12=[A1,z55,NI5,z55];
A13=[z52,I5,NI5,z55];
A14=[z52,A2,z55,NI5];
A15=[z52,NI5,I5,NI5];
A=[A11;A12;A13;A14;A15];
% Constraint Set Up
b0=T1(6,8);
b1=zeros(15,1);
b2=T1(1:5,8);
b=[b0;b1;b2];
e0=1;
O5=ones(5,1);
e1=O5*1;
e2=O5*2;
e3=O5*3;
e=[e0;e3;e1;e3;e2];
[status,x,y,z]=lp_solver(A,b,c,'min',e,d);
% Reformat solutions
x=x(1:7,:)';
y0=y(1,1);
y1=y(1,17:21);
y=[y1,y0]';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Problem 49
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [x,y,z]=P49(T1)

Omar Hopkins
Page 20 of 23

Project 1
% Problem Set Up
% Note that dummy variables for fuel @ arrival and
% fuel consumed have been set up in the model
% Set Up Objective Function
c1=T1(5,1:4);
c2=zeros(1,8);
c=[c1,c2];
% Set Up "A" Matrix
I4=eye(4);
O4=zeros(4,4);
NI4=I4*-1;
WD=diag(ones(1,4),1);
WD=[WD(1:4,5),WD(1:4,2:4)];
WDM1=-1*WD+I4;
XX=T1(1:4,1:4)/4000;
v=diag(XX);
X1=diag(v,1);
X1=[X1(1:4,5),X1(1:4,2:4)];
X=X1+XX;
A1=[I4,O4,O4];
A2=[I4,WDM1,NI4];
A3=[O4,I4,O4];
A4=[I4,I4,O4];
A5=-1*[XX,X,NI4];
A=[A1;A2;A3;A4;A5];
% Set Up Constraints
b1=T1(8,1:4)';
e1=ones(4,1);
b2=zeros(4,1);
e2=ones(4,1)*3;
b3=T1(6,1:4)';
e3=ones(4,1)*2;
b4=T1(7,1:4)';
e4=ones(4,1);
b5=diag(T1(1:4,1:4));
e5=ones(4,1)*3;
b=[b1;b2;b3;b4;b5];
e=[e1;e2;e3;e4;e5];
[status,x,y,z]=lp_solver(A,b,c,'min',e);
% Format Solution
x=x(1:4,1)';
y1=y(1,1:4);
y2=y(1,9:12);
y3=y(1,13:16);
y4=y(1,17:20);
y=[y2;y3;y1;y4];
Omar Hopkins
Page 21 of 23

Project 1

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Problem 53
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [x,y,z]=P53(T1,T2)
%Objective Function
c1=T2(1,1);
c2=(ones(6,1))'*T2(1,2);
c=[c1,c2];
%decision variables
d=ones(1,7);
% A Matrix
I=eye(6);
A1=ones(6,1);
A=[A1,I];
% Constraints
b=-1*T1(1:6,1);
% Constraint Direction
e=ones(6,1)*2;
[status,x,y,z]=lp_solver(A,b,c,'min',e,d);
% Rearrange solution - such that 6month loan @ bottom
x1=x(1,:);
x2=x(2:7,:);
x=[x2;x1];
y=y';

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Problem 55
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [x,y,z]=P55(T1)
% Objective Function Set Up
for i=1:4
c1=[c1,(1/T1(1,i)+T1(i,1))/2];
end
c=[c1,zeros(1,16)];
% Generate "A" Matrix
A11=diag(T1(1,1:4),0);
A12=diag(T1(2,1:4),0);
A13=diag(T1(3,1:4),0);
A14=diag(T1(4,1:4),0);
A10=zeros(1,4);
Omar Hopkins
Page 22 of 23

Project 1

A1=[ones(1,4),zeros(1,12);zeros(1,4),ones(1,4),zeros(1,8);zeros(1,8),ones
(1,4),zeros(1,4);zeros(1,12),ones(1,4)];
A1=[zeros(4,4),A1];
A2=[-eye(4),A11,A12,A13,A14];
A3=[eye(4),zeros(4,16)];
A=[A1;A2;A3];
% Constraint Set Up
b=[T1(5,1:4)';zeros(4,1);T1(6,1:4)'];
e=[ones(4,1);ones(4,1)*3;ones(4,1)*2];
[status,x,y,z]=lp_solver(A,b,c,'max',e);
x=x(1:4,1)';
y=[y(1,1:4);y(1,9:12)];

Omar Hopkins
Page 23 of 23

You might also like