-
Notifications
You must be signed in to change notification settings - Fork 0
/
multires_solve.m
92 lines (73 loc) · 2.83 KB
/
multires_solve.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
%Author: Zsolt T. Kosztyán Ph.D habil., University of Pannonia,
%Faculty of Economics, Department of Quantitative Methods
%----------------
%Calculate the Pareto-Optimal Resource Allocation with Resource Levelling.
%----------------
%Output:
%SST N by 1 vector of Scheduled Start Time of tasks.
%----------------
%Inputs:
%LD: N by N binary upper triangular matrix of the logic domain
%TD: N by 1 vector of the time domain
%RD: N by nR matrix of the resource demands
%----------------
%Usage:
%SST=multires_solve(LD,TD,RD)
%----------------
%Example:
%LD=triu(round(rand(10))); %Specify Logic Domain
%TD=rand(10,1)*30; %Specify Time Domain
%RD=rand(10,3)*5; %Specify Resource Domain
%tic;SST=multires_solve(LD,TD,RD);toc
%----------------
%Prepositions and Requirements:
%1.)LD should be a binary, upper triangular matrix of the logic domain.
%2.)TD,RD contains positive values.
function SST=multires_solve(LD,TD,RD)
global DSM T R Cr
%global values:
% DSM is the input logic domain
% T is the column vector of time demands (=the time domain)
% R is the matrix of resource demands (=the resource domain)
% Cr is the vector of resource constraints
%---Initialization of the global varaibles---
DSM=triu(round(LD)); %DSM must be an upper triangular binary matrix
T=TD;
R=RD;
N=numel(TD);
%---End of the initialization of the global variables---
[~,EST,~,LST,~]=tptfast(LD,TD); %Calculating EST and LST,
%where EST<=SST<=LST
%---Set of multi-objective genetic algorithm (MOGA)---
% Vectorized:off and UseParallel:false serialize the genetic algorithm
% Display:off = There is no need any information to display
options=gaoptimset('Vectorized','off','UseParallel',false,'Display','off');
%---End of setting MOGA---
%---Runing MOGA---
% @maxres: the target function (=maxres, minimize the maximal resource
%demands)
% N: the number of variables
% EST,LST: lower, upper bounds.
% options: The set of options (see above).
X=gamultiobj(@maxres,N,[],[],[],[],EST,LST,options);
%---End of runing MOGA---
%---Start of output formatting---
if numel(X)>0
SST=X(1,:)'; %SST will be the first pareto-optimal solution.
else
SST=EST; %SST=EST if there is no optimal solution.
end
Cr=maxres(SST); %Cr will be the vector of minimal resource maximums
%---Runing MOGA---
% @usedfloat: the target function (=usedfloat, minimize the amount of used
%total slacks)
% N: the number of variables
% EST,LST: lower, upper bounds.
% @constrainrt: The nonlinear constraint of resource demands.
% options: The set of options (see above).
SST=ga(@usedfloat,N,[],[],[],[],EST,LST,@constrainrt,options);
%---Start of output formatting---
SST=reshape(SST,[],1);
if numel(SST)==0
SST=EST; %If there is no optimal solution, SST=EST.
end