-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathColumnGenerationIP.m
57 lines (56 loc) · 2.15 KB
/
ColumnGenerationIP.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
%################- OR LAB- ------------#################
function [sheet_number,packing_pattern] = ColumnGenerationIP( B,width,Number,TW,flag)
%This code solves the 1D cutting Stock Problem Using Column Generation
%width = column vector of required width
%Number = column vector of required number of corresponding width
%TW = maximum Width of the roll
%flag is used to come out from the loop
%B is the initial basic matrix
%------- Initial Solution -------------------%
x = B\Number;% same as inv(B)*Number
%---- Size of basic variables -------%
m1 = size(width);
m = m1(1,1);
%------- Lower and Upperbound for solving MILP ----%
lb = zeros(m,1);
ub = inf(m,1);
%------- cost vector --------------%
cb = ones(m,1);% cb is the basic cost matrix
%------- Argument for calling intlinprog function --------%
f = (cb'/B)'; % f = transpse (transpose(cb)*inv(B))
A = width';
b = TW;
intcon = 1:m;
options = optimoptions('intlinprog','Display','off');% check intlinprog for this
[a,F]= intlinprog(-f,intcon,A,b,[],[],lb,ub,options);
%---------------------------------------------------------------
%---------------------------------------------------------------
%----- flag=1 when current basic is optimal --------------------
%----- Unboundedness has not been considered ------------------
if flag~=1
if F>=-1
flag =1;
else
dir = B\a;% same as inv(B)*a
theta =x./dir; % ./ provides element wise division of vector i.e. x1/d1, x2/d2.....
for i =1:m;
if theta(i) <= 0
theta (i) = inf;
%else
end
end
[I,J]= min(theta);
%----------- Unboundedness checking --------------------------------
if I ~= inf
B(:,J)= a;
else
flag =1; % this is the case of unboundedness--- Improve this code to tackle unboundedness
end
end
%------------------ Recursive calling of function till optimal solution----
[ x, B] = ColumnGenerationIP(B, width,Number,TW,flag);
%-------------------------------------------------------------------------
end
sheet_number=x;
packing_pattern =B;
end