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

1

2

3

4

5

6

7

8

9

10

11

12

13

14#include <algorithm>

15#include <cmath>

16#include <cstdint>

17#include <limits>

18#include <memory>

19#include <string>

20#include <utility>

21#include <vector>

22

23#include "absl/base/attributes.h"

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

29

30extern "C" {

31#include "glpk.h"

32}

33

35

37 public:

41 void Reset(bool maximize) {

44 }

46 if (maximize) {

48 } else {

50 }

51 }

54};

55

56

58 CHECK(tree != nullptr);

59 CHECK(info != nullptr);

61 switch (glp_ios_reason(tree)) {

62

63

64 case GLP_ISELECT:

65 case GLP_IROWGEN:

66 case GLP_IBINGO: {

67

68 glp_ios_tree_size(tree, nullptr, nullptr, &glpk_info->num_all_nodes_);

69

70 int node_id = glp_ios_best_node(tree);

71 if (node_id > 0) {

73 }

74 break;

75 }

76 default:

77 break;

78 }

79}

80

81

82

83namespace {

84

85int MPSolverIndexToGlpkIndex(int index) { return index + 1; }

86}

87

89 public:

90

93

94

96

97

98

100

101

102

103 void Reset() override;

104

105

106 void SetVariableBounds(int mpsolver_var_index, double lb, double ub) override;

107 void SetVariableInteger(int mpsolver_var_index, bool integer) override;

109 double ub) override;

110

111

113

115

117 double new_value, double old_value) override;

118

120

122 double coefficient) override;

123

125

127

128

129

131

132 int64_t nodes() const override;

133

134

136

138

139

141

142

143

145 bool IsLP() const override { return !mip_; }

146 bool IsMIP() const override { return mip_; }

147

151

153 return absl::StrFormat("GLPK %s", glp_version());

154 }

155

157

159

160 private:

161

163

164

166

167 void SetRelativeMipGap(double value) override;

168 void SetPrimalTolerance(double value) override;

169 void SetDualTolerance(double value) override;

170 void SetPresolveMode(int value) override;

171 void SetScalingMode(int value) override;

172 void SetLpAlgorithm(int value) override;

173

174 void ExtractOldConstraints();

175 void ExtractOneConstraint(MPConstraint* constraint, int* indices,

176 double* coefs);

177

179

180

181

182

183 double ComputeScaledBasisL1Norm(int num_rows, int num_cols,

184 double* row_scaling_factor,

185 double* column_scaling_factor) const;

186

187

188

189

190 double ComputeInverseScaledBasisL1Norm(int num_rows, int num_cols,

191 double* row_scaling_factor,

192 double* column_scaling_factor) const;

193

194 glp_prob* lp_;

195 bool mip_;

196

197

198 glp_smcp lp_param_;

199 glp_iocp mip_param_;

200

201 std::unique_ptr<GLPKInformation> mip_callback_info_;

202};

203

204

207

209

210 lp_ = glp_create_prob();

211 glp_set_prob_name(lp_, solver_->name_.c_str());

212 glp_set_obj_dir(lp_, GLP_MIN);

213 mip_callback_info_ = std::make_unique<GLPKInformation>(maximize_);

214}

215

216

218 CHECK(lp_ != nullptr);

219 glp_delete_prob(lp_);

220 lp_ = nullptr;

221}

222

224 CHECK(lp_ != nullptr);

225 glp_delete_prob(lp_);

226 lp_ = glp_create_prob();

227 glp_set_prob_name(lp_, solver_->name_.c_str());

228 glp_set_obj_dir(lp_, maximize_ ? GLP_MAX : GLP_MIN);

230}

231

232

233

234

237 glp_set_obj_dir(lp_, maximize ? GLP_MAX : GLP_MIN);

238}

239

241 double ub) {

245 return;

246 }

247

248 DCHECK(lp_ != nullptr);

250 const int glpk_var_index = MPSolverIndexToGlpkIndex(mpsolver_var_index);

253 if (lb == ub) {

254 glp_set_col_bnds(lp_, glpk_var_index, GLP_FX, lb, ub);

255 } else {

256 glp_set_col_bnds(lp_, glpk_var_index, GLP_DB, lb, ub);

257 }

