[FlopCpp] confusing indexing syntax

Tim Hultberg Tim.Hultberg at eumetsat.int
Sun Jan 25 10:11:06 EST 2009


Hi Michael,
   the problem is that the rightmost "0" is ambigious, you have to use a workaround and write the last sentence as

    initZ(j) = Z(j, 0)  == MP_expression(0);

or even

    initZ(j) = Z(j, 0) + 1 == 1;

(that the latter works (i.e with any constant dofferent from 0, but not with 0)  has something to do with a C++ default argument =0 somewhere (I have forgotten the details) and is something which I ought to fix if I'll get get some time)

In flopc++, sets are indices (class inheritance) so you can use them as indices just like in GAMS, by also having the index class you avoid having to use "set aliases" as in GAMS when a single set is indexed more than once. I like this, but of course it can be confusing if you are not used to it.

Cheers Tim

________________________________________
From: flopcpp-bounces at list.coin-or.org [flopcpp-bounces at list.coin-or.org] On Behalf Of Michael Chen [vancouver.michael at gmail.com]
Sent: 22 January 2009 07:40
To: flopcpp at list.coin-or.org
Subject: [FlopCpp] confusing indexing syntax

Hey, there,

I have no clue why this simple one cannot compile:

     MP_set NN(2);
     MP_set T(2);
     MP_variable Z(NN, T);
     Z.binary();

    MP_constraint initZ(NN);
    initZ(j) = Z(j, 0) == 0;

I tried all other possible format of the last sentence, and didn't get any luck.

I also see from the examples, a set name, T, for example, is used for indexing; sometimes, a MP_index variable is used for indexing; sometimes, Link(S,D), is used for indexing, not Link(s,d), where s and d are MP_index variable. I probably get used to AMPL syntax, where only index variable can be used to indexing things. Would anyone give me a rule about indexing syntax? Thanks.

--
Best regards,
Michael Chen




More information about the FlopCpp mailing list