Need help to code the following equation

15 views
Skip to first unread message

Udoy Paul

unread,
May 15, 2018, 12:22:25 PM5/15/18
to AMPL Modeling Language
Hi,
I have defined two sets as 

"set Number;
set Time;

param cost{Number}>=0;

param x0{Number} binary;

param rate{Number}>=0;

param demand{Time}>=0;

var x{Number,Time} binary;
var u{Number,Time} binary;
var p{Number,Time}>=0;"

In my constraints, I need to make sure that the following inequality holds:

U(t) >= X(t) - X(t-1);  for all Number

here t is for Time. and X0 is simply the initial status of the Number. 

Since I am new to AMPL, it would be a great help if you please help me with this. Thank you so much for your time.

Best,
Udoy Paul.

AMPL Google Group

unread,
May 15, 2018, 2:17:06 PM5/15/18
to Ampl Modeling Language
You have declared TIME is the set, but the way describe makes me think that TIME should be param. Is the members of TIME is 1...n, then you could declare param Time:=5;(say n=5), then use 1...Time to get all the members from 1...Time. You could write your constraint as follows:

subject to c1{i in Number, t in 2..Time}: u[i,t] >= x[i,t] - x[i,t-1];

If the members of time are indeed a set then you could modify your constraint: subject to c1{i in Number, t in Time: t!=0}: u[i,t] >= x[i,t] - x[i,t-1];



--
Paras Tiwari
am...@googlegroups.com
{#HS:581419801-7759#}
--
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 post to this group, send email to am...@googlegroups.com.
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.



Udoy Paul

unread,
May 17, 2018, 8:58:47 PM5/17/18
to AMPL Modeling Language
Thank you so much Mr. Tiwari. It was a great help. 

Best 
Udoy paul
Reply all
Reply to author
Forward
0 new messages