Continuity constraint

91 views
Skip to first unread message

Basma Ben Mahmoud

unread,
Jan 18, 2024, 4:43:38 PMJan 18
to AMPL Modeling Language
Hi,

I would like to know how to express the continuity constraint without using a decision variable in the conditional form. My challenge is to stay with a linear formulation.
I will start to explain my model :
We would like to determine the optimal starting and finishing date of the project while respecting the human resource capacity available to execute the project.

One of the assumptions is that the project could not be interrupted during its executing period, means once it starts it should be executed continually. Thus, we would like to express this constraint : Act[j,t] should have the value 1 for t<= Fin[j]
However, if we write the following constraint :
subject to continuityConstraint { j in P, t in T : t<= Fin[j]-1} :
Act [j,t+1] >= Act[j,t];
We are not with a linear model anymore

Sets :

set P:= {1..n}; #set of projects

set RType:={"Project manager", "Technical Expert", "Financial Analyst", "Estimator", "Contractual manager"}; #set of human resources

set T:= {1..l}; #set of terms

set S:= {"SP", "MP", "LP", "XLP"};#set of project sizes : small, medium, large and major

set PS within {P,S}; # Set of project-size combinations

Parameters : 

param ES{j in P}; # Earliest starting of the project

param LF{j in P}; # Latest finishing of the project

param Duration{j in P};# duration of project j

param RDemand{s in S, 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}>=0; #avaialibility of each human resource type r at the period t

Deicison variables :

var Act{j in P, t in T} binary#=1 if the project j is executing durint period t and 0 otherwise

var FinMax {j in P} integer;

var Debut{j in P} integer; # starting date of the project j

var Fin{j in P} integer; # Finishing date of the project j

var Y{j in P, r in RType, t in T} integer;# number of human resource type r allocated to project j at period t


subject to DurationConstraint {j in P}:

sum{t in T} Act[j, t] = Duration[j];

subject to AffectConstraint {r in RType, t in T}:

sum {j in P, (j,s) in PS} RDemand[s,r]*Act[j,t]<= Av[r,t];

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]*Act[j,t];

subject to Max_Constraint{j in P, t in T}:

t * Act[j, t] <= FinMax[j]; 

subject to Define_Fin{j in P}:

Fin[j] = FinMax[j]; 

subject to ActConstraint {j in P}:

(Fin[j]-Debut[j]) =(sum{t in T} Act[j,t])-1;


subject to FinishConstraint {j in P, t in T: t > LF[j]}:

Act[j,t]=0;

subject to SConstraint {j in P, t in T: t < ES[j]}:

Act[j,t]=0;


Thank you so much!!!

Do not hesitate if you have any question about the problem.


Best regards,

AMPL Google Group

unread,
Jan 19, 2024, 11:03:40 AMJan 19
to AMPL Modeling Language
Using the current versions of integer programming solvers that work with AMPL, you can write the constraint like this:

subject to continuityConstraint {j in P, t in T}:
   t <= Fin[j] - 1 ==> Act[j,t+1] >= Act[j,t];

(The ==> operator means "implies".) Solvers you can use include Gurobi, Xpress, COPT, MOSEK, HiGHS, SCIP, and CBC.


--
Robert Fourer

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

Ijtihad Emon

unread,
Jan 19, 2024, 11:03:41 AMJan 19
to am...@googlegroups.com
What result outcome. 

Ijtihad Emon BBA, (Notre Dame University of Bangladesh) MSc.Business Analytics (University of Kent), UK
UK, Canterbury 
  
Please make sure to maintain the time available for a contact.
Available Time for Contact:
Saturday - Not available.
Sunday - Not available.
Monday - 11:00 AM to 12:00 PM and 1:00 PM to 3:00 PM, (UK + Time Zone)
Tuesday - 12:00 PM to 2:00 PM, (UK + Time Zone)
Wednesday - 12:00 PM to 2:00 PM, (UK + Time Zone)
Thursday - 12:00 PM to 2:00 PM, (UK + Time Zone)
Friday - 12:00 PM to 2:00 PM, (UK + Time Zone)

Contact Number: +4407915302721
Email: ijtih...@gmail.com


--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ampl/f22c6f1a-deda-4210-be6a-daf2961d3ec2n%40googlegroups.com.

Ijtihad Emon

unread,
Jan 19, 2024, 1:33:00 PMJan 19
to am...@googlegroups.com
Ok let me try

Sent from Outlook for iOS

From: AMPL Google Group <am...@googlegroups.com>
Sent: Friday, January 19, 2024 3:45:44 AM
To: AMPL Modeling Language <am...@googlegroups.com>
Subject: Re: [AMPL 24955] Continuity constraint
 
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.

Basma Ben Mahmoud

unread,
Jan 19, 2024, 2:40:20 PMJan 19
to AMPL Modeling Language
Hi,

Thank you so much!

