Syntax error due to dimensional declaration

57 views
Skip to first unread message

CHIN JUN NAN

unread,
Nov 14, 2021, 9:15:02 AM11/14/21
to AMPL Modeling Language
Good days,

I have faced problems when I want to declare for the objective function, my R could have problems because it should be a 2-dimensional variable but I am not sure how can I declare for it in the objective function.

The ILP formulation will be:
ILP formulation.PNG

Thanks in advance.
monitoring.mod
monitoring.dat

AMPL Google Group

unread,
Nov 15, 2021, 1:57:55 PM11/15/21
to AMPL Modeling Language
An AMPL indexing expression must have the form "index in set-expr" where index is a name not currently defined, and set-expr is any set-valued expression. Thus, in your objective function, "P in R" is being rejected, because P is already defined (as the name of a set), and also R is not a set-valued expression (since it is the name of a parameter).

I can see that you write "P in R" because you are trying to create an AMPL expression for the following summation in your mathematical description of the objective:
bd8cae4d34a857883ec45aa429a7a82e.png
But it is not standard mathematical notation to have a formula with two ϵ signs in it. Can you explain what this notation means? In particular, what values does p take when it is summed in this way?


--
Robert Fourer
am...@googlegroups.com
{#HS:1696318300-107158#}

CHIN JUN NAN

unread,
Nov 16, 2021, 8:47:41 AM11/16/21
to AMPL Modeling Language
Dear Robert,

The notation is used to maximize the number of spatial dependencies and temporal dependencies when conducting the network monitoring. p will represent the active network flow inside a simple path; P is representing all of the possible network flows that are needed to collect all the target telemetry items requested by the application; Rsm is using to store the telemetry items that must be collected at the same node/device.

Thank you very much.

AMPL Google Group

unread,
Nov 17, 2021, 1:18:24 PM11/17/21
to AMPL Modeling Language
You have given a general description of how p, P, and Rsm relate to your application. However, it is still not clear how the summation indexing expression -- the one with two ϵ signs -- should be interpreted mathematically.

Perhaps you can give an example. For the P and Rsm data shown in your file monitoring.dat, how many p values does
bd8cae4d34a857883ec45aa429a7a82e.png
sum over, and what are those values?


--
Robert Fourer
am...@googlegroups.com
{#HS:1696318300-107158#}
On Tue, Nov 16, 2021 at 1:47 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Dear Robert,

The notation is used to maximize the number of spatial dependencies and temporal dependencies when conducting the network monitoring. p will represent the active network flow inside a simple path; P is representing all of the possible network flows that are needed to collect all the target telemetry items requested by the application; Rsm is using to store the telemetry items that must be collected at the same node/device.

Thank you very much.

On Mon, Nov 15, 2021 at 6:30 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
An AMPL indexing expression must have the form "index in set-expr" where index is a name not currently defined, and set-expr is any set-valued expression. Thus, in your objective function, "P in R" is being rejected, because P is already defined (as the name of a set), and also R is not a set-valued expression (since it is the name of a parameter).

I can see that you write "P in R" because you are trying to create an AMPL expression for the following summation in your mathematical description of the objective:
bd8cae4d34a857883ec45aa429a7a82e.png
But it is not standard mathematical notation to have a formula with two ϵ signs in it. Can you explain what this notation means? In particular, what values does p take when it is summed in this way?


--
Robert Fourer
am...@googlegroups.com

CHIN JUN NAN

unread,
Nov 18, 2021, 10:03:51 AM11/18/21
to AMPL Modeling Language

Since I also get it from the research paper, it did not explain in detail, but the variables are given are 
variable.PNG, but I am not sure why suddenly become needed of p in P in Rsm...

Sorry for the confusion...
Thank you.

AMPL Google Group

unread,
Nov 18, 2021, 11:06:38 AM11/18/21
to AMPL Modeling Language
You could consider the following AMPL statements to define the binary (zero-one) variables:

set M;
set D;
set Rs {M};
var sb {m in M, d in D, p in Rs[m]} binary;
var tb {m in M, p in Rs[m]} binary;

Then your objective function could be written like this:

maximize Objective:
   sum {m in M} sum {p in Rs[m]} sum {d in D} (sb[m,d,p] + tb[m,p]);

This still does not explain why "p in P in Rsm" appears in the paper's formulation, but maybe that was an error in printing the paper. (Unfortunately, unlike the user of a computer language such as AMPL, the author of a paper can invent any kind of strange notation or make any sort of formulation mistake without being warned by "syntax error".)


--
Robert Fourer
am...@googlegroups.com
{#HS:1696318300-107158#}
On Thu, Nov 18, 2021 at 3:04 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Since I also get it from the research paper, it did not explain in detail, but the variables are given are
variable.PNG, but I am not sure why suddenly become needed of p in P in Rsm...

Sorry for the confusion...
Thank you.

On Wed, Nov 17, 2021 at 6:17 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
You have given a general description of how p, P, and Rsm relate to your application. However, it is still not clear how the summation indexing expression -- the one with two ϵ signs -- should be interpreted mathematically.

Perhaps you can give an example. For the P and Rsm data shown in your file monitoring.dat, how many p values does
bd8cae4d34a857883ec45aa429a7a82e.png
sum over, and what are those values?


--
Robert Fourer
am...@googlegroups.com

CHIN JUN NAN

unread,
Nov 19, 2021, 8:41:17 AM11/19/21
to AMPL Modeling Language
Thanks, Robert but how should I set the Rs{M} in the data file?

Thank you and Regards.

AMPL Google Group

unread,
Nov 20, 2021, 11:58:30 AM11/20/21
to AMPL Modeling Language
It is just like for Rsm in your file monitoring.dat, except now your set is called Rs and it is indexed over M. The general idea is this:

set M := M1 M2 M3 ;
set Rs[M1] := P1 P2 P3 ;
set Rs[M2] := P2 P4 ;
set Rs[M3] := P5 P3 P2 ;


But note that this is only an example, and you will have to change it to show the correct data for your problem. (There's also an example in the subsection Indexed collections of sets in the AMPL book.)


--
Robert Fourer
am...@googlegroups.com
{#HS:1696318300-107158#}
On Fri, Nov 19, 2021 at 1:41 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Thanks, Robert but how should I set the Rs{M} in the data file?

Thank you and Regards.

On Thu, Nov 18, 2021 at 4:06 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
You could consider the following AMPL statements to define the binary (zero-one) variables:

set M;
set D;
set Rs {M};
var sb {m in M, d in D, p in Rs[m]} binary;
var tb {m in M, p in Rs[m]} binary;

Then your objective function could be written like this:

maximize Objective:
   sum {m in M} sum {p in Rs[m]} sum {d in D} (sb[m,d,p] + tb[m,p]);

This still does not explain why "p in P in Rsm" appears in the paper's formulation, but maybe that was an error in printing the paper. (Unfortunately, unlike the user of a computer language such as AMPL, the author of a paper can invent any kind of strange notation or make any sort of formulation mistake without being warned by "syntax error".)


--
Robert Fourer
am...@googlegroups.com

CHIN JUN NAN

unread,
Nov 21, 2021, 11:01:13 AM11/21/21
to AMPL Modeling Language
Okay, Thank you for your help.
Reply all
Reply to author
Forward
0 new messages