Changeset 989 for branches/devel/Clp/src/ClpModel.cpp
 Timestamp:
 Mar 10, 2007 7:05:03 PM (13 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/devel/Clp/src/ClpModel.cpp
r923 r989 76 76 lengthNames_(0), 77 77 numberThreads_(0), 78 specialOptions_(0), 78 79 #ifndef CLP_NO_STD 79 80 defaultHandler_(true), … … 157 158 eventHandler_=NULL; 158 159 whatsChanged_=0; 160 specialOptions_ = 0; 159 161 } 160 162 //############################################################################# … … 674 676 userPointer_ = rhs.userPointer_; 675 677 scalingFlag_ = rhs.scalingFlag_; 678 specialOptions_ = rhs.specialOptions_; 676 679 if (trueCopy) { 677 680 #ifndef CLP_NO_STD … … 706 709 rowUpper_ = ClpCopyOfArray ( rhs.rowUpper_, numberRows_ ); 707 710 columnLower_ = ClpCopyOfArray ( rhs.columnLower_, numberColumns_ ); 711 int scaleLength = ((specialOptions_&131072)==0) ? 1 : 2; 708 712 columnUpper_ = ClpCopyOfArray ( rhs.columnUpper_, numberColumns_ ); 709 rowScale_ = ClpCopyOfArray(rhs.rowScale_,numberRows_ );710 columnScale_ = ClpCopyOfArray(rhs.columnScale_,numberColumns_ );713 rowScale_ = ClpCopyOfArray(rhs.rowScale_,numberRows_*scaleLength); 714 columnScale_ = ClpCopyOfArray(rhs.columnScale_,numberColumns_*scaleLength); 711 715 if (rhs.objective_) 712 716 objective_ = rhs.objective_>clone(); … … 2771 2775 strParam_[ClpProbName] = rhs>strParam_[ClpProbName]; 2772 2776 #endif 2773 2777 specialOptions_ = rhs>specialOptions_; 2774 2778 optimizationDirection_ = rhs>optimizationDirection_; 2775 2779 objectiveValue_=rhs>objectiveValue_; … … 3436 3440 columnScale_ = NULL; 3437 3441 } 3442 void 3443 ClpModel::setSpecialOptions(unsigned int value) 3444 { 3445 specialOptions_=value; 3446 } 3447 /* This creates a coinModel object 3448 */ 3449 CoinModel * 3450 ClpModel::createCoinModel() const 3451 { 3452 CoinModel * coinModel = new CoinModel(); 3453 CoinPackedMatrix matrixByRow; 3454 matrixByRow.reverseOrderedCopyOf(*matrix()); 3455 coinModel>setObjectiveOffset(objectiveOffset()); 3456 coinModel>setProblemName(problemName().c_str()); 3457 3458 // Build by row from scratch 3459 const double * element = matrixByRow.getElements(); 3460 const int * column = matrixByRow.getIndices(); 3461 const CoinBigIndex * rowStart = matrixByRow.getVectorStarts(); 3462 const int * rowLength = matrixByRow.getVectorLengths(); 3463 int i; 3464 for (i=0;i<numberRows_;i++) { 3465 coinModel>addRow(rowLength[i],column+rowStart[i], 3466 element+rowStart[i],rowLower_[i],rowUpper_[i]); 3467 } 3468 // Now do column part 3469 const double * objective = this>objective(); 3470 for (i=0;i<numberColumns_;i++) { 3471 coinModel>setColumnBounds(i,columnLower_[i],columnUpper_[i]); 3472 coinModel>setColumnObjective(i,objective[i]); 3473 } 3474 for ( i=0;i<numberColumns_;i++) { 3475 if (isInteger(i)) 3476 coinModel>setColumnIsInteger(i,true); 3477 } 3478 // do names 3479 for (i=0;i<numberRows_;i++) { 3480 char temp[30]; 3481 strcpy(temp,rowName(i).c_str()); 3482 int length = strlen(temp); 3483 for (int j=0;j<length;j++) { 3484 if (temp[j]=='') 3485 temp[j]='_'; 3486 } 3487 coinModel>setRowName(i,temp); 3488 } 3489 for (i=0;i<numberColumns_;i++) { 3490 char temp[30]; 3491 strcpy(temp,columnName(i).c_str()); 3492 int length = strlen(temp); 3493 for (int j=0;j<length;j++) { 3494 if (temp[j]=='') 3495 temp[j]='_'; 3496 } 3497 coinModel>setColumnName(i,temp); 3498 } 3499 ClpQuadraticObjective * obj = (dynamic_cast< ClpQuadraticObjective*>(objective_)); 3500 if (obj) { 3501 const CoinPackedMatrix * quadObj = obj>quadraticObjective(); 3502 // add in quadratic 3503 const double * element = quadObj>getElements(); 3504 const int * row = quadObj>getIndices(); 3505 const CoinBigIndex * columnStart = quadObj>getVectorStarts(); 3506 const int * columnLength = quadObj>getVectorLengths(); 3507 for (i=0;i<numberColumns_;i++) { 3508 int nels = columnLength[i]; 3509 if (nels) { 3510 CoinBigIndex start = columnStart[i]; 3511 double constant = coinModel>getColumnObjective(i); 3512 char temp[100000]; 3513 char temp2[30]; 3514 sprintf(temp,"%g",constant); 3515 for (CoinBigIndex k=start;k<start+nels;k++) { 3516 int kColumn = row[k]; 3517 double value = element[k]; 3518 #if 1 3519 // ampl gives twice with assumed 0.5 3520 if (kColumn<i) 3521 continue; 3522 else if (kColumn==i) 3523 value *= 0.5; 3524 #endif 3525 if (value==1.0) 3526 sprintf(temp2,"+%s",coinModel>getColumnName(kColumn)); 3527 else if (value==1.0) 3528 sprintf(temp2,"%s",coinModel>getColumnName(kColumn)); 3529 else if (value>0.0) 3530 sprintf(temp2,"+%g*%s",value,coinModel>getColumnName(kColumn)); 3531 else 3532 sprintf(temp2,"%g*%s",value,coinModel>getColumnName(kColumn)); 3533 strcat(temp,temp2); 3534 assert (strlen(temp)<100000); 3535 } 3536 coinModel>setObjective(i,temp); 3537 if (logLevel()>2) 3538 printf("el for objective column %s is %s\n",coinModel>getColumnName(i),temp); 3539 } 3540 } 3541 } 3542 return coinModel; 3543 } 3438 3544 //############################################################################# 3439 3545 // Constructors / Destructor / Assignment
Note: See TracChangeset
for help on using the changeset viewer.