258 } else {

259 glp_set_col_bnds(lp_, glpk_var_index, GLP_LO, lb, 0.0);

260 }

262 glp_set_col_bnds(lp_, glpk_var_index, GLP_UP, 0.0, ub);

263 } else {

264 glp_set_col_bnds(lp_, glpk_var_index, GLP_FR, 0.0, 0.0);

265 }

266}

267

270 if (mip_) {

272

273 glp_set_col_kind(lp_, MPSolverIndexToGlpkIndex(mpsolver_var_index),

274 integer ? GLP_IV : GLP_CV);

275 } else {

277 }

278 }

279}

280

282 double lb, double ub) {

286 return;

287 }

288

289 const int glpk_constraint_index =

290 MPSolverIndexToGlpkIndex(mpsolver_constraint_index);

291 DCHECK(lp_ != nullptr);

295 if (lb == ub) {

296 glp_set_row_bnds(lp_, glpk_constraint_index, GLP_FX, lb, ub);

297 } else {

298 glp_set_row_bnds(lp_, glpk_constraint_index, GLP_DB, lb, ub);

299 }

300 } else {

301 glp_set_row_bnds(lp_, glpk_constraint_index, GLP_LO, lb, 0.0);

302 }

304 glp_set_row_bnds(lp_, glpk_constraint_index, GLP_UP, 0.0, ub);

305 } else {

306 glp_set_row_bnds(lp_, glpk_constraint_index, GLP_FR, 0.0, 0.0);

307 }

308}

309

312 double new_value, double old_value) {

314

315

316

317

320 !constraint->ContainsNewVariables())) {

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

322 std::unique_ptr<int[]> indices(new int[size + 1]);

323 std::unique_ptr<double[]> coefs(new double[size + 1]);

324 ExtractOneConstraint(constraint, indices.get(), coefs.get());

325 }

326}

327

328

331

333 glp_set_mat_row(lp_, MPSolverIndexToGlpkIndex(constraint->index()), 0,

334 nullptr, nullptr);

335 }

336}

337

338

340 double coefficient) {

342}

343

344

348

349

352 for (const auto& entry : solver_->objective_->coefficients_) {

353 const int mpsolver_var_index = entry.first->index();

354

357 } else {

358 glp_set_obj_coef(lp_, MPSolverIndexToGlpkIndex(mpsolver_var_index), 0.0);

359 }

360 }

361

362 glp_set_obj_coef(lp_, 0, 0.0);

363}

364

368

372

373

375 int total_num_vars = solver_->variables_.size();

381 if (!var->name().empty()) {

382 glp_set_col_name(lp_, MPSolverIndexToGlpkIndex(j), var->name().c_str());

383 }

386

387

388 double tmp_obj_coef = 0.0;

389 glp_set_obj_coef(lp_, MPSolverIndexToGlpkIndex(j), tmp_obj_coef);

390 }

391

392 ExtractOldConstraints();

393 }

394}

395

396

397void GLPKInterface::ExtractOldConstraints() {

398 const int max_constraint_size =

400

401

402 std::unique_ptr<int[]> indices(new int[max_constraint_size + 1]);

403 std::unique_ptr<double[]> coefs(new double[max_constraint_size + 1]);

404

408 const int size = ct->coefficients_.size();

409 if (size == 0) {

410 continue;

411 }

412

413 if (ct->ContainsNewVariables()) {

414 ExtractOneConstraint(ct, indices.get(), coefs.get());

415 }

416 }

417}

418

419

420

421

422void GLPKInterface::ExtractOneConstraint(MPConstraint* const constraint,

423 int* const indices,

424 double* const coefs) {

425

426 int k = 1;

427 for (const auto& entry : constraint->coefficients_) {

429 indices[k] = MPSolverIndexToGlpkIndex(entry.first->index());

430 coefs[k] = entry.second;

431 ++k;

432 }

433 glp_set_mat_row(lp_, MPSolverIndexToGlpkIndex(constraint->index()), k - 1,

434 indices, coefs);

435}

436

437

439 int total_num_rows = solver_->constraints_.size();

441

443 int num_coefs = 0;

