-
Notifications
You must be signed in to change notification settings - Fork 0
/
constrainrtparc.m
68 lines (64 loc) · 2.42 KB
/
constrainrtparc.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
%Author: Zsolt T. Kosztyán Ph.D habil., University of Pannonia,
%Faculty of Economics, Department of Quantitative Methods
%----------------
%Calculate the constraints for the hybrid continouos time-cost trade-off
%problems
%----------------
%Outputs:
%c is a vector of inequities.
%ceq is null vector of Eq.s
%----------------
%Input:
%chromosome: set of populations
%----------------
%Usage:
%[c,ceq]=constrainrtparc(chromosome)
%----------------
%Example:
%This is not executed as a stand-alone fuinction. Instead of specifying
%global values this function is cannot be run.
%----------------
%Prepositions and Requirements:
%1.)Global values P,Q,T,C,Ct,Cc,Cs must be specified.
%2.)P should be an upper triangular matrix of the logic domain.
function [c,ceq]=constrainrtparc(chromosome)
global P Q T C Ct Cc Cs
%global values:
% P is the PopSize by PopSize scores matrix of task/dependency inclusion
% Q is the PopSize by PopSize scores matrix of task/dependency exclusion
% T is the column vector of time demands (=the time domain)
% C is the column vector of cost demands (=the cost domain)
% Ct is the time constraint
% Cc is the cost constraint
% Cs is the score constraint
PopSize=numel(chromosome(:,1)); %The size of the population
N=size(P,1); %Number of activities
c=zeros(PopSize,3); %Initialize the PopSize by 3 matrix of inequities
tpts=zeros(PopSize,1); %Initialize the vector of TPTs
tpcs=zeros(PopSize,1); %Initialize the vector of TPCs
for I=1:PopSize
PSM=updatepemc(chromosome(I,:)); %PSM=[DSM,T] = Logic Domain and the
%vector of the selected modes
DSM=PSM(:,1:N); %DSM is a binary upper triangular matrix
MODES=PSM(:,end); %MODES is the proposed time duration between the
%normal and the crash durations
TD=zeros(N,1);
CD=zeros(N,1);
for i=1:N
if MODES(i)==0
TD(i)=0;
CD(i)=0;
else
TD(i)=MODES(i);
CD(i)=timetocost(TD(i),T(i,:),C(i,:));
end
end
tpts(I)=tptfast(DSM,TD); %Calculate TPT for the member I of the
%population
tpcs(I)=diag(DSM)'*CD; %Calculate TPC for the member I of the
%population
c(I,1)=tpts(I)-Ct; %TPT should be lower than the time constraint
c(I,2)=tpcs(I)-Cc; %TPC should be lower than the cost constraint
c(I,3)=Cs-maxscore_PEM(DSM,P,Q); %TPS should be greater than Cs
end
ceq=[];