% The coding below corresponds to problem 1%
% we set the f matrix equal to the coeffcients of our minimization problem
%the first element follows the trend Ps-24 for Ps={20, 22, 25, 27, 30, 32,
%35, 37, 40}. Note the actual value for the first element is = -(Ps-24)%
f20= [4 -2];
f22= [2 -2];
f25= [-1 -2];
f27= [-3 -2];
f30= [-6 -2];
f32= [-8 -2];
f35= [-11 -2];
f37= [-13 -2];
f40= [-16 -2];
A= [-1 0; 0 -1; 2 1; 1 1; 1 0];
b= [0; 0; 100; 80; 40];
%Now we test all these to find the optimal solution%
X20= linprog(f20,A,b)
X22= linprog(f22,A,b)
X25= linprog(f25,A,b)
X27= linprog(f27,A,b)
X30= linprog(f30,A,b)
X32= linprog(f32,A,b)
X37= linprog(f37,A,b)
X40= linprog(f40,A,b)
%This corresponds to problem 2%
%I denote each with a d for Dorian%
fd= [100 50];
Ad= [-2 -7; -12 -2; -1 0; 0 -1];
bd= [-28; -24; 0; 0];
Xd= linprog(fd,Ad,bd)
%For part b of problem 2, I let the price of comedy commercials%
%fluctuate from $30,000 to $50,000 in increments of $10,000%
d30= [100 30];
d40= [100 40];
d50= [100 50];
%Now we test%
D30= linprog(d30,Ad,bd)
D40= linprog(d40,Ad,bd)
D50= linprog(d50,Ad,bd)
%now for part c, we solve for the dual%
dualf= [-28 -24];
dualA= [-2 -12; -2 -7; -1 0; 0 -1];
dualb= [100; 50; 0; 0];
DUAL=linprog(dualf,dualA,dualb)
Academic License
>> HW1_Code
Optimization terminated.
X20 =
0.0000
80.0000
Optimization terminated.
X22 =
-0.0000
80.0000
Optimization terminated.
X25 =
0.0000
80.0000
Optimization terminated.
X27 =
20.0000
60.0000
Optimization terminated.
X30 =
40.0000
20.0000
Optimization terminated.
X32 =
40.0000
20.0000
Optimization terminated.
X37 =
40.0000
20.0000
Optimization terminated.
X40 =
40.0000
20.0000
Optimization terminated.
Xd =
1.4000
3.6000
Optimization terminated.
D30 =
1.4000
3.6000
Optimization terminated.
D40 =
1.4000
3.6000
Optimization terminated.
D50 =
1.4000
3.6000
Exiting: One or more of the residuals, duality gap, or total relative error
has grown 100000 times greater than its minimum value so far:
the dual appears to be infeasible (and the primal unbounded).
(The primal residual < TolFun=1.00e-08.)
DUAL =
1.0e+40 *
9.4183
0.0000