Google OR-Tools: ortools/linear_solver/xpress_interface.cc Source File

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16#include <algorithm>

17#include <clocale>

18#include <fstream>

19#include <istream>

20#include <limits>

21#include <memory>

22#include <mutex>

23#include <numeric>

24#include <string>

25

26#include "absl/strings/numbers.h"

27#include "absl/strings/str_format.h"

32

33#define XPRS_INTEGER 'I'

34#define XPRS_CONTINUOUS 'C'

35

36

37

38

39#define CHECK_STATUS(s) \

40 do { \

41 int const status_ = s; \

42 CHECK_EQ(0, status_); \

43 } while (0)

44

47

48

49 int version;

51 return "XPRESS library version unknown";

52

53 int const major = version / 100;

54 version -= major * 100;

55 int const release = version;

56

57 return absl::StrFormat("XPRESS library version %d.%02d", major, release);

58}

59

60

62 std::string const& value) {

63

64 if (!value.size()) {

65 LOG(DFATAL) << "Empty value for parameter '" << name << "' in "

67 return false;

68 }

69

70

71 int id, type;

74 LOG(DFATAL) << "Unknown parameter '" << name << "' in "

76 return false;

77 }

78

79

80 std::stringstream v(value);

81 v.imbue(std::locale("C"));

82 switch (type) {

84 int i;

85 v >> i;

86 if (!v.eof()) {

87 LOG(DFATAL) << "Failed to parse value '" << value

88 << "' for int parameter '" << name << "' in "

90 return false;

91 }

93 LOG(DFATAL) << "Failed to set int parameter '" << name << "' to "

95 return false;

96 }

97 } break;

100 v >> i;

101 if (!v.eof()) {

102 LOG(DFATAL) << "Failed to parse value '" << value

103 << "' for int64_t parameter '" << name << "' in "

105 return false;

106 }

108 LOG(DFATAL) << "Failed to set int64_t parameter '" << name << "' to "

110 return false;

111 }

112 } break;

114 double d;

115 v >> d;

116 if (!v.eof()) {

117 LOG(DFATAL) << "Failed to parse value '" << value

118 << "' for dbl parameter '" << name << "' in "

120 return false;

121 }

123 LOG(DFATAL) << "Failed to set double parameter '" << name << "' to "

125 return false;

126 }

127 } break;

128 default:

129

130

131 LOG(DFATAL) << "Unsupported parameter type " << type << " for parameter '"

133 return false;

134 }

135

136 return true;

137}

138

140 char errmsg[512];

142 VLOG(0) << absl::StrFormat("Function line %d did not execute correctly: %s\n",

143 line, errmsg);

144 exit(0);

145}

146

148

149

150

151

152

153

154

155

156

158 int nMsgLvl);

159

161 int nCols = 0;

163 return nCols;

164}

165

167 int nRows = 0;

169 return nRows;

170}

171

173 int nIters = 0;

175 return nIters;

176}

177

179 int nNodes = 0;

181 return nNodes;

182}

183

185

186 static int indexes[1] = {-1};

187 double values[1] = {-value};

189 return 0;

190}

191

193 const int colind[]) {

194

195

196 if (int status = XPRSaddmipsol(mLp, length, solval, colind, NULL)) {

197 LOG(WARNING) << "Failed to set solution hint.";

198 }

199}

200

202

207

208

209

210#if !defined(XPRS_NAN)

211#define XPRS_NAN std::numeric_limits<double>::quiet_NaN()

212#endif

213

214using std::unique_ptr;

215

218

219 public:

221 int num_nodes)

222 : xprsprob_(xprsprob),

223 event_(event),

224 num_nodes_(num_nodes),

225 variable_values_(0) {};

226

227

232 LOG(WARNING) << "AddCut is not implemented yet in XPRESS interface";

233 };

235 LOG(WARNING) << "AddLazyConstraint inside Callback is not implemented yet "

236 "in XPRESS interface";

237 };

239 const absl::flat_hash_map<const MPVariable*, double>& solution) override;

241

242

243

244

246

247 private:

250 std::vector<double>

251 variable_values_;

252 int num_nodes_;

253};

254

255

257 public:

260

261

262

263

265 exceptions_mutex_.lock();

266 caught_exceptions_.push_back(std::current_exception());

268 exceptions_mutex_.unlock();

269 }

271 exceptions_mutex_.lock();

272 for (const std::exception_ptr& ex : caught_exceptions_) {

273 try {

274 std::rethrow_exception(ex);

275 } catch (std::exception& ex) {

276

277

278

279

280 LOG(ERROR) << "Caught exception during user-defined call-back: "

281 << ex.what();

282 }

283 }

284 caught_exceptions_.clear();

285 exceptions_mutex_.unlock();

286 };

287

288 private:

290 std::vector<std::exception_ptr> caught_exceptions_;

291 std::mutex exceptions_mutex_;

292};

293

294

295

296

297

298

300 public:

301

302

303

306

307

309

310

311

313

314

315 void Write(const std::string& filename) override;

316

317

318

319 void Reset() override;

320

321 void SetVariableBounds(int var_index, double lb, double ub) override;

324

328 double new_value, double old_value) override;

329

330

332

334 double coefficient) override;

335

337

339

340

341

343

344 virtual int64_t nodes() const;

345

346

348

350

351

352

353

354

355

357 bool IsLP() const override { return !mMip; }

358 bool IsMIP() const override { return mMip; }

359

361 const std::vector<MPSolver::BasisStatus>& variable_statuses,

362 const std::vector<MPSolver::BasisStatus>& constraint_statuses) override;

363

367

369

371

374 LOG(DFATAL) << "ComputeExactConditionNumber not implemented for"

375 << " XPRESS_MIXED_INTEGER_PROGRAMMING";

376 return 0.0;

377 }

378

379

380 LOG(DFATAL) << "ComputeExactConditionNumber not implemented for"

381 << " XPRESS_LINEAR_PROGRAMMING";

382 return 0.0;

383 }

384

387

392

393 protected:

394

396

403

406

407 private:

408

409

410

411 void InvalidateModelSynchronization() {

412 mCstat.clear();

413 mRstat.clear();

415 }

416

417

418

419 void AddSolutionHintToOptimizer();

420

421 bool readParameters(std::istream& is, char sep);

422

423 private:

425 bool const mMip;

426

427

428

429

430 absl::btree_map<int, std::map<int, double> >

431 fixedOrderCoefficientsPerConstraint;

432

433

434

435

436

437

438

439

440

441

442

443

444 bool const supportIncrementalExtraction;

445

446

447

448

449

450

451 enum SlowUpdates {

452 SlowSetCoefficient = 0x0001,

453 SlowClearConstraint = 0x0002,

454 SlowSetObjectiveCoefficient = 0x0004,

455 SlowClearObjective = 0x0008,

456 SlowSetConstraintBounds = 0x0010,

457 SlowSetVariableInteger = 0x0020,

458 SlowSetVariableBounds = 0x0040,

459 SlowUpdatesAll = 0xffff

460 } const slowUpdates;

461

462

463

464

465

466

467 std::vector<int> mutable mCstat;

468 std::vector<int> mutable mRstat;

469

470 std::vector<int> mutable initial_variables_basis_status_;

471 std::vector<int> mutable initial_constraint_basis_status_;

472

473

474 static void MakeRhs(double lb, double ub, double& rhs, char& sense,

475 double& range);

476

477 std::map<std::string, int>& mapStringControls_;

478 std::map<std::string, int>& mapDoubleControls_;

479 std::map<std::string, int>& mapIntegerControls_;

480 std::map<std::string, int>& mapInteger64Controls_;

481

482 bool SetSolverSpecificParametersAsString(

483 const std::string& parameters) override;

484 MPCallback* callback_ = nullptr;

485};

