Skip to content

Commit

Permalink
Fix some issues with Ipopt
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaslundell committed Sep 16, 2023
1 parent 158a13f commit db906f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
20 changes: 11 additions & 9 deletions src/NLPSolver/NLPSolverIpoptBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ bool IpoptProblem::get_starting_point(Index n, [[maybe_unused]] bool init_x, [[m
[[maybe_unused]] bool init_z, [[maybe_unused]] Number* z_L, [[maybe_unused]] Number* z_U, [[maybe_unused]] Index m,
[[maybe_unused]] bool init_lambda, [[maybe_unused]] Number* lambda)
{
/*
assert(init_x == true);
assert(init_z == false);
assert(init_lambda == false);
Expand Down Expand Up @@ -294,7 +295,7 @@ bool IpoptProblem::get_starting_point(Index n, [[maybe_unused]] bool init_x, [[m
x[k] = variableLB;
else
x[k] = variableUB;
}
}*/

return (true);
}
Expand Down Expand Up @@ -477,6 +478,7 @@ bool IpoptProblem::eval_h(Index n, const Number* x, [[maybe_unused]] bool new_x,
return (true);
}

/*
bool IpoptProblem::get_scaling_parameters(Number& obj_scaling, [[maybe_unused]] bool& use_x_scaling,
[[maybe_unused]] Index n, [[maybe_unused]] Number* x_scaling, [[maybe_unused]] bool& use_g_scaling,
[[maybe_unused]] Index m, [[maybe_unused]] Number* g_scaling)
Expand All @@ -487,7 +489,7 @@ bool IpoptProblem::get_scaling_parameters(Number& obj_scaling, [[maybe_unused]]
use_g_scaling = false;
return (true);
}
}*/

void IpoptProblem::finalize_solution(SolverReturn status, [[maybe_unused]] Index n, const Number* x,
[[maybe_unused]] const Number* z_L, [[maybe_unused]] const Number* z_U, [[maybe_unused]] Index m,
Expand Down Expand Up @@ -896,25 +898,25 @@ void NLPSolverIpoptBase::setInitialSettings()
// ipoptApplication->Options()->SetStringValue("derivative_test_print_all", "no");

// These are default settings for Ipopt in Bonmin, so should work here as well
ipoptApplication->Options()->SetNumericValue("bound_relax_factor", 1e-10, true, true);
ipoptApplication->Options()->SetNumericValue("bound_relax_factor", 1e-8, true, true);
ipoptApplication->Options()->SetStringValue("mu_strategy", "adaptive", true, true);
ipoptApplication->Options()->SetStringValue("ma86_order", "auto", true, true);
// ipoptApplication->Options()->SetStringValue("ma86_order", "auto", true, true);
ipoptApplication->Options()->SetStringValue("mu_oracle", "probing", true, true);
ipoptApplication->Options()->SetStringValue("expect_infeasible_problem", "yes", true, true);
// ipoptApplication->Options()->SetStringValue("warm_start_init_point", "yes", true, true);
ipoptApplication->Options()->SetStringValue("warm_start_init_point", "no", true,
true); // Cannot warm start since we do not have all required info, just a starting point
ipoptApplication->Options()->SetNumericValue("gamma_phi", 1e-8, true, true);
ipoptApplication->Options()->SetNumericValue("gamma_theta", 1e-4, true, true);
ipoptApplication->Options()->SetNumericValue("required_infeasibility_reduction", 0.1, true, true);
ipoptApplication->Options()->SetNumericValue("bound_relax_factor", 1e-10, true, true);
// ipoptApplication->Options()->SetStringValue("nlp_scaling_method", "none", true, true);
ipoptApplication->Options()->SetNumericValue(
"obj_scaling_factor", sourceProblem->objectiveFunction->properties.isMinimize ? 1.0 : -1.0, true, true);

// if we have linear constraint and a quadratic objective, then the hessian of the Lagrangian is constant, and
// Ipopt can make use of this
if(sourceProblem->properties.isMIQPProblem)
ipoptApplication->Options()->SetStringValue("hessian_constant", "yes", true, true);

ipoptApplication->Options()->GetNumericValue(
"diverging_iterates_tol", ipoptProblem->divergingIterativesTolerance, "");

setSolverSpecificInitialSettings();
}

Expand Down
4 changes: 2 additions & 2 deletions src/NLPSolver/NLPSolverIpoptBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ class IpoptProblem : public Ipopt::TNLP
const Ipopt::Number* lambda, bool new_lambda, Ipopt::Index nele_hess, Ipopt::Index* iRow, Ipopt::Index* jCol,
Ipopt::Number* values) override;

bool get_scaling_parameters(Ipopt::Number& obj_scaling, bool& use_x_scaling, Ipopt::Index n,
Ipopt::Number* x_scaling, bool& use_g_scaling, Ipopt::Index m, Ipopt::Number* g_scaling) override;
/*bool get_scaling_parameters(Ipopt::Number& obj_scaling, bool& use_x_scaling, Ipopt::Index n,
Ipopt::Number* x_scaling, bool& use_g_scaling, Ipopt::Index m, Ipopt::Number* g_scaling) override;*/

/** This method is called when the algorithm is complete so the TNLP can store/write the solution */
void finalize_solution(Ipopt::SolverReturn status, Ipopt::Index n, const Ipopt::Number* x, const Ipopt::Number* z_L,
Expand Down

0 comments on commit db906f4

Please sign in to comment.