COIN-OR::LEMON - Graph Library

Ignore:
Timestamp:
02/08/05 18:47:19 (20 years ago)
Author:
marci
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1542
Message:

The pair of setSomeThing function is getSomeThing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/work/marci/lp/lp_solver_base.h

    r1113 r1143  
    172172
    173173  /*! \e
     174    \todo kellenene uj iterable structure bele, mert ez nem az igazi
    174175    \todo A[x,y]-t cserel. Jobboldal, baloldal csere.
    175176    \todo LEKERDEZESEK!!!
     
    202203    IterablePartition<int> col_iter_map;
    203204    /// \e
     205    std::vector<RowIt> int_row_map;
     206    /// \e
     207    std::vector<ColIt> int_col_map;
     208    /// \e
    204209    const int VALID_CLASS;
    205210    /// \e
     
    298303                               const std::vector<std::pair<int, _Value> >& coeffs) = 0;
    299304    /// \e
     305    /// This routine modifies \c coeffs only by the \c push_back method.
     306    virtual void _getRowCoeffs(int i,
     307                               std::vector<std::pair<int, _Value> >& coeffs) = 0;
    300308    virtual void _setColCoeffs(int i,
    301309                               const std::vector<std::pair<int, _Value> >& coeffs) = 0;
     310    /// \e
     311    /// This routine modifies \c coeffs only by the \c push_back method.
     312    virtual void _getColCoeffs(int i,
     313                               std::vector<std::pair<int, _Value> >& coeffs) = 0;
    302314  public:
    303315    /// \e
     
    374386        col_it=col_iter_map.push_back(i, VALID_CLASS);
    375387      }
     388      int_col_map.push_back(col_it);
    376389      return col_it;
    377390    }
     
    387400        row_it=row_iter_map.push_back(i, VALID_CLASS);
    388401      }
     402      int_row_map.push_back(row_it);
    389403      return row_it;
    390404    }
     
    401415        if (col_iter_map[it]>cols[1]) --col_iter_map[it];
    402416      }
     417      int_col_map.erase(int_col_map.begin()+cols[1]);
    403418    }
    404419    /// \e
     
    414429        if (row_iter_map[it]>rows[1]) --row_iter_map[it];
    415430      }
     431      int_row_map.erase(int_row_map.begin()+rows[1]);
    416432    }
    417433    /// \e
     
    510526    }
    511527    /// \e
     528    /// This routine modifies \c expr by only adding to it.
     529    void getRowCoeffs(RowIt row_it, Expression& expr) {
     530      std::vector<std::pair<int, _Value> > row_coeffs;
     531      _getRowCoeffs(row_iter_map[row_it], row_coeffs);
     532      for(typename std::vector<std::pair<int, _Value> >::const_iterator
     533            i=row_coeffs.begin(); i!=row_coeffs.end(); ++i) {
     534        expr+= (*i).second*int_col_map[(*i).first];
     535      }
     536    }
     537    /// \e
    512538    void setColCoeffs(ColIt col_it, const DualExpression& expr) {
    513539      std::vector<std::pair<int, _Value> > col_coeffs;
     
    520546    }
    521547    /// \e
     548    /// This routine modifies \c expr by only adding to it.
     549    void getColCoeffs(ColIt col_it, DualExpression& expr) {
     550      std::vector<std::pair<int, _Value> > col_coeffs;
     551      _getColCoeffs(col_iter_map[col_it], col_coeffs);
     552      for(typename std::vector<std::pair<int, _Value> >::const_iterator
     553            i=col_coeffs.begin(); i!=col_coeffs.end(); ++i) {
     554        expr+= (*i).second*int_row_map[(*i).first];
     555      }
     556    }
     557    /// \e
     558    /// \bug ez igy nem jo
    522559    void setObjCoeffs(const Expression& expr) {
    523560      for(typename Expression::Data::const_iterator i=expr.data.begin();
     
    525562        setObjCoef((*i).first, (*i).second);
    526563      }
     564    }
     565    /// \e
     566    /// This routine modifies \c expr by only adding to it.
     567    void getObjCoeffs(Expression& expr) {
     568      /// FIXME not yet implemented
    527569    }
    528570    //@}
     
    548590    LPGLPK() : Parent(),
    549591                        lp(lpx_create_prob()) {
     592      int_row_map.push_back(RowIt());
     593      int_col_map.push_back(ColIt());
    550594      lpx_set_int_parm(lp, LPX_K_DUAL, 1);
    551595    }
     
    593637        indices[length]=it->first;
    594638        doubles[length]=it->second;
    595 //      std::cout << "  " << indices[length] << " "
    596 //                << doubles[length] << std::endl;
    597       }
    598 //      std::cout << i << " " << length << std::endl;
     639      }
    599640      lpx_set_mat_row(lp, i, length, indices, doubles);
     641      delete [] indices;
     642      delete [] doubles;
     643    }
     644    /// \e
     645    virtual void _getRowCoeffs(int i,
     646                               std::vector<std::pair<int, double> >& coeffs) {
     647      int mem_length=1+colNum();
     648      int* indices = new int[mem_length];
     649      double* doubles = new double[mem_length];
     650      int length=lpx_get_mat_row(lp, i, indices, doubles);
     651      for (int i=1; i<=length; ++i) {
     652        coeffs.push_back(std::make_pair(indices[i], doubles[i]));
     653      }
    600654      delete [] indices;
    601655      delete [] doubles;
     
    615669      }
    616670      lpx_set_mat_col(lp, i, length, indices, doubles);
     671      delete [] indices;
     672      delete [] doubles;
     673    }
     674    /// \e
     675    virtual void _getColCoeffs(int i,
     676                               std::vector<std::pair<int, double> >& coeffs) {
     677      int mem_length=1+rowNum();
     678      int* indices = new int[mem_length];
     679      double* doubles = new double[mem_length];
     680      int length=lpx_get_mat_col(lp, i, indices, doubles);
     681      for (int i=1; i<=length; ++i) {
     682        coeffs.push_back(std::make_pair(indices[i], doubles[i]));
     683      }
    617684      delete [] indices;
    618685      delete [] doubles;
Note: See TracChangeset for help on using the changeset viewer.