486

487

490

492 int xpress_basis_status);

493

495 static std::map<std::string, int> mapControls = {

505 };

506 return mapControls;

507}

508

510 static std::map<std::string, int> mapControls = {

590 };

591 return mapControls;

592}

593

595 static std::map<std::string, int> mapControls = {

827 };

828 return mapControls;

829}

830

832 static std::map<std::string, int> mapControls = {

835 };

836 return mapControls;

837}

838

839

842 mLp(nullptr),

843 mMip(mip),

844 supportIncrementalExtraction(false),

845 slowUpdates(SlowClearObjective),

851 CHECK(correctlyLoaded);

854 DCHECK(mLp != nullptr);

858}

859

864

866

867

868 int version = 0;

870

871 int const major = version / 1000000;

872 version -= major * 1000000;

873 int const release = version / 10000;

874 version -= release * 10000;

875 int const mod = version / 100;

876 version -= mod * 100;

877 int const fix = version;

878

879 return absl::StrFormat("XPRESS library version %d.%02d.%02d.%02d", major,

880 release, mod, fix);

881}

882

883

884

887 std::vector<int> rows(nRows);

888 std::iota(rows.begin(), rows.end(), 0);

890 std::vector<int> cols(nCols);

891 std::iota(cols.begin(), cols.end(), 0);

896 mCstat.clear();

897 mRstat.clear();

898}

899

904

907

908

909

910

911

912

913

914 if (!supportIncrementalExtraction && !(slowUpdates & SlowSetVariableBounds)) {

915 InvalidateModelSynchronization();

916 } else {

918

919

921 char const lu[2] = {'L', 'U'};

922 double const bd[2] = {lb, ub};

923 int const idx[2] = {var_index, var_index};

925 } else {

926

927

928 InvalidateModelSynchronization();

929 }

930 }

931}

932

933

936

937

938

939

940

941

942

943

944

945

946

947 if (!supportIncrementalExtraction &&

948 !(slowUpdates & SlowSetVariableInteger)) {

949 InvalidateModelSynchronization();

950 } else {

951 if (mMip) {

953

954

955

956 DCHECK_LE(var_index, getnumcols(mLp));

959 } else {

960 InvalidateModelSynchronization();

961 }

962 } else {

963 LOG(DFATAL)

964 << "Attempt to change variable to integer in non-MIP problem!";

965 }

966 }

967}

968

969

970void XpressInterface::MakeRhs(double lb, double ub, double& rhs, char& sense,

971 double& range) {

972 if (lb == ub) {

973

974 rhs = lb;

975 range = 0.0;

976 sense = 'E';

978

979

980

981

982

983 if (lb > ub) {

984

985 LOG(DFATAL) << "XPRESS does not support contradictory bounds on range "

986 "constraints! ["

987 << lb << ", " << ub << "] will be converted to " << ub << ", "

988 << (ub - std::abs(ub - lb)) << "]";

989 }

990 rhs = ub;

991 range = std::abs(ub - lb);

992 sense = 'R';

995

996 rhs = ub;

997 range = 0.0;

998 sense = 'L';

1001

1002 rhs = lb;

1003 range = 0.0;

1004 sense = 'G';

1005 } else {

1006

1007

1008

1009

1010

1011

1014 if (std::abs(lb) < std::abs(ub))

1015 rhs = lb;

1016 else

1017 rhs = ub;

1018 range = 0.0;

1019 sense = 'N';

1020 }

1021}

1022

1025

1026

1027

1028

1029

1030

1031

1032 if (!supportIncrementalExtraction &&

1033 !(slowUpdates & SlowSetConstraintBounds)) {

1034 InvalidateModelSynchronization();

1035 } else {

1037

1038

1039 DCHECK(mLp != nullptr);

1040 char sense;

1041 double range, rhs;

1042 MakeRhs(lb, ub, rhs, sense, range);

1043 if (sense == 'R') {

1044

1045

1046

1050 } else {

1053 }

1054 } else {

1055

1056

1057 InvalidateModelSynchronization();

1058 }

1059 }

1060}

1061

1063

1064

1065

1066

1067

1068

1069

1070

1071

1072

1073 InvalidateModelSynchronization();

1074}

1075

1077

1078

1079

1080

1081

1082

1083

1084

1085

1086

1087

1088

1089 InvalidateModelSynchronization();

1090}

1091

1094 double new_value, double) {

1096

1097 fixedOrderCoefficientsPerConstraint[constraint->index()][variable->index()] =

1098 new_value;

1099

1100

1101

1102

1103

1104

1105

1106

1107 if (!supportIncrementalExtraction && !(slowUpdates & SlowSetCoefficient)) {

1108 InvalidateModelSynchronization();

1109 } else {

1110 int const row = constraint->index();

1111 int const col = variable->index();

1113

1114

1118 } else {

1119

1120

1121 InvalidateModelSynchronization();

1122 }

1123 }

1124}

1125

1127 int const row = constraint->index();

1129

1130 return;

1131

1132 fixedOrderCoefficientsPerConstraint.erase(constraint->index());

1133

1134

1135

1136

1137

1138

1139

1140

1141

1142 if (!(slowUpdates & SlowClearConstraint)) {

1143 InvalidateModelSynchronization();

1144 } else {

1146

1147 int const len = constraint->coefficients_.size();

1148 unique_ptr<int[]> rowind(new int[len]);

1149 unique_ptr<int[]> colind(new int[len]);

1150 unique_ptr<double[]> val(new double[len]);

1151 int j = 0;

1152 const auto& coeffs = constraint->coefficients_;

1153 for (auto coeff : coeffs) {

1154 int const col = coeff.first->index();

1156 rowind[j] = row;

1157 colind[j] = col;

1158 val[j] = 0.0;

1159 ++j;

1160 }

1161 }

1162 if (j)

1164 }

1165}

1166

1168 double coefficient) {

1169 int const col = variable->index();

1171

1172 return;

1173

1175

1176

1177

1178

1179

1180

1181

1182 if (supportIncrementalExtraction ||

1183 (slowUpdates & SlowSetObjectiveCoefficient)) {

1185 } else {

1186 InvalidateModelSynchronization();

1187 }

1188}

1189

1195

1198

1199

1200

1201

1202

1203

1204 if (supportIncrementalExtraction || (slowUpdates & SlowClearObjective)) {

1206 unique_ptr<int[]> ind(new int[cols]);

1207 unique_ptr<double[]> zero(new double[cols]);

1208 int j = 0;

1209 const auto& coeffs = solver_->objective_->coefficients_;

1210 for (auto coeff : coeffs) {

1211 int const idx = coeff.first->index();

1212

1214 DCHECK_LT(idx, cols);

1215 ind[j] = idx;

1216 zero[j] = 0.0;

1217 ++j;

1218 }

1219 }

1220 if (j > 0) {

1222 }

1224 } else {

1225 InvalidateModelSynchronization();

1226 }

1227}

1228

1229

1230

1233 return static_cast<int64_t>(getitcnt(mLp));

1234}

1235

1237 if (mMip) {

1239 return static_cast<int64_t>(getnodecnt(mLp));

1240 } else {

1241 LOG(DFATAL) << "Number of nodes only available for discrete problems";

1243 }

1244}

1245

1246

1248 int xpress_basis_status) {

1249 switch (xpress_basis_status) {

1258 default:

1259 LOG(DFATAL) << "Unknown XPRESS basis status";

1261 }

1262}

1263

1266 switch (mpsolver_basis_status) {

1277 default:

1278 LOG(DFATAL) << "Unknown MPSolver basis status";

1280 }

1281}

1282

1283

1285 if (mMip) {

1286 LOG(FATAL) << "Basis status only available for continuous problems";

1288 }

1289

1291 if (mRstat.empty()) {

1293 mRstat.resize(rows);

1295 }

