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

Peter Sels sels.peter at gmail.com
Wed Nov 25 07:51:33 EST 2009


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



More information about the FlopCpp mailing list