lemon/clp.cc
changeset 1207 eba5aa390aca
parent 1205 57abff252556
     1.1 --- a/lemon/clp.cc	Thu Jan 21 08:36:53 2021 +0100
     1.2 +++ b/lemon/clp.cc	Thu Jan 21 18:58:37 2021 +0100
     1.3 @@ -227,14 +227,14 @@
     1.4    }
     1.5  
     1.6    ClpLp::Value ClpLp::_getCoeff(int ix, int jx) const {
     1.7 -    CoinBigIndex begin = _prob->clpMatrix()->getVectorStarts()[ix];
     1.8 -    CoinBigIndex end = begin + _prob->clpMatrix()->getVectorLengths()[ix];
     1.9 +    CoinBigIndex begin = _prob->clpMatrix()->getVectorStarts()[jx];
    1.10 +    CoinBigIndex end = begin + _prob->clpMatrix()->getVectorLengths()[jx];
    1.11  
    1.12      const int* indices = _prob->clpMatrix()->getIndices();
    1.13      const double* elements = _prob->clpMatrix()->getElements();
    1.14  
    1.15 -    const int* it = std::lower_bound(indices + begin, indices + end, jx);
    1.16 -    if (it != indices + end && *it == jx) {
    1.17 +    const int* it = std::lower_bound(indices + begin, indices + end, ix);
    1.18 +    if (it != indices + end && *it == ix) {
    1.19        return elements[it - indices];
    1.20      } else {
    1.21        return 0.0;
    1.22 @@ -461,4 +461,14 @@
    1.23      }
    1.24    }
    1.25  
    1.26 +   void ClpLp::_write(std::string file, std::string format) const
    1.27 +  {
    1.28 +    if(format == "LP")
    1.29 +      _prob->writeLp(file.c_str(), "", 1e-5, 10, 5,
    1.30 +                     sense()==ClpLp::MIN?1:-1,
    1.31 +                     true
    1.32 +                     );
    1.33 +    else throw UnsupportedFormatError(format);
    1.34 +  }
    1.35 + 
    1.36  } //END OF NAMESPACE LEMON