1296 } else {

1297 mRstat.clear();

1298 }

1299

1300 if (!mRstat.empty()) {

1302 } else {

1303 LOG(FATAL) << "Row basis status not available";

1305 }

1306}

1307

1308

1310 if (mMip) {

1311 LOG(FATAL) << "Basis status only available for continuous problems";

1313 }

1314

1316 if (mCstat.empty()) {

1318 mCstat.resize(cols);

1320 }

1321 } else {

1322 mCstat.clear();

1323 }

1324

1325 if (!mCstat.empty()) {

1327 } else {

1328 LOG(FATAL) << "Column basis status not available";

1330 }

1331}

1332

1333

1335

1336

1337

1339

1340 if (!supportIncrementalExtraction) {

1341

1342

1347 }

1348

1350 int const var_count = solver_->variables_.size();

1351 int new_col_count = var_count - last_extracted;

1352 if (new_col_count > 0) {

1353

1354

1355 unique_ptr<double[]> obj(new double[new_col_count]);

1356 unique_ptr<double[]> lb(new double[new_col_count]);

1357 unique_ptr<double[]> ub(new double[new_col_count]);

1358 unique_ptr<char[]> ctype(new char[new_col_count]);

1359

1360 for (int j = 0, var_idx = last_extracted; j < new_col_count;

1361 ++j, ++var_idx) {

1363 lb[j] = var->lb();

1364 ub[j] = var->ub();

1366 obj[j] = solver_->objective_->GetCoefficient(var);

1367 }

1368

1369

1370

1371

1372

1373

1374 std::vector<MPVariable*> const& variables = solver_->variables();

1375 for (int j = last_extracted; j < var_count; ++j) {

1378 }

1379

1380 try {

1381 bool use_new_cols = true;

1382

1383 if (supportIncrementalExtraction) {

1384

1385

1386

1387

1388

1389

1390

1391

1392 unique_ptr<int[]> collen(new int[new_col_count]);

1393 for (int j = 0; j < new_col_count; ++j) collen[j] = 0;

1394 int nonzeros = 0;

1395

1396

1400 const auto& coeffs = ct->coefficients_;

1401 for (auto coeff : coeffs) {

1402 int const idx = coeff.first->index();

1405 ++nonzeros;

1406 }

1407 }

1408 }

1409

1410 if (nonzeros > 0) {

1411

1412

1413

1414 use_new_cols = false;

1415 unique_ptr<int[]> begin(new int[new_col_count + 2]);

1416 unique_ptr<int[]> cmatind(new int[nonzeros]);

1417 unique_ptr<double[]> cmatval(new double[nonzeros]);

1418

1419

1420

1421

1422

1423

1424

1425

1426

1427

1428 int* cmatbeg = begin.get();

1429 cmatbeg[0] = 0;

1430 cmatbeg[1] = 0;

1431 ++cmatbeg;

1432 for (int j = 0; j < new_col_count; ++j)

1433 cmatbeg[j + 1] = cmatbeg[j] + collen[j];

1434

1437 int const row = ct->index();

1438 const auto& coeffs = ct->coefficients_;

1439 for (auto coeff : coeffs) {

1440 int const idx = coeff.first->index();

1442 int const nz = cmatbeg[idx]++;

1443 cmatind[nz] = row;

1444 cmatval[nz] = coeff.second;

1445 }

1446 }

1447 }

1448 --cmatbeg;

1450 cmatbeg, cmatind.get(), cmatval.get(),

1451 lb.get(), ub.get()));

1452 }

1453 }

1454

1455 if (use_new_cols) {

1456

1457

1458

1459 std::vector<int> collen(new_col_count, 0);

1460 std::vector<int> cmatbeg(new_col_count, 0);

1461 unique_ptr<int[]> cmatind(new int[1]);

1462 unique_ptr<double[]> cmatval(new double[1]);

1463 cmatind[0] = 0;

1464 cmatval[0] = 1.0;

1465

1467 cmatbeg.data(), cmatind.get(), cmatval.get(),

1468 lb.get(), ub.get()));

1469

1471 unique_ptr<int[]> ind(new int[new_col_count]);

1472 for (int j = 0; j < cols; ++j) ind[j] = j;

1474 XPRSchgcoltype(mLp, cols - last_extracted, ind.get(), ctype.get()));

1475

1476 } else {

1477

1478

1479

1481

1482

1484 unique_ptr<int[]> ind(new int[new_col_count]);

1485 for (int j = last_extracted; j < cols; ++j)

1486 ind[j - last_extracted] = j;

1488 ctype.get()));

1489 }

1490 }

1491 } catch (...) {

1492

1494 if (cols > last_extracted) {

1495 std::vector<int> cols_to_delete;

1496 for (int i = last_extracted; i < cols; ++i) cols_to_delete.push_back(i);

1497 (void)XPRSdelcols(mLp, cols_to_delete.size(), cols_to_delete.data());

1498 }

1499 std::vector<MPVariable*> const& variables = solver_->variables();

1500 int const size = variables.size();

1501 for (int j = last_extracted; j < size; ++j)

1503 throw;

1504 }

1505 }

1506}

1507

1508

1510

1511

1512 if (!supportIncrementalExtraction) {

1513

1514

1519 }

1520

1522 int const total = solver_->constraints_.size();

1523

1524 if (total > offset) {

1525

1526

1528

1529 int newCons = total - offset;

1531 int const chunk = newCons;

1532

1533

1534

1536

1537 try {

1538 unique_ptr<int[]> rmatind(new int[cols]);

1539 unique_ptr<double[]> rmatval(new double[cols]);

1540 unique_ptr<int[]> rmatbeg(new int[chunk]);

1541 unique_ptr<char[]> sense(new char[chunk]);

1542 unique_ptr<double[]> rhs(new double[chunk]);

1543 unique_ptr<double[]> rngval(new double[chunk]);

1544 std::vector<int> delayedRows;

1545

1546

1547

1548 for (int c = 0; c < newCons; ) {

1549

1550 int nextRow = 0;

1551 int nextNz = 0;

1552 for (; c < newCons && nextRow < chunk; ++c, ++nextRow) {

1554

1555

1556

1557 if (nextNz + ct->coefficients_.size() > cols) {

1558 DCHECK_GT(nextRow, 0);

1559 break;

1560 }

1561

1562

1563 MakeRhs(ct->lb(), ct->ub(), rhs[nextRow], sense[nextRow],

1564 rngval[nextRow]);

1565

1566

1567 rmatbeg[nextRow] = nextNz;

1568 const auto& coeffs = fixedOrderCoefficientsPerConstraint[ct->index()];

1569 for (auto [idx, coeff] : coeffs) {

1571 DCHECK_LT(nextNz, cols);

1572 DCHECK_LT(idx, cols);

1573 rmatind[nextNz] = idx;

1574 rmatval[nextNz] = coeff;

1575 ++nextNz;

1576 }

1577 }

1579 delayedRows.push_back(offset + c);

1580 }

1581 }

1582 if (nextRow > 0) {

1584 rngval.get(), rmatbeg.get(), rmatind.get(),

1585 rmatval.get()));

1586 }

1587 if (!delayedRows.empty()) {

1589 mLp, static_cast<int>(delayedRows.size()), delayedRows.data()));

1590 }

1591 }

1592 } catch (...) {

1593

1595 std::vector<int> rows_to_delete;

1596 for (int i = offset; i < rows; ++i) rows_to_delete.push_back(i);

1597 if (rows > offset)

1598 (void)XPRSdelrows(mLp, rows_to_delete.size(), rows_to_delete.data());

1599 std::vector<MPConstraint*> const& constraints = solver_->constraints();

1600 int const size = constraints.size();

1602 throw;

1603 }

1604 }

1605}

