Skip to content

Commit

Permalink
clean up comments in interface code
Browse files Browse the repository at this point in the history
  • Loading branch information
tvignon-artelys committed Oct 7, 2024
1 parent a52585b commit 8f80b50
Showing 1 changed file with 4 additions and 37 deletions.
41 changes: 4 additions & 37 deletions ortools/linear_solver/knitro_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,6 @@ class KnitroInterface : public MPSolverInterface {

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

// TODO : A voir si on override
// std::optional<MPSolutionResponse> DirectlySolveProto(
// const MPModelRequest& request, std::atomic<bool>* interrupt) override;

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

Expand Down Expand Up @@ -505,7 +501,6 @@ KnitroInterface::~KnitroInterface() { CHECK_STATUS(KN_free(&kc_)); }
void KnitroInterface::Reset() {
// Instead of explicitly clearing all model objects we
// just delete the problem object and allocate a new one.
// std::cout << "Reset Called" << std::endl;
CHECK_STATUS(KN_free(&kc_));
no_obj_ = true;
int status;
Expand All @@ -532,8 +527,6 @@ void KnitroInterface::SetOptimizationDirection(bool maximize) {

void KnitroInterface::SetVariableBounds(int var_index, double lb, double ub) {
InvalidateSolutionSynchronization();
// the "extracted" check is done upstream for now
// but it should be done here
if (variable_is_extracted(var_index)) {
// Not cached if the variable has been extracted.
DCHECK_LT(var_index, last_variable_index_);
Expand All @@ -549,8 +542,6 @@ void KnitroInterface::SetVariableBounds(int var_index, double lb, double ub) {
void KnitroInterface::SetVariableInteger(int var_index, bool integer) {
InvalidateSolutionSynchronization();
if (mip_) {
// the "extracted" check is done upstream for now
// but it should be done here
if (variable_is_extracted(var_index)) {
DCHECK_LT(var_index, last_variable_index_);
CHECK_STATUS(KN_set_var_type(
Expand All @@ -566,8 +557,6 @@ void KnitroInterface::SetVariableInteger(int var_index, bool integer) {

void KnitroInterface::SetConstraintBounds(int row_index, double lb, double ub) {
InvalidateSolutionSynchronization();
// the "extracted" check is done upstream for now
// but it should be done here
if (constraint_is_extracted(row_index)) {
DCHECK_LT(row_index, last_constraint_index_);
CHECK_STATUS(
Expand Down Expand Up @@ -607,8 +596,7 @@ void KnitroInterface::ClearConstraint(MPConstraint* constraint) {
const auto& coeffs = constraint->coefficients_;
for (auto coeff : coeffs) {
int const col = coeff.first->index();
// if the variable has been extracted,
// then its linear coefficient exists
// if the variable has been extracted then its linear coefficient exists
if (variable_is_extracted(col)) {
var_ind[j] = col;
++j;
Expand Down Expand Up @@ -701,16 +689,6 @@ void KnitroInterface::ExtractNewVariables() {
DCHECK(!variable_is_extracted(var_index));
set_variable_as_extracted(var_index, true);

// // Defines the bounds and type of var
// CHECK_STATUS(KN_set_var_lobnd(kc_, var_index,
// redefine_infinity_double(var->lb())));
// CHECK_STATUS(KN_set_var_upbnd(kc_, var_index,
// redefine_infinity_double(var->ub())));
// CHECK_STATUS(KN_set_var_type(kc_, var_index,
// (mip_ && var->integer())
// ? KN_VARTYPE_INTEGER
// : KN_VARTYPE_CONTINUOUS));

// Define the bounds and type of var
idx_vars[var_index - last_variable_index_] = var_index;
lb[var_index - last_variable_index_] = redefine_infinity_double(var->lb());
Expand Down Expand Up @@ -994,7 +972,6 @@ absl::Status KnitroInterface::SetNumThreads(int num_threads) {
// ------ Solve -----

MPSolver::ResultStatus KnitroInterface::Solve(MPSolverParameters const& param) {
// std::cout << "Solve Called " << std::endl;
WallTimer timer;
timer.Start();

Expand All @@ -1006,11 +983,6 @@ MPSolver::ResultStatus KnitroInterface::Solve(MPSolverParameters const& param) {
ExtractModel();
VLOG(1) << absl::StrFormat("Model build in %.3f seconds.", timer.Get());

// std::cout << "Number of variables : " << solver_->variables_.size()
// << std::endl;
// std::cout << "Number of constraints : " << solver_->constraints_.size()
// << std::endl;

if (quiet_) {
// Silent the screen output
CHECK_STATUS(KN_set_int_param(kc_, KN_PARAM_OUTLEV, KN_OUTLEV_NONE));
Expand Down Expand Up @@ -1054,8 +1026,6 @@ MPSolver::ResultStatus KnitroInterface::Solve(MPSolverParameters const& param) {
if (mip_) best_objective_bound_ = 0;
result_status_ = MPSolver::OPTIMAL;
sync_status_ = SOLUTION_SYNCHRONIZED;
// std::cout << "Solution Status (empty problem): " << result_status_
// << std::endl;
return result_status_;
}

Expand Down Expand Up @@ -1099,9 +1069,6 @@ MPSolver::ResultStatus KnitroInterface::Solve(MPSolverParameters const& param) {
VLOG(1) << "No feasible solution found.";
}

// int algorithm;
// KN_get_int_param(kc_, KN_PARAM_ALG, &algorithm);
// // std::cout << "Algorithm setting param " << algorithm << std::endl;
sync_status_ = SOLUTION_SYNCHRONIZED;

return result_status_;
Expand Down Expand Up @@ -1181,9 +1148,9 @@ int64_t KnitroInterface::nodes() const {
// ----- Misc -----

std::string KnitroInterface::SolverVersion() const {
int const length = 15; // should contain the string termination character
char release[length + 1]; // checked but there are trouble if not allocated
// with a additional char
int const length = 15; // should contain the string termination character,
char release[length + 1]; // checked but there is trouble if not allocated
// with an additional char

CHECK_STATUS(KN_get_release(length, release));

Expand Down

0 comments on commit 8f80b50

Please sign in to comment.