Constraint about the human resource demand for each project !!!

36 views
Skip to first unread message

Basma Ben Mahmoud

unread,
Nov 22, 2023, 3:46:18 PM11/22/23
to AMPL Modeling Language
Good afternoon,

I would like to know how to express the following condition that should introduce that the resource allocated to each project should satisfy each project demand during the period when the project is executing, means for t between Start and End.
  • Such as Debut (j) is the first decision variable: the starting date of the project.
  • Fin (j) the finishing date of the project j.
Here is the details about the problem :

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];


  • The results that I get are really weird when I juste put the following constraint :: 

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];!!!

  • When testing the following one, I had an error on defining indexes :

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,

AMPL Google Group

unread,
Nov 24, 2023, 4:29:28 PM11/24/23
to AMPL Modeling Language
AMPL needs to tell the solver how many constraints there are, and what each constraint is, before the solver runs. Thus it's not possible to put a restriction involving variables, such as Debut[j] <= t <= Fin[j], inside the indexing for a constraint. Instead the restriction involving variables must be part of the constraint expression. For example, using the ==> ("imples") operator, you can write DemandConstraint like this:

subject to DemandConstraint {j in P, r in RType, t in T}:
   Debut[j] <= t <= Fin[j]  ==>  Y[j, r, t] = RDemand[j,r];

This form of constraint is recognized by CBC, COPT, GCG, Gurobi, HiGHS, Mosek, SCIP, and Xpress. (CPLEX will be added soon.) If you have any problem getting it to work, please reply with your model and data files attached.


--
Robert Fourer

We're switching to a new, enhanced user forum.
Join it now at discuss.ampl.com.
{#HS:2430245802-120774#}

Basma Ben Mahmoud

unread,
Nov 30, 2023, 10:19:00 PM11/30/23
to AMPL Modeling Language
Thank you so much ! :)
Reply all
Reply to author
Forward
0 new messages