Changeset 847 for stable/0.4


Ignore:
Timestamp:
May 10, 2012 5:47:30 PM (8 years ago)
Author:
pbelotti
Message:

fixed elimination of terms in affine expressions due to small (<1e-21) coefficient

File:
1 edited

Legend:

Unmodified
Added
Removed
  • stable/0.4/Couenne/src/convex/operators/conv-exprGroup.cpp

    r490 r847  
    245245  lincoeff::iterator el = lcoeff_.begin ();
    246246
    247   for (int i=0; el != lcoeff_.end (); ++el)
     247  nterms = displacement;
     248
     249  for (; el != lcoeff_.end (); ++el)
    248250
    249251    if (fabs (el -> second) > 1.0e-21) {
    250252      // why 1.0e-21? Look at CoinPackedMatrix.cpp:2237
    251253
    252       coeff [i   + displacement] = el -> second;
    253       index [i++ + displacement] = el -> first -> Index ();
     254      coeff [nterms]  = el -> second;
     255      index [nterms++] = el -> first -> Index ();
    254256    }
    255257
     
    264266    }
    265267    else {                        // variable
    266       coeff [++nterms] = 1.;
    267       index   [nterms] = curr -> Index ();
    268     }
    269   }
    270 
    271   cut -> setRow (nterms + displacement, index, coeff);
     268      coeff [nterms]  = 1.;
     269      index [nterms++] = curr -> Index ();
     270    }
     271  }
     272
     273  cut -> setRow (nterms, index, coeff);
    272274
    273275  delete [] index;
Note: See TracChangeset for help on using the changeset viewer.