I tried the following constraint : 
subject to continuityConstraint {j in P, t in T }:

(2<= t <= Fin[j]) ==> (Act[j, t] >= Act[j, t-1]);

And I got an error message : 

Error: The redefinition of an indicator constraint "bin_var==0/1 ==> c'x>=d" into a big-M constraint failed due to the absence of a finite lower bound on c'x. If the solver supports indicator constraints, it will be passed to the solver, otherwise this is a fatal error. To remove this error/warning, the following options can be available:

1. Provide tight bounds on variables entering logical expressions;

2. Use option cvt:mip:bigM to set the default value of big-M (use with care);

3. If available, set acc:indle=2 for native handling of the constraint.

exit value 18446744073709551615


My second question:  Is there any way to express this continuity while staying with a linear problem please? We would like to use the Cplex solver and to search for an optimal solution.

Thank you again!

AMPL Google Group

unread,
Jan 20, 2024, 6:00:24 PMJan 20
to AMPL Modeling Language
Since 2 <= t does not involve a variable, it would be better to write the constraint like this:

subject to continuityConstraint {j in P, t in T: t >= 2}:
   t <= Fin[j]  ==>  Act[j,t] >= Act[j,t-1];

In the error message, the instruction "Provide tight bounds on variables entering logical expressions" refers to this variable that appears in continuityConstraint:


var Fin {j in P} integer;

You can fix the error by adding some reasonable lower and upper bounds to this statement. For example, the bounds might be:

var Fin {j in P} integer, >= ES[j], <= LF[j];

Using some appropriate bounds, the solver can convert "t <= Fin[j] ==> Act[j,t] >= Act[j,t-1]" to a linear formulation that is solvable. (Note: If you want to use CPLEX, you will need to select the new version that is called "cplexmp" in the current distribution, by writing "option solver cplexmp;".)

Alternatively, you might change your model to replace the constraint using ==> by a linear formulation. This may be difficult, however -- it would involve adding more binary variables and more constraints to your model -- and there is some change of making a mistake. Operations Research Stack Exchange is a good place to ask for help with reformulations like this.

If you have more questions, please attach your model and data files so that it is possible to reproduce any problem that you are seeing.


--
Robert Fourer

We're switching to a new, enhanced user forum.
Join it now at discuss.ampl.com.
{#HS:2484545601-121864#}
On Fri, Jan 19, 2024 at 7:40 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hi,

Thank you so much!

I tried the following constraint :
subject to continuityConstraint {j in P, t in T }:

(2<= t <= Fin[j]) ==> (Act[j, t] >= Act[j, t-1]);

And I got an error message :

Error: The redefinition of an indicator constraint "bin_var==0/1 ==> c'x>=d" into a big-M constraint failed due to the absence of a finite lower bound on c'x. If the solver supports indicator constraints, it will be passed to the solver, otherwise this is a fatal error. To remove this error/warning, the following options can be available:

1. Provide tight bounds on variables entering logical expressions;

2. Use option cvt:mip:bigM to set the default value of big-M (use with care);

3. If available, set acc:indle=2 for native handling of the constraint.

exit value 18446744073709551615

My second question: Is there any way to express this continuity while staying with a linear problem please? We would like to use the Cplex solver and to search for an optimal solution.

Thank you again!

On Fri, Jan 19, 2024 at 6:33 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Ok let me try

On Fri, Jan 19, 2024 at 4:04 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
What result outcome.


Ijtihad Emon BBA, (Notre Dame University of Bangladesh) MSc.Business
Analytics (University of Kent), UK

+447915302721 | ijtih...@gmail.com
UK, Canterbury

Please make sure to maintain the time available for a contact.

Available Time for Contact:
Saturday - Not available.
Sunday - Not available.
Monday - 11:00 AM to 12:00 PM and 1:00 PM to 3:00 PM, (UK + Time Zone)
Tuesday - 12:00 PM to 2:00 PM, (UK + Time Zone)
Wednesday - 12:00 PM to 2:00 PM, (UK + Time Zone)
Thursday - 12:00 PM to 2:00 PM, (UK + Time Zone)
Friday - 12:00 PM to 2:00 PM, (UK + Time Zone)

Contact Number: +4407915302721
Email: ijtih...@gmail.com


On Thu, 18 Jan 2024 at 9:43 pm, Basma Ben Mahmoud <
On Fri, Jan 19, 2024 at 3:45 AM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Using the current versions of integer programming solvers that work with AMPL, you can write the constraint like this:

subject to continuityConstraint {j in P, t in T}:
   t <= Fin[j] - 1 ==> Act[j,t+1] >= Act[j,t];

(The ==> operator means "implies".) Solvers you can use include Gurobi, Xpress, COPT, MOSEK, HiGHS, SCIP, and CBC.


--
Robert Fourer

We're switching to a new, enhanced user forum.
Join it now at discuss.ampl.com.
Reply all
Reply to author
Forward
0 new messages