Contents

numbers of days and schdules

Nd = 7;
Ns = 10;

off days for 10 schedules

S= [1 1 2 2 3 3 4 4 5 5;
    6 7 6 7 6 7 6 7 6 7];

on or off matrix

A = ones(Nd,Ns);
for j = 1:Ns
    A(S(:,j),j) = 0;
end

demands and costs

b = [60 45 40 50 60 35 35]';
c = 500*ones(Ns,1);
c([2 9]) = 450;
disp([A b]); disp(c');
     0     0     1     1     1     1     1     1     1     1    60
     1     1     0     0     1     1     1     1     1     1    45
     1     1     1     1     0     0     1     1     1     1    40
     1     1     1     1     1     1     0     0     1     1    50
     1     1     1     1     1     1     1     1     0     0    60
     0     1     0     1     0     1     0     1     0     1    35
     1     0     1     0     1     0     1     0     1     0    35

   500   450   500   500   500   500   500   500   450   500

nonnegativity

lb = zeros(Ns,1);

solve using 2 methods

default: interior-point method

fprintf('\ndefault: ')
[x,f,~,~,lambda] = linprog(c,-A,-b,[],[],lb);
fprintf('f = %d, sum(x) = %i\n',f,sum(x));
fprintf('----- primal:\n'); fprintf('x: %.2f\n',x);
fprintf('------- dual:\n'); fprintf('y: %.2f\n',lambda.ineqlin);

% simplex method
fprintf('\nsimplex: ')
opts = optimset;
opts.LargeScale = 'off';
opts.Simplex = 'on';
[x,f,~,~,lambda] = linprog(c,-A,-b,[],[],lb,[],[],opts);
fprintf('f = %d, sum(x) = %i\n',f,sum(x));
fprintf('----- primal:\n'); fprintf('x: %.2f\n',x);
fprintf('------- dual:\n'); fprintf('y: %.2f\n',lambda.ineqlin);
default: Optimization terminated.
f = 3.400000e+04, sum(x) = 7.000000e+01
----- primal:
x: 0.00
x: 10.00
x: 8.42
x: 8.42
x: 9.44
x: 9.44
x: 7.15
x: 7.15
x: 10.00
x: 0.00
------- dual:
y: 50.00
y: 0.00
y: 0.00
y: 0.00
y: 50.00
y: 400.00
y: 400.00

simplex: Optimization terminated.
f = 34000, sum(x) = 70
----- primal:
x: 0.00
x: 10.00
x: 0.00
x: 25.00
x: 5.00
x: 0.00
x: 20.00
x: 0.00
x: 10.00
x: 0.00
------- dual:
y: 50.00
y: 0.00
y: 0.00
y: 0.00
y: 50.00
y: 400.00
y: 400.00