Changeset 1143:4fb22cfa5759 in lemon0.x for src/work/marci/lp/lp_solver_base.h
 Timestamp:
 02/08/05 18:47:19 (18 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@1542
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/work/marci/lp/lp_solver_base.h
r1113 r1143 172 172 173 173 /*! \e 174 \todo kellenene uj iterable structure bele, mert ez nem az igazi 174 175 \todo A[x,y]t cserel. Jobboldal, baloldal csere. 175 176 \todo LEKERDEZESEK!!! … … 202 203 IterablePartition<int> col_iter_map; 203 204 /// \e 205 std::vector<RowIt> int_row_map; 206 /// \e 207 std::vector<ColIt> int_col_map; 208 /// \e 204 209 const int VALID_CLASS; 205 210 /// \e … … 298 303 const std::vector<std::pair<int, _Value> >& coeffs) = 0; 299 304 /// \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; 300 308 virtual void _setColCoeffs(int i, 301 309 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; 302 314 public: 303 315 /// \e … … 374 386 col_it=col_iter_map.push_back(i, VALID_CLASS); 375 387 } 388 int_col_map.push_back(col_it); 376 389 return col_it; 377 390 } … … 387 400 row_it=row_iter_map.push_back(i, VALID_CLASS); 388 401 } 402 int_row_map.push_back(row_it); 389 403 return row_it; 390 404 } … … 401 415 if (col_iter_map[it]>cols[1]) col_iter_map[it]; 402 416 } 417 int_col_map.erase(int_col_map.begin()+cols[1]); 403 418 } 404 419 /// \e … … 414 429 if (row_iter_map[it]>rows[1]) row_iter_map[it]; 415 430 } 431 int_row_map.erase(int_row_map.begin()+rows[1]); 416 432 } 417 433 /// \e … … 510 526 } 511 527 /// \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 512 538 void setColCoeffs(ColIt col_it, const DualExpression& expr) { 513 539 std::vector<std::pair<int, _Value> > col_coeffs; … … 520 546 } 521 547 /// \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 522 559 void setObjCoeffs(const Expression& expr) { 523 560 for(typename Expression::Data::const_iterator i=expr.data.begin(); … … 525 562 setObjCoef((*i).first, (*i).second); 526 563 } 564 } 565 /// \e 566 /// This routine modifies \c expr by only adding to it. 567 void getObjCoeffs(Expression& expr) { 568 /// FIXME not yet implemented 527 569 } 528 570 //@} … … 548 590 LPGLPK() : Parent(), 549 591 lp(lpx_create_prob()) { 592 int_row_map.push_back(RowIt()); 593 int_col_map.push_back(ColIt()); 550 594 lpx_set_int_parm(lp, LPX_K_DUAL, 1); 551 595 } … … 593 637 indices[length]=it>first; 594 638 doubles[length]=it>second; 595 // std::cout << " " << indices[length] << " " 596 // << doubles[length] << std::endl; 597 } 598 // std::cout << i << " " << length << std::endl; 639 } 599 640 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 } 600 654 delete [] indices; 601 655 delete [] doubles; … … 615 669 } 616 670 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 } 617 684 delete [] indices; 618 685 delete [] doubles;
Note: See TracChangeset
for help on using the changeset viewer.