param n;
param l;
set P:= {1..n}; #set of projects
set RType:={"Project manager", "Contractual manager"}; #set of human resources
set T:= {1..l}; #set of periods
param LF{j in P}; # Latest finishing of the project
param Duration{j in P};# duration of project j
param RDemand{j in P, r in RType}; # total number of required resource type r to be allocated to project j on any term within its duration
param Av{r in RType, t in T}; #number of resource type r available at the period t
var Debut{j in P} integer>=1; # Project starting date
var Fin{j in P} integer>=0; # Project finishing date
var XS{j in P, t in T} binary; #indicates in which period project j starts
var XE{j in P, t in T} binary; #indicates in which period project j finishes
var Y{j in P, r in RType, t in T} integer>=0; #resource r allocated to project j at the period t
minimize Z:
sum{j in P, r in RType, t in T} Y[j,r,t];
subject to DurationConstraint {j in P}:
Fin[j]-Debut[j]+1= Duration[j];
subject to StartConstraint {j in P}:
Debut[j]= sum {t in T} t*XS[j,t];
subject to EndConstraint {j in P}:
Fin[j]= sum {t in T} t*XE[j,t];
subject to SContraint {j in P}:
sum{t in T} XS[j,t] <= 1;
subject to EConstraint {j in P}:
sum{t in T} XE[j,t] <= 1;
subject to AffectConstraint {r in RType, t in T}:
sum {j in P} Y[j,r,t]<= Av[r,t];
subject to DemandConstraint {j in P, r in RType, t in T}:
Y[j, r, t]= RDemand[j,r];
subject to FinishConstraint {j in P}:
Fin[j]<= LF[j];
subject to DemandConstraint {j in P, (j,s) in PS, (j, m) in PM, r in RType,t in T}:
Y[j, r, t]>= RDemand[s,m,r];!!!
subject to DemandConstraint {j in P, r in RType, t in T : Debut[j]<=t<=Fin[j]}:
Y[j, r, t]= RDemand[j,r];
Thank you!!!
Best regards,
subject to DemandConstraint {j in P, r in RType, t in T}: Debut[j] <= t <= Fin[j] ==> Y[j, r, t] = RDemand[j,r];