1606

1607

1609

1610

1611

1613

1614

1615 unique_ptr<int[]> ind(new int[cols]);

1616 unique_ptr<double[]> val(new double[cols]);

1617 for (int j = 0; j < cols; ++j) {

1618 ind[j] = j;

1619 val[j] = 0.0;

1620 }

1621

1622 const auto& coeffs = solver_->objective_->coefficients_;

1623 for (auto coeff : coeffs) {

1624 int const idx = coeff.first->index();

1626 DCHECK_LT(idx, cols);

1627 val[idx] = coeff.second;

1628 }

1629 }

1630

1633}

1634

1635

1636

1642

1644 if (mMip) {

1646 } else {

1647 LOG(WARNING) << "The relative MIP gap is only available "

1648 << "for discrete problems.";

1649 }

1650}

1651

1655

1659

1662

1663 switch (presolve) {

1666 return;

1669 return;

1670 }

1672}

1673

1674

1677

1678 switch (scaling) {

1681 break;

1684

1685

1686

1687

1688 break;

1689 }

1690}

1691

1692

1693

1695 auto const algorithm =

1697

1698 int alg = 1;

1699

1700 switch (algorithm) {

1702 alg = 2;

1703 break;

1705 alg = 3;

1706 break;

1708 alg = 4;

1709 break;

1710 }

1711

1714 } else {

1716 }

1717}

1719 const std::vector<MPSolver::BasisStatus>& statuses) {

1720 std::vector<int> result;

1721 result.resize(statuses.size());

1722 std::transform(statuses.cbegin(), statuses.cend(), result.begin(),

1724 return result;

1725}

1726

1728 const std::vector<MPSolver::BasisStatus>& variable_statuses,

1729 const std::vector<MPSolver::BasisStatus>& constraint_statuses) {

1730 if (mMip) {

1731 LOG(DFATAL) << __FUNCTION__ << " is only available for LP problems";

1732 return;

1733 }

1735 initial_constraint_basis_status_ =

1737}

1738

1739bool XpressInterface::readParameters(std::istream& is, char sep) {

1740

1741

1742

1743

1744

1745 std::string name(""), value("");

1746 bool inValue = false;

1747

1748 while (is) {

1749 int c = is.get();

1750 if (is.eof()) break;

1751 if (c == '=') {

1752 if (inValue) {

1753 LOG(DFATAL) << "Failed to parse parameters in " << SolverVersion();

1754 return false;

1755 }

1756 inValue = true;

1757 } else if (c == sep) {

1758

1759 if (name.size() == 0 && value.size() == 0) {

1760

1761 continue;

1762 } else if (name.size() == 0) {

1763 LOG(DFATAL) << "Parameter setting without name in " << SolverVersion();

1765 return false;

1766

1767

1768 name = "";

1769 value = "";

1770 inValue = false;

1771 } else if (std::isspace(c)) {

1772 continue;

1773 } else if (inValue) {

1774 value += (char)c;

1775 } else {

1776 name += (char)c;

1777 }

1778 }

1779 if (inValue) return readParameter(mLp, name, value);

1780

1781 return true;

1782}

1783

1785

1786 std::ifstream s(filename);

1787 if (!s) return false;

1788 return readParameters(s, '\n');

1789}

1790

1792 return ".prm";

1793}

1794

1796 int status;

1797

1798

1799 mCstat.clear();

1800 mRstat.clear();

1801

1804

1805

1808 switch (inc) {

1810 Reset();

1811

1812 break;

1813 }

1816 break;

1817 }

1818 }

1819

1820

1821

1822

1823

1824

1827 VLOG(1) << absl::StrFormat("Model build in %.3f seconds.", timer.Get());

1828

1829

1831

1832

1833

1834

1835

1836

1837

1839 solver_->SetSolverSpecificParametersAsString(

1840 solver_->solver_specific_parameter_string_);

1841 if (solver_->time_limit()) {

1842 VLOG(1) << "Setting time limit = " << solver_->time_limit() << " ms.";

1843

1844

1846 -1 * solver_->time_limit_in_secs()));

1847 }

1848

1849

1850

1851 if (!mMip && !initial_variables_basis_status_.empty() &&

1852 !initial_constraint_basis_status_.empty()) {

1854 initial_variables_basis_status_.data()));

1855 }

1856

1857

1858 this->AddSolutionHintToOptimizer();

1859

1860

1861

1863 if (callback_ != nullptr) {

1866 static_cast<void*>(mp_callback_wrapper), 0));

1867 }

1868

1869

1870

1871

1873

1874 int xpress_stat = 0;

1875 if (mMip) {

1878 } else {

1881 }

1882

1883 if (mp_callback_wrapper != nullptr) {

1885 delete mp_callback_wrapper;

1886 }

1887

1891 }

1892

1893

1895

1896 if (status) {

1897 VLOG(1) << absl::StrFormat("Failed to optimize MIP. Error %d", status);

1898

1899

1900 } else {

1901 VLOG(1) << absl::StrFormat("Solved in %.3f seconds.", timer.Get());

1902 }

1903

1904 VLOG(1) << absl::StrFormat("XPRESS solution status %d.", xpress_stat);

1905

1906

1907 bool const feasible = (mMip ? (xpress_stat == XPRS_MIP_OPTIMAL ||

1910

1911

1914 DCHECK_EQ(rows, solver_->constraints_.size());

1915 DCHECK_EQ(cols, solver_->variables_.size());

1916

1917

1920 if (feasible) {

1921 if (mMip) {

1925 } else {

1927 }

1928 }

1931

1932

1933 if (mMip) {

1934

1935 if (feasible) {

1936 if (cols > 0) {

1937 unique_ptr<double[]> x(new double[cols]);

1939 for (int i = 0; i < solver_->variables_.size(); ++i) {

1942 VLOG(3) << var->name() << ": value =" << x[i];

1943 }

1944 }

1945 } else {

1946 for (auto& variable : solver_->variables_)

1948 }

1949

1950

1951 for (auto& variable : solver_->variables_)

1953 for (auto& constraint : solver_->constraints_)

1955 } else {

1956

1957 if (cols > 0) {

1958 unique_ptr<double[]> x(new double[cols]);

1959 unique_ptr<double[]> dj(new double[cols]);

1961 for (int i = 0; i < solver_->variables_.size(); ++i) {

1964 bool value = false, dual = false;

1965

1966 if (feasible) {

1968 value = true;

1969 } else {

1971 }

1972 if (feasible) {

1974 dual = true;

1975 } else {

1977 }

1978 VLOG(3) << var->name() << ":"

1979 << (value ? absl::StrFormat(" value = %f", x[i]) : "")

1980 << (dual ? absl::StrFormat(" reduced cost = %f", dj[i]) : "");

1981 }

1982 }

1983

1984 if (rows > 0) {

1985 unique_ptr<double[]> pi(new double[rows]);

1986 if (feasible) {

1988 }

1989 for (int i = 0; i < solver_->constraints_.size(); ++i) {

1991 bool dual = false;

1992 if (feasible) {

1994 dual = true;

1995 } else {

1997 }

1998 VLOG(4) << "row " << ct->index() << ":"

1999 << (dual ? absl::StrFormat(" dual = %f", pi[i]) : "");

2000 }

2001 }

2002 }

2003

2004

2005 if (mMip) {

2006 switch (xpress_stat) {

2009 break;

2012 break;

2015 break;

2016 default:

2018 break;

2019 }

2020 } else {

2021 switch (xpress_stat) {

2024 break;

2027 break;

2030 break;

2031 default:

2033 break;

2034 }

2035 }

2036

2039}

2040

2041namespace {

2042template <class T>

2043struct getNameFlag;

2044

2045template <>

2048};

2049

2050template <>

2053};

2054

2055template <class T>

2056

