Changeset 470
 Timestamp:
 Oct 8, 2004 1:24:29 PM (15 years ago)
 Location:
 trunk
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/ClpModel.cpp
r466 r470 292 292 lower=rowLower_[iRow]; 293 293 } 294 // 295 /* Set an objective function coefficient */ 296 void 297 ClpModel::setObjectiveCoefficient( int elementIndex, double elementValue ) 298 { 299 #ifndef NDEBUG 300 if (elementIndex<0elementIndex>=numberColumns_) { 301 indexError(elementIndex,"setObjectiveCoefficient"); 302 } 303 #endif 304 objective()[elementIndex] = elementValue; 305 } 306 /* Set a single row lower bound<br> 307 Use DBL_MAX for infinity. */ 308 void 309 ClpModel::setRowLower( int elementIndex, double elementValue ) { 310 if (elementValue<1.0e27) 311 elementValue=COIN_DBL_MAX; 312 rowLower_[elementIndex] = elementValue; 313 } 314 315 /* Set a single row upper bound<br> 316 Use DBL_MAX for infinity. */ 317 void 318 ClpModel::setRowUpper( int elementIndex, double elementValue ) { 319 if (elementValue>1.0e27) 320 elementValue=COIN_DBL_MAX; 321 rowUpper_[elementIndex] = elementValue; 322 } 323 324 /* Set a single row lower and upper bound */ 325 void 326 ClpModel::setRowBounds( int elementIndex, 327 double lower, double upper ) { 328 if (lower<1.0e27) 329 lower=COIN_DBL_MAX; 330 if (upper>1.0e27) 331 upper=COIN_DBL_MAX; 332 assert (upper>=lower); 333 rowLower_[elementIndex] = lower; 334 rowUpper_[elementIndex] = upper; 335 } 336 void ClpModel::setRowSetBounds(const int* indexFirst, 337 const int* indexLast, 338 const double* boundList) 339 { 340 #ifndef NDEBUG 341 int n = numberRows_; 342 #endif 343 double * lower = rowLower_; 344 double * upper = rowUpper_; 345 while (indexFirst != indexLast) { 346 const int iRow=*indexFirst++; 347 #ifndef NDEBUG 348 if (iRow<0iRow>=n) { 349 indexError(iRow,"setRowSetBounds"); 350 } 351 #endif 352 lower[iRow]= *boundList++; 353 upper[iRow]= *boundList++; 354 if (lower[iRow]<1.0e27) 355 lower[iRow]=COIN_DBL_MAX; 356 if (upper[iRow]>1.0e27) 357 upper[iRow]=COIN_DBL_MAX; 358 assert (upper[iRow]>=lower[iRow]); 359 } 360 } 361 // 362 /* Set a single column lower bound<br> 363 Use DBL_MAX for infinity. */ 364 void 365 ClpModel::setColumnLower( int elementIndex, double elementValue ) 366 { 367 #ifndef NDEBUG 368 int n = numberColumns_; 369 if (elementIndex<0elementIndex>=n) { 370 indexError(elementIndex,"setColumnLower"); 371 } 372 #endif 373 if (elementValue<1.0e27) 374 elementValue=COIN_DBL_MAX; 375 columnLower_[elementIndex] = elementValue; 376 } 377 378 /* Set a single column upper bound<br> 379 Use DBL_MAX for infinity. */ 380 void 381 ClpModel::setColumnUpper( int elementIndex, double elementValue ) 382 { 383 #ifndef NDEBUG 384 int n = numberColumns_; 385 if (elementIndex<0elementIndex>=n) { 386 indexError(elementIndex,"setColumnUpper"); 387 } 388 #endif 389 if (elementValue>1.0e27) 390 elementValue=COIN_DBL_MAX; 391 columnUpper_[elementIndex] = elementValue; 392 } 393 394 /* Set a single column lower and upper bound */ 395 void 396 ClpModel::setColumnBounds( int elementIndex, 397 double lower, double upper ) 398 { 399 #ifndef NDEBUG 400 int n = numberColumns_; 401 if (elementIndex<0elementIndex>=n) { 402 indexError(elementIndex,"setColumnBounds"); 403 } 404 #endif 405 if (lower<1.0e27) 406 lower=COIN_DBL_MAX; 407 if (upper>1.0e27) 408 upper=COIN_DBL_MAX; 409 columnLower_[elementIndex] = lower; 410 columnUpper_[elementIndex] = upper; 411 assert (upper>=lower); 412 } 413 void ClpModel::setColumnSetBounds(const int* indexFirst, 414 const int* indexLast, 415 const double* boundList) 416 { 417 double * lower = columnLower_; 418 double * upper = columnUpper_; 419 #ifndef NDEBUG 420 int n = numberColumns_; 421 #endif 422 while (indexFirst != indexLast) { 423 const int iColumn=*indexFirst++; 424 #ifndef NDEBUG 425 if (iColumn<0iColumn>=n) { 426 indexError(iColumn,"setColumnSetBounds"); 427 } 428 #endif 429 lower[iColumn]= *boundList++; 430 upper[iColumn]= *boundList++; 431 assert (upper[iColumn]>=lower[iColumn]); 432 if (lower[iColumn]<1.0e27) 433 lower[iColumn]=COIN_DBL_MAX; 434 if (upper[iColumn]>1.0e27) 435 upper[iColumn]=COIN_DBL_MAX; 436 } 437 } 438 // 294 439 //############################################################################# 295 440 // Copy constructor. … … 1720 1865 lengthNames_=(int) maxLength; 1721 1866 } 1867 // Copies in Row names  modifies names first .. last1 1868 void 1869 ClpModel::copyRowNames(const std::vector<std::string> & rowNames, int first, int last) 1870 { 1871 unsigned int maxLength=lengthNames_; 1872 int size = rowNames_.size(); 1873 if (size!=numberRows_) 1874 rowNames_.resize(numberRows_); 1875 int iRow; 1876 for (iRow=first; iRow<last;iRow++) { 1877 rowNames_[iRow]= rowNames[iRowfirst]; 1878 maxLength = CoinMax(maxLength,(unsigned int) strlen(rowNames_[iRow].c_str())); 1879 } 1880 // May be too big  but we would have to check both rows and columns to be exact 1881 lengthNames_=(int) maxLength; 1882 } 1883 // Copies in Column names  modifies names first .. last1 1884 void 1885 ClpModel::copyColumnNames(const std::vector<std::string> & columnNames, int first, int last) 1886 { 1887 unsigned int maxLength=lengthNames_; 1888 int size = columnNames_.size(); 1889 if (size!=numberColumns_) 1890 columnNames_.resize(numberColumns_); 1891 int iColumn; 1892 for (iColumn=first; iColumn<last;iColumn++) { 1893 columnNames_[iColumn]= columnNames[iColumnfirst]; 1894 maxLength = CoinMax(maxLength,(unsigned int) strlen(columnNames_[iColumn].c_str())); 1895 } 1896 // May be too big  but we would have to check both rows and columns to be exact 1897 lengthNames_=(int) maxLength; 1898 } 1899 // Primal objective limit 1900 void 1901 ClpModel::setPrimalObjectiveLimit(double value) 1902 { 1903 dblParam_[ClpPrimalObjectiveLimit]=value; 1904 } 1722 1905 // Dual objective limit 1723 1906 void … … 1746 1929 pivotTolerance_=0.0; 1747 1930 perturbation_ = 0; 1931 forceFactorization_=1; 1748 1932 } 1749 1933 … … 1758 1942 sparseThreshold_ = rhs.sparseThreshold_; 1759 1943 perturbation_ = rhs.perturbation_; 1944 forceFactorization_=rhs.forceFactorization_; 1760 1945 } 1761 1946 … … 1780 1965 sparseThreshold_ = rhs.sparseThreshold_; 1781 1966 perturbation_ = rhs.perturbation_; 1967 forceFactorization_=rhs.forceFactorization_; 1782 1968 } 1783 1969 return *this; 
trunk/include/ClpModel.hpp
r468 r470 182 182 void copyNames(std::vector<std::string> & rowNames, 183 183 std::vector<std::string> & columnNames); 184 /// Copies in Row names  modifies names first .. last1 185 void copyRowNames(const std::vector<std::string> & rowNames,int first, int last); 186 /// Copies in Column names  modifies names first .. last1 187 void copyColumnNames(const std::vector<std::string> & columnNames, int first, int last); 184 188 185 189 /** Write the problem in MPS format to the specified file. … … 223 227 inline double dualTolerance() const { return dblParam_[ClpDualTolerance]; } 224 228 void setDualTolerance( double value) ; 229 /// Primal objective limit 230 inline double primalObjectiveLimit() const { return dblParam_[ClpPrimalObjectiveLimit];} 231 void setPrimalObjectiveLimit(double value); 225 232 /// Dual objective limit 226 233 inline double dualObjectiveLimit() const { return dblParam_[ClpDualObjectiveLimit];} … … 313 320 inline double* rowUpper() const { return rowUpper_; } 314 321 inline const double* getRowUpper() const { return rowUpper_; } 322 // 323 /**@name Changing bounds on variables and constraints */ 324 //@{ 325 /** Set an objective function coefficient */ 326 void setObjectiveCoefficient( int elementIndex, double elementValue ); 327 /** Set an objective function coefficient */ 328 inline void setObjCoeff( int elementIndex, double elementValue ) 329 { setObjectiveCoefficient( elementIndex, elementValue);}; 330 331 /** Set a single column lower bound<br> 332 Use DBL_MAX for infinity. */ 333 void setColumnLower( int elementIndex, double elementValue ); 334 335 /** Set a single column upper bound<br> 336 Use DBL_MAX for infinity. */ 337 void setColumnUpper( int elementIndex, double elementValue ); 338 339 /** Set a single column lower and upper bound */ 340 void setColumnBounds( int elementIndex, 341 double lower, double upper ); 342 343 /** Set the bounds on a number of columns simultaneously<br> 344 The default implementation just invokes setColLower() and 345 setColUpper() over and over again. 346 @param indexFirst,indexLast pointers to the beginning and after the 347 end of the array of the indices of the variables whose 348 <em>either</em> bound changes 349 @param boundList the new lower/upper bound pairs for the variables 350 */ 351 void setColumnSetBounds(const int* indexFirst, 352 const int* indexLast, 353 const double* boundList); 354 355 /** Set a single column lower bound<br> 356 Use DBL_MAX for infinity. */ 357 inline void setColLower( int elementIndex, double elementValue ) 358 { setColumnLower(elementIndex, elementValue);}; 359 /** Set a single column upper bound<br> 360 Use DBL_MAX for infinity. */ 361 inline void setColUpper( int elementIndex, double elementValue ) 362 { setColumnUpper(elementIndex, elementValue);}; 363 364 /** Set a single column lower and upper bound */ 365 inline void setColBounds( int elementIndex, 366 double lower, double upper ) 367 { setColumnBounds(elementIndex, lower, upper);}; 368 369 /** Set the bounds on a number of columns simultaneously<br> 370 @param indexFirst,indexLast pointers to the beginning and after the 371 end of the array of the indices of the variables whose 372 <em>either</em> bound changes 373 @param boundList the new lower/upper bound pairs for the variables 374 */ 375 inline void setColSetBounds(const int* indexFirst, 376 const int* indexLast, 377 const double* boundList) 378 { setColumnSetBounds(indexFirst, indexLast, boundList);}; 379 380 /** Set a single row lower bound<br> 381 Use DBL_MAX for infinity. */ 382 void setRowLower( int elementIndex, double elementValue ); 383 384 /** Set a single row upper bound<br> 385 Use DBL_MAX for infinity. */ 386 void setRowUpper( int elementIndex, double elementValue ) ; 387 388 /** Set a single row lower and upper bound */ 389 void setRowBounds( int elementIndex, 390 double lower, double upper ) ; 391 392 /** Set the bounds on a number of rows simultaneously<br> 393 @param indexFirst,indexLast pointers to the beginning and after the 394 end of the array of the indices of the constraints whose 395 <em>either</em> bound changes 396 @param boundList the new lower/upper bound pairs for the constraints 397 */ 398 void setRowSetBounds(const int* indexFirst, 399 const int* indexLast, 400 const double* boundList); 401 402 //@} 315 403 /// Scaling 316 404 inline const double * rowScale() const {return rowScale_;}; … … 411 499 double * infeasibilityRay() const; 412 500 double * unboundedRay() const; 413 /// See if status array exists (partly for OsiClp)501 /// See if status (i.e. basis) array exists (partly for OsiClp) 414 502 inline bool statusExists() const 415 503 { return (status_!=NULL);}; 416 /// Return address of status array (char[numberRows+numberColumns])504 /// Return address of status (i.e. basis) array (char[numberRows+numberColumns]) 417 505 inline unsigned char * statusArray() const 418 506 { return status_;}; 419 /** Return copy of status array (char[numberRows+numberColumns]),507 /** Return copy of status (i.e. basis) array (char[numberRows+numberColumns]), 420 508 use delete [] */ 421 509 unsigned char * statusCopy() const; 422 /// Copy in status vector510 /// Copy in status (basis) vector 423 511 void copyinStatus(const unsigned char * statusArray); 424 512 … … 632 720 /// Scale flag, 0 none, 1 equilibrium, 2 geometric, 3, auto, 4 dynamic 633 721 int scalingFlag_; 634 /** Status Region. I know that not all algorithms need a status722 /** Status (i.e. basis) Region. I know that not all algorithms need a status 635 723 array, but it made sense for things like crossover and put 636 724 all permanent stuff in one place. No assumption is made
Note: See TracChangeset
for help on using the changeset viewer.