447 if (ct->name().empty()) {

448 glp_set_row_name(lp_, MPSolverIndexToGlpkIndex(i),

449 absl::StrFormat("ct_%i", i).c_str());

450 } else {

451 glp_set_row_name(lp_, MPSolverIndexToGlpkIndex(i), ct->name().c_str());

452 }

453

455 num_coefs += ct->coefficients_.size();

456 }

457

458

460

461

462

463

464

465

466 std::unique_ptr<int[]> variable_indices(new int[num_coefs + 1]);

467 std::unique_ptr<int[]> constraint_indices(new int[num_coefs + 1]);

468 std::unique_ptr<double[]> coefs(new double[num_coefs + 1]);

469 int k = 1;

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

472 for (const auto& entry : ct->coefficients_) {

474 constraint_indices[k] = MPSolverIndexToGlpkIndex(ct->index());

475 variable_indices[k] = MPSolverIndexToGlpkIndex(entry.first->index());

476 coefs[k] = entry.second;

477 ++k;

478 }

479 }

480 CHECK_EQ(num_coefs + 1, k);

481 glp_load_matrix(lp_, num_coefs, constraint_indices.get(),

482 variable_indices.get(), coefs.get());

483 } else {

484

485 int max_constraint_size = solver_->ComputeMaxConstraintSize(

487

488

489 std::unique_ptr<int[]> indices(new int[max_constraint_size + 1]);

490 std::unique_ptr<double[]> coefs(new double[max_constraint_size + 1]);

492 ExtractOneConstraint(solver_->constraints_[i], indices.get(),

493 coefs.get());

494 }

495 }

496 }

497}

498

500

501

502 for (const auto& entry : solver_->objective_->coefficients_) {

503 glp_set_obj_coef(lp_, MPSolverIndexToGlpkIndex(entry.first->index()),

504 entry.second);

505 }

506

507 glp_set_obj_coef(lp_, 0, solver_->Objective().offset());

508}

509

510

514

515

519 }

520

521

523 glp_term_out(GLP_OFF);

524 } else {

525 glp_term_out(GLP_ON);

526 }

527

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

530

531

532

533

534 ConfigureGLPKParameters(param);

535

536

538 int solver_status = glp_simplex(lp_, &lp_param_);

539 if (mip_) {

540

541

542 if (solver_status == 0) {

543 solver_status = glp_intopt(lp_, &mip_param_);

544 } else {

545

546

547

548

550 if (solver_status == GLP_ETMLIM) {

552 }

555 }

556 }

557 VLOG(1) << absl::StrFormat("GLPK Status: %i (time spent: %.3f seconds).",

558 solver_status, timer.Get());

559

560

561 if (mip_) {

564 } else {

566 }

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

571 double val;

572 if (mip_) {

573 val = glp_mip_col_val(lp_, MPSolverIndexToGlpkIndex(i));

574 } else {

575 val = glp_get_col_prim(lp_, MPSolverIndexToGlpkIndex(i));

576 }

578 VLOG(3) << var->name() << ": value =" << val;

579 if (!mip_) {

580 double reduced_cost;

581 reduced_cost = glp_get_col_dual(lp_, MPSolverIndexToGlpkIndex(i));

583 VLOG(4) << var->name() << ": reduced cost = " << reduced_cost;

584 }

585 }

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

588 if (!mip_) {

589 const double dual_value =

590 glp_get_row_dual(lp_, MPSolverIndexToGlpkIndex(i));

592 VLOG(4) << "row " << MPSolverIndexToGlpkIndex(i)

593 << ": dual value = " << dual_value;

594 }

595 }

596

597

598 if (mip_) {

599 int tmp_status = glp_mip_status(lp_);

600 VLOG(1) << "GLPK result status: " << tmp_status;

601 if (tmp_status == GLP_OPT) {

603 } else if (tmp_status == GLP_FEAS) {

605 } else if (tmp_status == GLP_NOFEAS) {

606

607

608

610 } else if (solver_status == GLP_ETMLIM) {

612 } else {

614

615

616 }

617 } else {

618 int tmp_status = glp_get_status(lp_);

619 VLOG(1) << "GLPK result status: " << tmp_status;

620 if (tmp_status == GLP_OPT) {

622 } else if (tmp_status == GLP_FEAS) {

624 } else if (tmp_status == GLP_NOFEAS || tmp_status == GLP_INFEAS) {

625

626

627

629 } else if (tmp_status == GLP_UNBND) {

630

631

632

634 } else if (solver_status == GLP_ETMLIM) {

636 } else {

638 }

639 }