2057

2058void ExtractNames(XPRSprob mLp, const std::vector<T*>& objects) {

2059 const bool have_names =

2060 std::any_of(objects.begin(), objects.end(),

2061 [](const T* x) { return !x->name().empty(); });

2062

2063

2064

2065

2066

2067 if (have_names) {

2068 std::vector<char> all_names;

2069 for (const auto& x : objects) {

2070 const std::string& current_name = x->name();

2071 std::copy(current_name.begin(), current_name.end(),

2072 std::back_inserter(all_names));

2073 all_names.push_back('\0');

2074 }

2075

2076

2077

2078 if (!all_names.empty() && all_names.back() == '\0') all_names.pop_back();

2079

2081 objects.size() - 1));

2082 }

2083}

2084}

2085

2089 }

2091

2092 ExtractNames(mLp, solver_->variables_);

2093 ExtractNames(mLp, solver_->constraints_);

2094

2095 VLOG(1) << "Writing Xpress MPS \"" << filename << "\".";

2096 const int status = XPRSwriteprob(mLp, filename.c_str(), "");

2097 if (status) {

2098 LOG(ERROR) << "Xpress: Failed to write MPS!";

2099 }

2100}

2101

2102template <class Container>

2103void splitMyString(const std::string& str, Container& cont, char delim = ' ') {

2104 std::stringstream ss(str);

2105 std::string token;

2106 while (std::getline(ss, token, delim)) {

2107 cont.push_back(token);

2108 }

2109}

2110

2112 *out = var.c_str();

2113 return true;

2114}

2115

2116#define setParamIfPossible_MACRO(target_map, setter, converter, type) \

2117 { \

2118 auto matchingParamIter = (target_map).find(paramAndValuePair.first); \

2119 if (matchingParamIter != (target_map).end()) { \

2120 type convertedValue; \

2121 bool ret = converter(paramAndValuePair.second, &convertedValue); \

2122 if (ret) { \

2123 VLOG(1) << "Setting parameter " << paramAndValuePair.first \

2124 << " to value " << convertedValue << std::endl; \

2125 } \

2126 setter(mLp, matchingParamIter->second, convertedValue); \

2127 continue; \

2128 } \

2129 }

2130

2131bool XpressInterface::SetSolverSpecificParametersAsString(

2132 const std::string& parameters) {

2133 if (parameters.empty()) return true;

2134

2135 std::vector<std::pair<std::string, std::string> > paramAndValuePairList;

2136

2137 std::stringstream ss(parameters);

2138 std::string paramName;

2139 while (std::getline(ss, paramName, ' ')) {

2140 std::string paramValue;

2141 if (std::getline(ss, paramValue, ' ')) {

2142 paramAndValuePairList.push_back(std::make_pair(paramName, paramValue));

2143 } else {

2144 LOG(ERROR) << "No value for parameter " << paramName << " : function "

2145 << __FUNCTION__ << std::endl;

2146 return false;

2147 }

2148 }

2149

2150 for (auto& paramAndValuePair : paramAndValuePairList) {

2152 absl::SimpleAtoi<int>, int);

2154 absl::SimpleAtod, double);

2158 absl::SimpleAtoi<int64_t>, int64_t);

2159 LOG(ERROR) << "Unknown parameter " << paramName << " : function "

2160 << __FUNCTION__ << std::endl;

2161 return false;

2162 }

2163 return true;

2164}

2165

2166

2167

2168

2169

2170

2171

2172

2173

2175 int nMsgLvl) {

2177 if (!xprs->quiet()) {

2178 switch (nMsgLvl) {

2179

2180 case 4:

2181 case 3:

2182

2183 case 2:

2184 case 1:

2185 printf("%*s\n", nLen, sMsg);

2186 break;

2187

2188 default:

2189 fflush(nullptr);

2190 break;

2191 }

2192 }

2193}

2194

2195void XpressInterface::AddSolutionHintToOptimizer() {

2196

2197 const std::size_t len = solver_->solution_hint_.size();

2198 if (len == 0) {

2199

2200 return;

2201 }

2202 unique_ptr<int[]> col_ind(new int[len]);

2203 unique_ptr<double[]> val(new double[len]);

2204

2205 for (std::size_t i = 0; i < len; ++i) {

2206 col_ind[i] = solver_->solution_hint_[i].first->index();

2207 val[i] = solver_->solution_hint_[i].second;

2208 }

2209 addhint(mLp, len, val.get(), col_ind.get());

2210}

2211

2213 if (callback_ != nullptr) {

2214

2216 }

2217 callback_ = mp_callback;

2218}

2219

2220

2221

2222

2224 auto callback_with_context = static_cast<MPCallbackWrapper*>(cbdata);

2225 if (callback_with_context == nullptr ||

2226 callback_with_context->GetCallback() == nullptr) {

2227

2228 return;

2229 }

2230 try {

2231 std::unique_ptr<XpressMPCallbackContext> cb_context =

2232 std::make_unique<XpressMPCallbackContext>(

2234 callback_with_context->GetCallback()->RunCallback(cb_context.get());

2235 } catch (std::exception&) {

2236 callback_with_context->CatchException(cbprob);

2237 }

2238}

2239

2243

2245 if (variable_values_.empty()) {

2246 int num_vars = getnumcols(*xprsprob_);

2247 variable_values_.resize(num_vars);

2249 }

2250 return variable_values_[variable->index()];

2251}

2252

2254 const absl::flat_hash_map<const MPVariable*, double>& solution) {

2255

2256 const std::size_t len = solution.size();

2257 if (len == 0) {

2258

2259 return NAN;

2260 }

2262

2263

2264

2265

2266 LOG(WARNING)

2267 << "XPRESS does not currently allow suggesting MIP solutions after "

2268 "a kMipSolution event. Try another call-back.";

2269 return NAN;

2270 }

2271 unique_ptr<int[]> colind(new int[len]);

2272 unique_ptr<double[]> val(new double[len]);

2273 int i = 0;

2274 for (const auto& [var, value] : solution) {

2275 colind[i] = var->index();

2276 val[i] = value;

2277 ++i;

2278 }

2279 addhint(*xprsprob_, len, val.get(), colind.get());

2280

2281

2282

2283 return NAN;

2284}

2285

2286namespace {

2287

2288

2289const void* const kRegisterXpress ABSL_ATTRIBUTE_UNUSED = [] {

2294 return nullptr;

2295}();

2296

2297

2298const void* const kRegisterXpressMip ABSL_ATTRIBUTE_UNUSED = [] {

2303 return nullptr;

2304}();

2305

2306}

2307

2308}

MPCallback * GetCallback() const

Definition xpress_interface.cc:259

MPCallbackWrapper(MPCallback *callback)

Definition xpress_interface.cc:258

void CatchException(XPRSprob cbprob)

Definition xpress_interface.cc:264

void LogCaughtExceptions()

Definition xpress_interface.cc:270

bool is_lazy() const

Advanced usage: returns true if the constraint is "lazy" (see below).

void set_dual_value(double dual_value)

double lb() const

Returns the lower bound.

double ub() const

Returns the upper bound.

int index() const

Returns the index of the constraint in the MPSolver::constraints_.

static MPSolverInterfaceFactoryRepository * GetInstance()

void Register(MPSolverInterfaceFactory factory, MPSolver::OptimizationProblemType problem_type, std::function< bool()> is_runtime_ready={})

void set_variable_as_extracted(int var_index, bool extracted)

bool CheckSolutionIsSynchronized() const

static constexpr int64_t kUnknownNumberOfIterations

friend class MPConstraint

void InvalidateSolutionSynchronization()

void set_constraint_as_extracted(int ct_index, bool extracted)

void ResetExtractionInformation()

virtual void SetIntegerParamToUnsupportedValue(MPSolverParameters::IntegerParam param, int value)

