[FlopCpp] negative numbers in MP_set and MP_subset and as index to MP_variable? OK or NOK?

Tim Hultberg Tim.Hultberg at eumetsat.int
Wed Nov 25 12:38:43 EST 2009


Dear Peter,
   all "dense" set are implicitly numbered from 0 to N-1 (when declared MP_set S(N)), so when picking elements for subsets negative numbers can not be used - you must add the offset..

Probably things could be improved by changing the interface to insert and to document this issue. (added in the TODO list to look at this but can take a while ..) 
Anyway, I hope you can get your model running without to much fuzz.

It could be considered to implement in flopc++ the possibility to let "dense" sets be declared as MP_set S(MinElem,MaxElem) which might be more elegant in your case.

Cheers, Tim
________________________________________
From: flopcpp-bounces at list.coin-or.org [flopcpp-bounces at list.coin-or.org] On Behalf Of Peter Sels [sels.peter at gmail.com]
Sent: 25 November 2009 13:51
To: flopcpp at list.coin-or.org
Subject: [FlopCpp] negative numbers in MP_set and MP_subset and as index to     MP_variable? OK or NOK?

Hello All,

I am trying to use negative numbers in MP_set and MP_subset.
According to the header files for those, I see int io unsigned int so
I guessed this must be possible...
I used:

const int P=5;
const int R=10;
MP_set pSet(P);
MP_set rPreSet(2*R+1);
MP_subset<1> rSet(rPreSet);
for (int r=-R; r<=+R; r++) {
  rSet.insert(r);
}
MP_subset<2> prSubSet(pSet, rSet);
for (unsigned int p=0; p<P; p++) {
  for (int r=-R; r<=R; r++) {
     prSubSet.insert(p, r);
  }
}

and declared the solver variable array:

MP_variable(prSubSet);

then I solved which went ok I think and read back using:

double b;
for (unsigned int p=0; p<P; p++) {
  for (int r=-R; r<=R; r++) {
     b = bVar.(prSubSet.insert(p, r));
     cout << "b = " << b << endl;
  }
}

All the above compiled and linked. However, running only went
ok up to the point where b is being assigned with the first time r is
negative...

I could solve this problem by adding an offset to the r, such that all
the r indices become positive,
but would like to avoid that extra work. So my question is: is this
still possible with negative r
in this or another way?...

thanks and best regards,

--
Peter

_______________________________________________
FlopCpp mailing list
FlopCpp at list.coin-or.org
http://list.coin-or.org/mailman/listinfo/flopcpp




More information about the FlopCpp mailing list