640

642

644}

645

647 int glpk_basis_status) const {

648 switch (glpk_basis_status) {

649 case GLP_BS:

651 case GLP_NL:

653 case GLP_NU:

655 case GLP_NF:

657 case GLP_NS:

659 default:

660 LOG(FATAL) << "Unknown GLPK basis status";

662 }

663}

664

665

666

668#if GLP_MAJOR_VERSION == 4 && GLP_MINOR_VERSION < 49

670 return lpx_get_int_parm(lp_, LPX_K_ITCNT);

671 }

672#elif (GLP_MAJOR_VERSION == 4 && GLP_MINOR_VERSION >= 53) || \

673 GLP_MAJOR_VERSION >= 5

675 return glp_get_it_cnt(lp_);

676 }

677#endif

678 LOG(WARNING) << "Total number of iterations is not available";

680}

681

683 if (mip_) {

685 return mip_callback_info_->num_all_nodes_;

686 } else {

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

689 }

690}

691

693 DCHECK_GE(constraint_index, 0);

695 const int glpk_basis_status =

696 glp_get_row_stat(lp_, MPSolverIndexToGlpkIndex(constraint_index));

697 return TransformGLPKBasisStatus(glpk_basis_status);

698}

699

701 DCHECK_GE(variable_index, 0);

703 const int glpk_basis_status =

704 glp_get_col_stat(lp_, MPSolverIndexToGlpkIndex(variable_index));

705 return TransformGLPKBasisStatus(glpk_basis_status);

706}

707

710 LOG(WARNING) << "Ignoring ABNORMAL status from GLPK: This status may or may"

711 << " not indicate that a solution exists.";

712 return true;

713 } else {

714

716 }

717}

718

721

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

723 << " GLPK_MIXED_INTEGER_PROGRAMMING";

724 return 0.0;

725 }

727

728

730 const int num_rows = glp_get_num_rows(lp_);

731 const int num_cols = glp_get_num_cols(lp_);

732

733 std::unique_ptr<double[]> row_scaling_factor(new double[num_rows + 1]);

734 std::unique_ptr<double[]> column_scaling_factor(new double[num_cols + 1]);

735 for (int row = 1; row <= num_rows; ++row) {

736 row_scaling_factor[row] = glp_get_rii(lp_, row);

737 }

738 for (int col = 1; col <= num_cols; ++col) {

739 column_scaling_factor[col] = glp_get_sjj(lp_, col);

740 }

741 return ComputeInverseScaledBasisL1Norm(num_rows, num_cols,

742 row_scaling_factor.get(),

743 column_scaling_factor.get()) *

744 ComputeScaledBasisL1Norm(num_rows, num_cols, row_scaling_factor.get(),

745 column_scaling_factor.get());

746}

747

748double GLPKInterface::ComputeScaledBasisL1Norm(

749 int num_rows, int num_cols, double* row_scaling_factor,

750 double* column_scaling_factor) const {

751 double norm = 0.0;

752 std::unique_ptr<double[]> values(new double[num_rows + 1]);

753 std::unique_ptr<int[]> indices(new int[num_rows + 1]);

754 for (int col = 1; col <= num_cols; ++col) {

755 const int glpk_basis_status = glp_get_col_stat(lp_, col);

756

757 if (glpk_basis_status == GLP_BS) {

758

759 const int num_nz = glp_get_mat_col(lp_, col, indices.get(), values.get());

760 double column_norm = 0.0;

761 for (int k = 1; k <= num_nz; k++) {

762 column_norm += fabs(values[k] * row_scaling_factor[indices[k]]);

763 }

764 column_norm *= fabs(column_scaling_factor[col]);

765

766 norm = std::max(norm, column_norm);

767 }

768 }

769

770 for (int row = 1; row <= num_rows; ++row) {

771 const int glpk_basis_status = glp_get_row_stat(lp_, row);

772

773 if (glpk_basis_status == GLP_BS) {

774

775

776

777 const double column_norm = fabs(row_scaling_factor[row]);

778

779 norm = std::max(norm, column_norm);

780 }

781 }

782 return norm;

783}