int last_constraint_index_

bool variable_is_extracted(int var_index) const

bool constraint_is_extracted(int ct_index) const

static constexpr int64_t kUnknownNumberOfNodes

double best_objective_bound_

void SetMIPParameters(const MPSolverParameters &param)

MPSolverInterface(MPSolver *solver)

void SetCommonParameters(const MPSolverParameters &param)

MPSolver::ResultStatus result_status_

SynchronizationStatus sync_status_

PresolveValues

For each categorical parameter, enumeration of possible values.

@ PRESOLVE_OFF

Presolve is off.

@ PRESOLVE_ON

Presolve is on.

LpAlgorithmValues

LP algorithm to use.

@ BARRIER

Barrier algorithm.

@ INCREMENTALITY

Advanced usage: incrementality from one solve to the next.

@ PRESOLVE

Advanced usage: presolve mode.

@ LP_ALGORITHM

Algorithm to solve linear programs.

@ SCALING

Advanced usage: enable or disable matrix scaling.

IncrementalityValues

Advanced usage: Incrementality options.

@ INCREMENTALITY_OFF

Start solve from scratch.

ScalingValues

Advanced usage: Scaling options.

@ SCALING_ON

Scaling is on.

@ SCALING_OFF

Scaling is off.

int GetIntegerParam(MPSolverParameters::IntegerParam param) const

Returns the value of an integer parameter.

@ FEASIBLE

feasible, or stopped by limit.

@ INFEASIBLE

proven infeasible.

@ UNBOUNDED

proven unbounded.

@ ABNORMAL

abnormal, i.e., error of some kind.

@ XPRESS_MIXED_INTEGER_PROGRAMMING

@ XPRESS_LINEAR_PROGRAMMING

The class for variables of a Mathematical Programming (MP) model.

bool integer() const

Returns the integrality requirement of the variable.

double lb() const

Returns the lower bound.

double ub() const

Returns the upper bound.

const std::string & name() const

Returns the name of the variable.

void set_reduced_cost(double reduced_cost)

void set_solution_value(double value)

int index() const

Returns the index of the variable in the MPSolver::variables_.

MPSolver::BasisStatus row_status(int constraint_index) const override

Definition xpress_interface.cc:1284

virtual int64_t nodes() const

Definition xpress_interface.cc:1236

MPSolver::BasisStatus column_status(int variable_index) const override

Definition xpress_interface.cc:1309

void ClearObjective() override

Definition xpress_interface.cc:1196

void SetOptimizationDirection(bool maximize) override

Definition xpress_interface.cc:900

void AddRowConstraint(MPConstraint *ct) override

Definition xpress_interface.cc:1062

void SetObjectiveOffset(double value) override

Definition xpress_interface.cc:1190

double ComputeExactConditionNumber() const override

Definition xpress_interface.cc:372

bool IsLP() const override

Definition xpress_interface.cc:357

virtual bool ReadParameterFile(std::string const &filename)

Definition xpress_interface.cc:1784

void Reset() override

Definition xpress_interface.cc:885

void SetCoefficient(MPConstraint *constraint, MPVariable const *variable, double new_value, double old_value) override

Definition xpress_interface.cc:1092

void SetVariableBounds(int var_index, double lb, double ub) override

Definition xpress_interface.cc:905

XpressInterface(MPSolver *solver, bool mip)

Definition xpress_interface.cc:840

void Write(const std::string &filename) override

Definition xpress_interface.cc:2086

void * underlying_solver() override

Definition xpress_interface.cc:370

MPSolver::ResultStatus Solve(MPSolverParameters const &param) override

Definition xpress_interface.cc:1795

void ExtractObjective() override

Definition xpress_interface.cc:1608

void ClearConstraint(MPConstraint *constraint) override

Definition xpress_interface.cc:1126

void SetConstraintBounds(int row_index, double lb, double ub) override

Definition xpress_interface.cc:1023

void SetRelativeMipGap(double value) override

Definition xpress_interface.cc:1643

void SetDualTolerance(double value) override

Definition xpress_interface.cc:1656

void ExtractNewVariables() override

Definition xpress_interface.cc:1334

bool InterruptSolve() override

Definition xpress_interface.cc:388

void SetScalingMode(int value) override

Definition xpress_interface.cc:1675

void AddVariable(MPVariable *var) override

Definition xpress_interface.cc:1076

void SetObjectiveCoefficient(MPVariable const *variable, double coefficient) override

Definition xpress_interface.cc:1167

void SetStartingLpBasis(const std::vector< MPSolver::BasisStatus > &variable_statuses, const std::vector< MPSolver::BasisStatus > &constraint_statuses) override

Definition xpress_interface.cc:1727

void SetLpAlgorithm(int value) override

Definition xpress_interface.cc:1694

void SetCallback(MPCallback *mp_callback) override

Definition xpress_interface.cc:2212

virtual int64_t iterations() const

Definition xpress_interface.cc:1231

void ExtractNewConstraints() override

Definition xpress_interface.cc:1509

virtual std::string ValidFileExtensionForParameterFile() const

Definition xpress_interface.cc:1791

void SetPrimalTolerance(double value) override

Definition xpress_interface.cc:1652

void SetParameters(MPSolverParameters const &param) override

Definition xpress_interface.cc:1637

bool SupportsCallbacks() const override

Definition xpress_interface.cc:386

void SetVariableInteger(int var_index, bool integer) override

Definition xpress_interface.cc:934

~XpressInterface() override

Definition xpress_interface.cc:860

void SetPresolveMode(int value) override

Definition xpress_interface.cc:1660

bool IsMIP() const override

Definition xpress_interface.cc:358

bool IsContinuous() const override

Definition xpress_interface.cc:356

std::string SolverVersion() const override

Definition xpress_interface.cc:865

void AddCut(const LinearRange &cutting_plane) override

Definition xpress_interface.cc:231

bool UpdateFromXpressState(XPRSprob cbprob)

MPCallbackEvent Event() override

Definition xpress_interface.cc:228

int64_t NumExploredNodes() override

Definition xpress_interface.cc:240

bool CanQueryVariableValues() override

Definition xpress_interface.cc:2240

XpressMPCallbackContext(XPRSprob *xprsprob, MPCallbackEvent event, int num_nodes)

Definition xpress_interface.cc:220

double SuggestSolution(const absl::flat_hash_map< const MPVariable *, double > &solution) override

Definition xpress_interface.cc:2253

void AddLazyConstraint(const LinearRange &lazy_constraint) override

Definition xpress_interface.cc:234

friend class XpressInterface

Definition xpress_interface.cc:217

double VariableValue(const MPVariable *variable) override

Definition xpress_interface.cc:2244

absl::string_view name() const

std::function< int(XPRSprob prob, int objidx)> XPRSdelobj

std::function< int(XPRSprob prob, void(XPRS_CC *f_intsol)(XPRSprob cbprob, void *cbdata), void *p, int priority)> XPRSaddcbintsol

std::function< int(XPRSprob prob, int control)> XPRSsetdefaultcontrol

std::function< int(XPRSprob prob, int nrows, const int rowind[], const char rowtype[])> XPRSchgrowtype

void addhint(const XPRSprob &mLp, int length, const double solval[], const int colind[])

Definition xpress_interface.cc:192

std::function< int(XPRSprob prob, int nrows, const int rowind[])> XPRSloaddelayedrows

std::function< int(XPRSprob prob, int attrib, int *p_value)> XPRSgetintattrib

static std::map< std::string, int > & getMapIntControls()

Definition xpress_interface.cc:594

std::function< int(XPRSprob prob, int attrib, double *p_value)> XPRSgetdblattrib

std::function< int(XPRSprob prob, const char *filename, const char *flags)> XPRSwriteprob

