why does card() work?

506 views
Skip to first unread message

Ian Downes

unread,
Nov 10, 2009, 12:45:37 AM11/10/09
to AMPL Modeling Language
I'm not quite sure what I'm doing wrong but card() doesn't work like
I'd expect, could someone please tell me what I'm missing here....

thanks - Ian

[2143][ian@weta:~]$ ampl -v
AMPL Student Version 20090726 (Linux 2.6.25.20-0.4-pae)

[2143][ian@weta:~]$ ampl
ampl: set A = {1..10};
ampl: display A;
set A := 1 2 3 4 5 6 7 8 9 10;

ampl: card(A);

syntax error
context: >>> card( <<< A);
ampl:

Paul

unread,
Nov 10, 2009, 8:41:18 AM11/10/09
to AMPL Modeling Language
There's nothing wrong with the card() function; your last statement is
syntactically incomplete. Try

ampl: display card(A);

or

ampl: param c := card(A);
ampl: display c;

etc.

/Paul

Ian Downes

unread,
Nov 10, 2009, 1:14:47 AM11/10/09
to AMPL Modeling Language
sorry I meant, why doesn't it work as expected?

Paul

unread,
Nov 10, 2009, 11:13:37 AM11/10/09
to AMPL Modeling Language


On Nov 10, 1:14 am, Ian Downes <ian.dow...@gmail.com> wrote:
> sorry I meant, why doesn't it work as expected?
>

I suppose that comes down to what you were expecting. Given a set S,
card(S) returns the cardinality of the set. In what way is that not
as expected?

/Paul

Paul

unread,
Nov 10, 2009, 11:15:15 AM11/10/09
to AMPL Modeling Language
Sorry -- if your last post was just to change the subject line, then
you can ignore this.

Ian Downes

unread,
Nov 10, 2009, 4:01:20 PM11/10/09
to am...@googlegroups.com
Paul,

thanks - I was just getting confused as to what the syntax error was referring to, I'm just getting used to ampl and requiring either a display or an assignment.

Ian


--

You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To post to this group, send email to am...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ampl?hl=.



Reply all
Reply to author
Forward
0 new messages