784

785double GLPKInterface::ComputeInverseScaledBasisL1Norm(

786 int num_rows, int num_cols, double* row_scaling_factor,

787 double* column_scaling_factor) const {

788

789 if (!glp_bf_exists(lp_)) {

790 const int factorize_status = glp_factorize(lp_);

791 switch (factorize_status) {

792 case GLP_EBADB: {

793 LOG(FATAL) << "Not able to factorize: error GLP_EBADB.";

794 break;

795 }

796 case GLP_ESING: {

797 LOG(WARNING)

798 << "Not able to factorize: "

799 << "the basis matrix is singular within the working precision.";

801 }

802 case GLP_ECOND: {

803 LOG(WARNING)

804 << "Not able to factorize: the basis matrix is ill-conditioned.";

806 }

807 default:

808 break;

809 }

810 }

811 std::unique_ptr<double[]> right_hand_side(new double[num_rows + 1]);

812 double norm = 0.0;

813

814

815

816

817

818

819

820

821

822

823

824

825 for (int k = 1; k <= num_rows; ++k) {

826 for (int row = 1; row <= num_rows; ++row) {

827 right_hand_side[row] = 0.0;

828 }

829 right_hand_side[k] = 1.0;

830

831 for (int row = 1; row <= num_rows; ++row) {

832 right_hand_side[row] /= row_scaling_factor[row];

833 }

834 glp_ftran(lp_, right_hand_side.get());

835

836

837

838 for (int row = 1; row <= num_rows; ++row) {

839 const int k = glp_get_bhead(lp_, row);

840 if (k <= num_rows) {

841

842 right_hand_side[row] *= row_scaling_factor[k];

843 } else {

844

845 right_hand_side[row] /= column_scaling_factor[k - num_rows];

846 }

847 }

848

849 double column_norm = 0.0;

850 for (int row = 1; row <= num_rows; ++row) {

851 column_norm += fabs(right_hand_side[row]);

852 }

853

854 norm = std::max(norm, column_norm);

855 }

856 return norm;

857}

858

859

860

861void GLPKInterface::ConfigureGLPKParameters(const MPSolverParameters& param) {

862 if (mip_) {

863 glp_init_iocp(&mip_param_);

864

865 if (solver_->time_limit()) {

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

867 mip_param_.tm_lim = solver_->time_limit();

868 }

869

871 mip_callback_info_->Reset(maximize_);

872 mip_param_.cb_info = mip_callback_info_.get();

873

874 }

875

876

877

878 glp_init_smcp(&lp_param_);

879

880 if (solver_->time_limit()) {

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

882 lp_param_.tm_lim = solver_->time_limit();

883 }

884

885

886 glp_scale_prob(lp_, GLP_SF_AUTO);

887

888

889 glp_adv_basis(lp_, 0);

890

891

892 SetParameters(param);

893}

894

897 if (mip_) {

899 }

900}

901

902void GLPKInterface::SetRelativeMipGap(double value) {

903 if (mip_) {

904 mip_param_.mip_gap = value;

905 } else {

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

907 << "for discrete problems.";

908 }

909}

910

911void GLPKInterface::SetPrimalTolerance(double value) {

912 lp_param_.tol_bnd = value;

913}

914

915void GLPKInterface::SetDualTolerance(double value) { lp_param_.tol_dj = value; }

916

917void GLPKInterface::SetPresolveMode(int value) {

918 switch (value) {

920 mip_param_.presolve = GLP_OFF;

921 lp_param_.presolve = GLP_OFF;

922 break;

923 }

925 mip_param_.presolve = GLP_ON;

926 lp_param_.presolve = GLP_ON;

927 break;

928 }

929 default: {

931 }

932 }

933}

934

935void GLPKInterface::SetScalingMode(int value) {

937}

938

939void GLPKInterface::SetLpAlgorithm(int value) {

940 switch (value) {

942

943 lp_param_.meth = GLP_DUALP;

944 break;

945 }

947 lp_param_.meth = GLP_PRIMAL;

948 break;

949 }