CUSTOM_INTERRUPT_REASON

Definition xpress_interface.cc:201

@ CALLBACK_EXCEPTION

Definition xpress_interface.cc:201

std::function< int(XPRSprob prob, void(XPRS_CC *f_message)(XPRSprob cbprob, void *cbdata, const char *msg, int msglen, int msgtype), void *p, int priority)> XPRSaddcbmessage

Select next search node to expand Select next item_i to add this new search node to the search Generate a new search node where item_i is not in the knapsack Check validity of this new partial solution(using propagators) - If valid

static MPSolver::BasisStatus XpressToMPSolverBasisStatus(int xpress_basis_status)

Definition xpress_interface.cc:1247

bool initXpressEnv(bool verbose, int xpress_oem_license_key)

init XPRESS environment.

std::function< int(XPRSprob prob, int length, const double solval[], const int colind[], const char *name)> XPRSaddmipsol

int getnumcols(const XPRSprob &mLp)

Definition xpress_interface.cc:160

std::function< int(XPRSprob prob, double x[], double slack[])> XPRSgetmipsol

std::function< int(XPRSprob prob, int nbounds, const int colind[], const char bndtype[], const double bndval[])> XPRSchgbounds

int getnodecnt(const XPRSprob &mLp)

Definition xpress_interface.cc:178

bool stringToCharPtr(const std::string &var, const char **out)

Definition xpress_interface.cc:2111

std::function< int(XPRSprob prob, const int rowstat[], const int colstat[])> XPRSloadbasis

std::function< int(XPRSprob prob, int row, int col, double coef)> XPRSchgcoef

std::function< int(XPRSprob prob, int nrows, const int rowind[])> XPRSdelrows

std::function< int(XPRSprob prob, int ncols, const int colind[])> XPRSdelcols

std::string getSolverVersion(XPRSprob const &prob)

Definition xpress_interface.cc:46

void interruptXPRESS(XPRSprob &xprsProb, CUSTOM_INTERRUPT_REASON reason)

Definition xpress_interface.cc:203

std::function< int(XPRSprob prob, int control, int *p_value)> XPRSgetintcontrol

std::function< int(XPRSprob prob, void(XPRS_CC *f_intsol)(XPRSprob cbprob, void *cbdata), void *p)> XPRSremovecbintsol

std::function< int(XPRSprob prob, int ncols, const int colind[], const char coltype[])> XPRSchgcoltype

std::function< int(XPRSprob prob, const char *name, int *p_id, int *p_type)> XPRSgetcontrolinfo

std::function< int(XPRSprob prob, double x[], double slack[], double duals[], double djs[])> XPRSgetlpsol

std::function< int(XPRSprob prob)> XPRSpostsolve

std::function< int(XPRSprob prob, int nrows, const int rowind[], const double rng[])> XPRSchgrhsrange

int setobjoffset(const XPRSprob &mLp, double value)

Definition xpress_interface.cc:184

std::function< int(XPRSprob prob, int type, const char names[], int first, int last)> XPRSaddnames

static int MPSolverToXpressBasisStatus(MPSolver::BasisStatus mpsolver_basis_status)

Definition xpress_interface.cc:1264

std::function< int(XPRSprob prob, int ncoefs, const int rowind[], const int colind[], const double rowcoef[])> XPRSchgmcoef

std::function< int(void)> XPRSfree

std::function< int(XPRSprob prob, int reason)> XPRSinterrupt

int getitcnt(const XPRSprob &mLp)

Definition xpress_interface.cc:172

bool XpressIsCorrectlyInstalled()

std::vector< int > XpressBasisStatusesFrom(const std::vector< MPSolver::BasisStatus > &statuses)

Definition xpress_interface.cc:1718

void splitMyString(const std::string &str, Container &cont, char delim=' ')

Definition xpress_interface.cc:2103

std::function< int(XPRSprob prob, int control, int value)> XPRSsetintcontrol

std::function< int(XPRSprob prob, int nrows, int ncoefs, const char rowtype[], const double rhs[], const double rng[], const int start[], const int colind[], const double rowcoef[])> XPRSaddrows

static std::map< std::string, int > & getMapStringControls()

Definition xpress_interface.cc:494

std::function< int(XPRSprob prob, char *errmsg)> XPRSgetlasterror

void XPRS_CC XpressIntSolCallbackImpl(XPRSprob cbprob, void *cbdata)

Definition xpress_interface.cc:2223

std::function< int(XPRSprob prob)> XPRSdestroyprob

int getnumrows(const XPRSprob &mLp)

Definition xpress_interface.cc:166

void printError(const XPRSprob &mLp, int line)

Definition xpress_interface.cc:139

void XPRS_CC optimizermsg(XPRSprob prob, void *data, const char *sMsg, int nLen, int nMsgLvl)

Definition xpress_interface.cc:2174

std::function< int(XPRSprob prob, int control, double value)> XPRSsetdblcontrol

std::function< int(XPRSprob prob, int control, const char *value)> XPRSsetstrcontrol

std::function< int(XPRSprob prob, int ncols, int ncoefs, const double objcoef[], const int start[], const int rowind[], const double rowcoef[], const double lb[], const double ub[])> XPRSaddcols

static std::map< std::string, int > & getMapDoubleControls()

Definition xpress_interface.cc:509

ClosedInterval::Iterator begin(ClosedInterval interval)

std::function< int(XPRSprob prob, const char *flags)> XPRSmipoptimize

std::function< int(XPRSprob prob, int nrows, const int rowind[], const double rhs[])> XPRSchgrhs

std::function< int(XPRSprob prob, int ncols, const int colind[], const double objcoef[])> XPRSchgobj

std::function< int(XPRSprob *p_prob)> XPRScreateprob

std::function< int(XPRSprob prob, const char *flags)> XPRSlpoptimize

static std::map< std::string, int > & getMapInt64Controls()

Definition xpress_interface.cc:831

std::function< int(XPRSprob prob, int control, XPRSint64 value)> XPRSsetintcontrol64

std::function< int(XPRSprob prob, int objsense)> XPRSchgobjsense

std::function< int(XPRSprob prob, int rowstat[], int colstat[])> XPRSgetbasis

bool readParameter(XPRSprob const &prob, std::string const &name, std::string const &value)

Definition xpress_interface.cc:61

#define XPRS_COMPUTEEXECSERVICE

#define XPRS_BARORDERTHREADS

#define XPRS_EXTRAMIPENTS

#define XPRS_MAXMEMORYHARD

#define XPRS_HEURSEARCHTARGETSIZE

#define XPRS_RELAXTREEMEMORYLIMIT

#define XPRS_CROSSOVERRELPIVOTTOL

#define XPRS_BARGAPTARGET

#define XPRS_TREECUTSELECT

#define XPRS_TUNERTHREADS

#define XPRS_MAXPAGELINES

#define XPRS_MAXCHECKSONMAXTIME

#define XPRS_HEURDIVEITERLIMIT

#define XPRS_GLOBALBOUNDINGBOX

#define XPRS_FEASTOLPERTURB

#define XPRS_TREEFILELOGINTERVAL

#define XPRS_HEURSEARCHTREESELECT

#define XPRS_RESOURCESTRATEGY

#define XPRS_TREEMEMORYSAVINGTARGET

#define XPRS_QUADRATICUNSHIFT

#define XPRS_MIPABSGAPNOTIFYOBJ

#define XPRS_CROSSOVERITERLIMIT

#define XPRS_TYPE_NOTDEFINED

#define XPRS_MIPKAPPAFREQ

#define XPRS_CROSSOVERFEASWEIGHT

#define XPRS_BRANCHCHOICE

#define XPRS_OBJ_MAXIMIZE

#define XPRS_FEASIBILITYJUMP

#define XPRS_OUTPUTCONTROLS

