@@ -336,6 +336,18 @@ static int countCostedSlacks(OsiSolverInterface *model)
336
336
void Idiot::crash (int numberPass, CoinMessageHandler *handler,
337
337
const CoinMessages *messages, bool doCrossover)
338
338
{
339
+ // use last digit
340
+ if (numberPass%10 ) {
341
+ lightWeight_=0 ;
342
+ int option = numberPass%10 ;
343
+ numberPass -= option;
344
+ if ((option&1 )!=0 )
345
+ strategy_ |= 1048576 ; // extra bit at end
346
+ if ((option&2 )!=0 )
347
+ strategy_ |= 4194304 ; // limited presolve
348
+ else if ((option&4 )!=0 )
349
+ strategy_ |= 2097152 ; // no presolve
350
+ }
339
351
// lightweight options
340
352
int numberColumns = model_->getNumCols ();
341
353
const double *objective = model_->getObjCoefficients ();
@@ -974,6 +986,12 @@ void Idiot::solve2(CoinMessageHandler *handler, const CoinMessages *messages)
974
986
numberAway = n;
975
987
keepinfeas = result.infeas ;
976
988
lastWeighted = result.weighted ;
989
+ if (iteration == majorIterations_&&(strategy_&1048576 )!=0 ) {
990
+ // do a few more
991
+ mu = std::min (mu,1.0e-11 );
992
+ majorIterations_+=10 ;
993
+ strategy_ &= ~1048576 ; // switch off
994
+ }
977
995
// iterationTotal += result.iteration;
978
996
if (iteration == 1 ) {
979
997
if ((strategy_ & 1024 ) != 0 && mu < 1.0e-10 )
@@ -1305,6 +1323,8 @@ void Idiot::crossOver(int mode)
1305
1323
return ;
1306
1324
}
1307
1325
double fixTolerance = IDIOT_FIX_TOLERANCE;
1326
+ bool wantVector = false ;
1327
+ bool justValuesPass = false ;
1308
1328
#ifdef COIN_DEVELOP
1309
1329
double startTime = CoinCpuTime ();
1310
1330
#endif
@@ -1356,6 +1376,9 @@ void Idiot::crossOver(int mode)
1356
1376
double *saveRowUpper = NULL ;
1357
1377
double *saveRowLower = NULL ;
1358
1378
bool allowInfeasible = ((strategy_ & 8192 ) != 0 ) || (majorIterations_ > 1000000 );
1379
+ ClpSimplex * saveModelX = NULL ;
1380
+ if ((strategy_&(2097152 |4194304 ))!=0 )
1381
+ saveModelX = new ClpSimplex (*model_);
1359
1382
if (addAll < 3 ) {
1360
1383
saveUpper = new double [ncols];
1361
1384
saveLower = new double [ncols];
@@ -1447,6 +1470,7 @@ void Idiot::crossOver(int mode)
1447
1470
// model_->setPerturbation(56);
1448
1471
#endif
1449
1472
model_->createStatus ();
1473
+ if (!saveModelX) {
1450
1474
/* addAll
1451
1475
0 - chosen,all used, all
1452
1476
1 - chosen, all
@@ -1726,7 +1750,7 @@ void Idiot::crossOver(int mode)
1726
1750
} else {
1727
1751
maxmin = 1.0 ;
1728
1752
}
1729
- bool justValuesPass = majorIterations_ > 1000000 ;
1753
+ justValuesPass = majorIterations_ > 1000000 ;
1730
1754
if (slackStart >= 0 ) {
1731
1755
for (i = 0 ; i < nrows; i++) {
1732
1756
model_->setRowStatus (i, ClpSimplex::superBasic);
@@ -1814,7 +1838,6 @@ void Idiot::crossOver(int mode)
1814
1838
}
1815
1839
/* printf("%d in basis\n",ninbas);*/
1816
1840
}
1817
- bool wantVector = false ;
1818
1841
if (dynamic_cast < ClpPackedMatrix * >(model_->clpMatrix ())) {
1819
1842
// See if original wanted vector
1820
1843
ClpPackedMatrix *clpMatrixO = dynamic_cast < ClpPackedMatrix * >(model_->clpMatrix ());
@@ -1825,6 +1848,85 @@ void Idiot::crossOver(int mode)
1825
1848
if ((strategy_ & 65536 ) != 0 )
1826
1849
justValuesPass = true ;
1827
1850
// double * saveBounds=NULL;
1851
+ } else {
1852
+ addAll = 3 ;
1853
+ memcpy (model_->columnLower (),saveModelX->columnLower (),ncols*sizeof (double ));
1854
+ memcpy (model_->columnUpper (),saveModelX->columnUpper (),ncols*sizeof (double ));
1855
+ memcpy (model_->rowLower (),saveModelX->rowLower (),nrows*sizeof (double ));
1856
+ memcpy (model_->rowUpper (),saveModelX->rowUpper (),nrows*sizeof (double ));
1857
+ delete saveModelX;
1858
+ if (strategy_&4194304 ) {
1859
+ int nAway = 0 ;
1860
+ double *away = new double [ncols+nrows];
1861
+ int *choose = new int [ncols+nrows];
1862
+ for (int i=0 ;i<ncols;i++) {
1863
+ if (colsol[i] < lower[i] + fixTolerance) {
1864
+ colsol[i] = lower[i];
1865
+ model_->setColumnStatus (i,ClpSimplex::atLowerBound);
1866
+ } else if (colsol[i] > upper[i] - fixTolerance) {
1867
+ colsol[i] = upper[i];
1868
+ model_->setColumnStatus (i,ClpSimplex::atUpperBound);
1869
+ } else if (lower[i]<-1.0e50 && upper[i]>1.0e50 ) {
1870
+ model_->setColumnStatus (i,ClpSimplex::isFree);
1871
+ away[i] = -1.0e50 ;
1872
+ choose[nAway++] = i;
1873
+ } else {
1874
+ away[i] = -std::min (upper[i]-colsol[i],colsol[i]-lower[i]);
1875
+ model_->setColumnStatus (i, ClpSimplex::superBasic);
1876
+ choose[nAway++] = i;
1877
+ }
1878
+ }
1879
+ for (int i=0 ;i<nrows;i++) {
1880
+ if (rowsol[i] < lower[i] + fixTolerance) {
1881
+ rowsol[i] = lower[i];
1882
+ model_->setRowStatus (i,ClpSimplex::atLowerBound);
1883
+ } else if (rowsol[i] > upper[i] - fixTolerance) {
1884
+ rowsol[i] = upper[i];
1885
+ model_->setRowStatus (i,ClpSimplex::atUpperBound);
1886
+ } else if (lower[i]<-1.0e50 && upper[i]>1.0e50 ) {
1887
+ model_->setRowStatus (i,ClpSimplex::isFree);
1888
+ away[i] = -1.0e50 ;
1889
+ choose[nAway++] = i+ncols;
1890
+ } else {
1891
+ away[i] = -std::min (upper[i]-rowsol[i],rowsol[i]-lower[i]);
1892
+ model_->setRowStatus (i, ClpSimplex::superBasic);
1893
+ choose[nAway++] = i+ncols;
1894
+ }
1895
+ }
1896
+ CoinSort_2 (away, away + nAway, choose);
1897
+ // nAway = std::min(nAway,(3*nrows/4));
1898
+ nAway = std::min (nAway,nrows);
1899
+ for (int i=0 ;i<nAway;i++)
1900
+ model_->setColumnStatus (choose[i],ClpSimplex::basic);
1901
+ delete [] away;
1902
+ delete [] choose;
1903
+ } else {
1904
+ for (int i=0 ;i<ncols;i++) {
1905
+ if (colsol[i] < lower[i] + fixTolerance) {
1906
+ colsol[i] = lower[i];
1907
+ model_->setColumnStatus (i,ClpSimplex::atLowerBound);
1908
+ } else if (colsol[i] > upper[i] - fixTolerance) {
1909
+ colsol[i] = upper[i];
1910
+ model_->setColumnStatus (i,ClpSimplex::atUpperBound);
1911
+ } else if (lower[i]<-1.0e50 && upper[i]>1.0e50 ) {
1912
+ model_->setColumnStatus (i,ClpSimplex::isFree);
1913
+ } else {
1914
+ model_->setColumnStatus (i, ClpSimplex::superBasic);
1915
+ }
1916
+ }
1917
+ for (int i=0 ;i<nrows;i++) {
1918
+ model_->setRowStatus (i,ClpSimplex::basic);
1919
+ }
1920
+ }
1921
+ bool justValuesPass = false ;
1922
+ bool wantVector =true ;
1923
+ matrix = model_->clpMatrix ();
1924
+ ClpPackedMatrix *clpMatrix = dynamic_cast < ClpPackedMatrix * >(matrix);
1925
+ assert (clpMatrix);
1926
+ clpMatrix->makeSpecialColumnCopy ();
1927
+ model_->primal (1 );
1928
+ clpMatrix->releaseSpecialColumnCopy ();
1929
+ }
1828
1930
if (addAll < 3 ) {
1829
1931
ClpPresolve pinfo;
1830
1932
if (presolve) {
@@ -1965,6 +2067,16 @@ void Idiot::crossOver(int mode)
1965
2067
saveModel = model_;
1966
2068
pinfo.setPresolveActions (pinfo.presolveActions () | 16384 );
1967
2069
model_ = pinfo.presolvedModel (*model_, 1.0e-8 , false , 5 );
2070
+ if ((strategy_&4194304 )!=0 ) {
2071
+ if (!model_||model_->numberRows ()>0.8 *saveModel->numberRows ()) {
2072
+ // do not presolve
2073
+ presolve=0 ;
2074
+ delete model_;
2075
+ model_=saveModel;
2076
+ delete [] saveBounds;
2077
+ saveBounds = NULL ;
2078
+ }
2079
+ }
1968
2080
if (saveBounds) {
1969
2081
memcpy (saveModel->columnLower (), saveBounds, ncols * sizeof (double ));
1970
2082
memcpy (saveModel->columnUpper (), saveBounds + ncols, ncols * sizeof (double ));
@@ -2049,11 +2161,13 @@ void Idiot::crossOver(int mode)
2049
2161
delete[] which;
2050
2162
}
2051
2163
}
2164
+ if ((strategy_&(2097152 |4194304 ))==0 ) {
2052
2165
// Maybe presolve did nothing!
2053
2166
if (pinfo.nullPresolve ()) {
2054
2167
delete model_;
2055
2168
model_ = NULL ;
2056
2169
}
2170
+ }
2057
2171
if (model_) {
2058
2172
// See if we want to go all way
2059
2173
int oldSize = 2 * saveModel->numberRows () + saveModel->numberColumns ();
@@ -2160,6 +2274,14 @@ void Idiot::crossOver(int mode)
2160
2274
if (presolve) {
2161
2275
saveModel = model_;
2162
2276
model_ = pinfo.presolvedModel (*model_, 1.0e-8 , false , 5 );
2277
+ if ((strategy_&(2097152 |4194304 ))!=0 ) {
2278
+ if (!model_||(strategy_&2097152 )==0 ||model_->numberRows ()>0.8 *saveModel->numberRows ()) {
2279
+ // do not presolve
2280
+ presolve=0 ;
2281
+ delete model_;
2282
+ model_=saveModel;
2283
+ }
2284
+ }
2163
2285
} else {
2164
2286
presolve = 0 ;
2165
2287
}
@@ -2212,6 +2334,14 @@ void Idiot::crossOver(int mode)
2212
2334
if (presolve) {
2213
2335
saveModel = model_;
2214
2336
model_ = pinfo.presolvedModel (*model_, 1.0e-8 , false , 5 );
2337
+ if ((strategy_&(2097152 |4194304 ))!=0 ) {
2338
+ if (!model_||(strategy_&2097152 )==0 ||model_->numberRows ()>0.8 *saveModel->numberRows ()) {
2339
+ // do not presolve
2340
+ presolve=0 ;
2341
+ delete model_;
2342
+ model_=saveModel;
2343
+ }
2344
+ }
2215
2345
} else {
2216
2346
presolve = 0 ;
2217
2347
}
@@ -2417,5 +2547,3 @@ Idiot::~Idiot()
2417
2547
delete[] whenUsed_;
2418
2548
}
2419
2549
2420
- /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
2421
- */
0 commit comments