951 default: {

953 value);

954 }

955 }

956}

957

958namespace {

959

960

961const void* const kRegisterGLPKLP ABSL_ATTRIBUTE_UNUSED = [] {

965 return nullptr;

966}();

967

968

969const void* const kRegisterGLPKMIP ABSL_ATTRIBUTE_UNUSED = [] {

973 return nullptr;

974}();

975

976}

977

978}

void Reset(bool maximize)

Definition glpk_interface.cc:41

double best_objective_bound_

Definition glpk_interface.cc:53

void ResetBestObjectiveBound(bool maximize)

Definition glpk_interface.cc:45

GLPKInformation(bool maximize)

Definition glpk_interface.cc:38

int num_all_nodes_

Definition glpk_interface.cc:52

int64_t nodes() const override

Definition glpk_interface.cc:682

~GLPKInterface() override

Definition glpk_interface.cc:217

bool IsLP() const override

Definition glpk_interface.cc:145

double ComputeExactConditionNumber() const override

Definition glpk_interface.cc:719

void ClearObjective() override

Definition glpk_interface.cc:350

void ClearConstraint(MPConstraint *constraint) override

Definition glpk_interface.cc:329

void ExtractNewConstraints() override

Definition glpk_interface.cc:438

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

Definition glpk_interface.cc:240

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

Definition glpk_interface.cc:339

bool IsContinuous() const override

Definition glpk_interface.cc:144

bool CheckSolutionExists() const override

Definition glpk_interface.cc:708

void AddRowConstraint(MPConstraint *ct) override

Definition glpk_interface.cc:365

void * underlying_solver() override

Definition glpk_interface.cc:156

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

Definition glpk_interface.cc:310

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

Definition glpk_interface.cc:511

void AddVariable(MPVariable *var) override

Definition glpk_interface.cc:369

GLPKInterface(MPSolver *solver, bool mip)

Definition glpk_interface.cc:205

bool IsMIP() const override

Definition glpk_interface.cc:146

void SetVariableInteger(int mpsolver_var_index, bool integer) override

Definition glpk_interface.cc:268

int64_t iterations() const override

Definition glpk_interface.cc:667

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

Definition glpk_interface.cc:281

MPSolver::BasisStatus row_status(int constraint_index) const override

Definition glpk_interface.cc:692

void SetOptimizationDirection(bool maximize) override

Definition glpk_interface.cc:235

MPSolver::BasisStatus column_status(int variable_index) const override

Definition glpk_interface.cc:700

std::string SolverVersion() const override

Definition glpk_interface.cc:152

void ExtractObjective() override

Definition glpk_interface.cc:499

void ExtractNewVariables() override

Definition glpk_interface.cc:374

void Reset() override

Definition glpk_interface.cc:223

void SetObjectiveOffset(double value) override

Definition glpk_interface.cc:345

void set_dual_value(double dual_value)

double lb() const

Returns the lower bound.

double ub() const

Returns the upper bound.

const std::string & name() const

Returns the name of the constraint.

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_

virtual bool CheckSolutionExists() const

virtual void SetUnsupportedIntegerParam(MPSolverParameters::IntegerParam param)

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)

virtual double infinity()

void SetCommonParameters(const MPSolverParameters &param)

MPSolver::ResultStatus result_status_

SynchronizationStatus sync_status_

@ PRESOLVE_OFF

Presolve is off.

@ PRESOLVE_ON

Presolve is on.

@ 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.

@ INCREMENTALITY_OFF

Start solve from scratch.

int GetIntegerParam(MPSolverParameters::IntegerParam param) const

Returns the value of an integer parameter.

@ FEASIBLE

feasible, or stopped by limit.

@ NOT_SOLVED

not been solved yet.

@ INFEASIBLE

proven infeasible.

@ UNBOUNDED

proven unbounded.

@ ABNORMAL

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

@ GLPK_MIXED_INTEGER_PROGRAMMING

@ GLPK_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)

void SetupGlpkEnvAutomaticDeletion()

void GLPKGatherInformationCallback(glp_tree *tree, void *info)

Definition glpk_interface.cc:57