-
Notifications
You must be signed in to change notification settings - Fork 0
/
constrainrtparcq.m
78 lines (73 loc) · 2.83 KB
/
constrainrtparcq.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
%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-quality-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]=constrainrtparcq(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,q,Ct,Cc,Cq,Cs must be specified.
%2.)P should be an upper triangular matrix of the logic domain.
function [c,ceq]=constrainrtparcq(chromosome)
global P Q T C q Ct Cc Cq 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)
% q is the column vector of quality parameters
% Ct is the time constraint
% Cc is the cost constraint
% Cq is the quality 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,4); %Initialize the PopSize by 4 matrix of inequities
tpts=zeros(PopSize,1); %Initialize the vector of TPTs
tpcs=zeros(PopSize,1); %Initialize the vector of TPCs
tpqs=zeros(PopSize,1); %Initialize the vector of TPQs
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);
QD=zeros(N,1);
for i=1:N
if MODES(i)==0
TD(i)=0;
CD(i)=0;
QD(i)=0;
else
TD(i)=MODES(i);
CD(i)=timetocost(TD(i),T(i,:),C(i,:));
QD(i)=timetoquality(TD(i),T(i,:),q(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
tpqs(I)=tpqfast(DSM,P,QD); %Calculate TPQ 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)=Cq-tpqs(I); %TPQ should be greater than the Cq
c(I,4)=Cs-maxscore_PEM(DSM,P,Q); %TPS should be greater than Cs
end
ceq=[];