#define XPRS_MIP_SOLUTION

#define XPRS_BARPRESOLVEOPS

#define XPRS_MIPABSGAPNOTIFY

#define XPRS_HEURSEARCHFREQ

#define XPRS_BARINDEFLIMIT

#define XPRS_SIFTPRESOLVEOPS

#define XPRS_VARSELECTION

#define XPRS_CHECKINPUTDATA

#define XPRS_PLUSINFINITY

#define XPRS_EIGENVALUETOL

#define XPRS_DUMMYCONTROL

#define XPRS_COMPUTEJOBPRIORITY

#define XPRS_NUMERICALEMPHASIS

#define XPRS_MAXLOCALBACKTRACK

#define XPRS_CROSSOVERRELPIVOTTOLSAFE

#define XPRS_IFCHECKCONVEXITY

#define XPRS_MIPRESTARTFACTOR

#define XPRS_MIPADDCUTOFF

#define XPRS_SERIALIZEPREINTSOL

#define XPRS_HEURFORCESPECIALOBJ

#define XPRS_ALGAFTERCROSSOVER

#define XPRS_HEURDIVESPEEDUP

#define XPRS_BACKTRACKTIE

#define XPRS_MIP_UNBOUNDED

#define XPRS_PRECONVERTSEPARABLE

#define XPRS_PRECOMPONENTSEFFORT

#define XPRS_COMPUTEMATX_IISMAXTIME

#define XPRS_MPSBOUNDNAME

#define XPRS_DUALSTRATEGY

#define XPRS_BAROBJPERTURB

#define XPRS_MIPFRACREDUCE

#define XPRS_OBJSCALEFACTOR

#define XPRS_SOLTIMELIMIT

#define XPRS_USERSOLHEURISTIC

#define XPRS_BARFAILITERLIMIT

#define XPRS_PRECLIQUESTRATEGY

#define XPRS_FEASTOLTARGET

#define XPRS_MIPRELGAPNOTIFY

#define XPRS_HISTORYCOSTS

#define XPRS_HEURSEARCHROOTCUTFREQ

#define XPRS_MIPTERMINATIONMETHOD

#define XPRS_MAXSTALLTIME

#define XPRS_BRANCHSTRUCTURAL

struct xo_prob_struct * XPRSprob

#define XPRS_HEURSEARCHROOTSELECT

#define XPRS_MIPDUALREDUCTIONS

#define XPRS_BARNUMSTABILITY

#define XPRS_PRESOLVEPASSES

#define XPRS_IGNORECONTAINERMEMORYLIMIT

#define XPRS_PRIMALUNSHIFT

#define XPRS_CONCURRENTTHREADS

#define XPRS_HEURSEARCHEFFORT

#define XPRS_MAXIMPLIEDBOUND

#define XPRS_ROOTPRESOLVE

#define XPRS_CROSSOVERTHREADS

#define XPRS_PREBNDREDCONE

#define XPRS_MAXCHECKSONMAXCUTTIME

#define XPRS_MUTEXCALLBACKS

#define XPRS_MIPRELCUTOFF

#define XPRS_MPS18COMPATIBLE

#define XPRS_BARSTARTWEIGHT

#define XPRS_OPTIMALITYTOLTARGET

#define XPRS_PREANALYTICCENTER

#define XPRS_HEURDIVESTRATEGY

#define XPRS_BREADTHFIRST

#define XPRS_LOCALBACKTRACK

#define XPRS_TUNERMAXTIME

#define XPRS_FEASIBILITYPUMP

#define XPRS_REPAIRINDEFINITEQMAX

#define XPRS_TUNERHISTORY

#define XPRS_REPAIRINDEFINITEQ

#define XPRS_TREEDIAGNOSTICS

#define XPRS_PRECONFIGURATION

#define XPRS_CROSSOVEROPS

#define XPRS_MIPABSGAPNOTIFYBOUND

#define XPRS_COMPUTEMATX_IIS

#define XPRS_CONFLICTCUTS

#define XPRS_INDPRELINBIGM

#define XPRS_PRIMALPERTURB

#define XPRS_ALGAFTERNETWORK

#define XPRS_DUALGRADIENT

#define XPRS_PRECOMPONENTS

#define XPRS_NODEPROBINGEFFORT

#define XPRS_PWLNONCONVEXTRANSFORMATION

#define XPRS_TREECOMPRESSION

#define XPRS_PRESOLVEMAXGROW

#define XPRS_TREEMEMORYLIMIT

#define XPRS_MIPCOMPONENTS

#define XPRS_TUNERSESSIONNAME

#define XPRS_BARFREESCALE

#define XPRS_TUNEROUTPUTPATH

#define XPRS_MARKOWITZTOL

#define XPRS_HEURDIVERANDOMIZE

#define XPRS_PWLDUALREDUCTIONS

#define XPRS_BARLARGEBOUND

#define XPRS_OPTIMALITYTOL

#define XPRS_MAXSCALEFACTOR

#define XPRS_CROSSOVERACCURACYTOL

#define XPRS_PRECONEDECOMP

#define XPRS_HEUREMPHASIS

#define XPRS_BARITERLIMIT

#define XPRS_TUNERVERBOSE

#define XPRS_TUNERPERMUTE

#define XPRS_PREOBJCUTDETECT

#define XPRS_PREPROTECTDUAL

#define XPRS_REPAIRINFEASTIMELIMIT

#define XPRS_MPSNAMELENGTH

#define XPRS_GENCONSDUALREDUCTIONS

#define XPRS_LP_UNBOUNDED

#define XPRS_GENCONSABSTRANSFORMATION

#define XPRS_LPREFINEITERLIMIT

#define XPRS_HEURDIVESOFTROUNDING

#define XPRS_MIPREFINEITERLIMIT

#define XPRS_REPAIRINFEASMAXTIME

#define XPRS_MAXTREEFILESIZE

#define XPRS_HEURBEFORELP

#define XPRS_CALLBACKCHECKTIMEDELAY

#define XPRS_LNPITERLIMIT

#define XPRS_BARREGULARIZE

#define XPRS_NODESELECTION

#define XPRS_IGNORECONTAINERCPULIMIT

#define XPRS_CALLBACKFROMMASTERTHREAD

#define XPRS_MIPCONCURRENTNODES

#define XPRS_EXTRASETELEMS

#define XPRS_MIPABSCUTOFF

#define XPRS_TREECOVERCUTS

#define XPRS_DENSECOLLIMIT

#define XPRS_SLEEPONTHREADWAIT

#define XPRS_GLOBALSPATIALBRANCHIFPREFERORIG

#define XPRS_NAMES_COLUMN

#define XPRS_FORCEPARALLELDUAL

#define XPRS_MIPCONCURRENTSOLVES

#define XPRS_CROSSOVERDRP

#define XPRS_MIPRESTARTGAPTHRESHOLD

#define XPRS_MINUSINFINITY

#define XPRS_PREIMPLICATIONS

#define XPRS_MPSRANGENAME

#define XPRS_MAXMCOEFFBUFFERELEMS

#define XPRS_DETERMINISTIC

#define XPRS_MIPTOLTARGET

#define XPRS_MAXMEMORYSOFT

#define XPRS_TUNERMETHODFILE

#define XPRS_PREPERMUTESEED

#define XPRS_OBJ_MINIMIZE

#define XPRS_NETSTALLLIMIT

#define XPRS_PREBNDREDQUAD

#define XPRS_BARPRIMALSTOP

#define setParamIfPossible_MACRO(target_map, setter, converter, type)

Definition xpress_interface.cc:2116

#define XPRS_NAN

Definition xpress_interface.cc:211

#define XPRS_CONTINUOUS

Definition xpress_interface.cc:34

#define XPRS_INTEGER

Definition xpress_interface.cc:33