Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Math_Opt x Highs enum update #4436

Open
Mizux opened this issue Nov 12, 2024 · 0 comments
Open

Math_Opt x Highs enum update #4436

Mizux opened this issue Nov 12, 2024 · 0 comments
Assignees
Labels
Bug Solver: HiGHS Issue specific to EDU HiGHS Solver: MathOpt MathOpt related issue
Milestone

Comments

@Mizux
Copy link
Collaborator

Mizux commented Nov 12, 2024

Seems we forget the management of the new enum: kInterrupt, kMemoryLimit,kMax

%bazel build -c opt //ortools/math_opt/...
INFO: Analyzed 262 targets (2 packages loaded, 171 targets configured).
INFO: From Compiling ortools/math_opt/solvers/highs_solver.cc:
ortools/math_opt/solvers/highs_solver.cc: In static member function 'static absl::lts_20240722::StatusOr<operations_research::math_opt::TerminationProto> operations_research::math_opt::HighsSolver::MakeTermination(HighsModelStatus, const HighsInfo&, bool, bool, bool, bool, SolutionClaims)':
ortools/math_opt/solvers/highs_solver.cc:491:10: warning: enumeration value 'kSolutionLimit' not handled in switch [-Wswitch]
  491 |   switch (highs_model_status) {
      |          ^
ortools/math_opt/solvers/highs_solver.cc:491:10: warning: enumeration value 'kInterrupt' not handled in switch [-Wswitch]
ortools/math_opt/solvers/highs_solver.cc:491:10: warning: enumeration value 'kMemoryLimit' not handled in switch [-Wswitch]
ortools/math_opt/solvers/highs_solver.cc:491:10: warning: enumeration value 'kMax' not handled in switch [-Wswitch]
INFO: From Compiling ortools/math_opt/solvers/highs_solver.cc:
ortools/math_opt/solvers/highs_solver.cc: In static member function 'static absl::lts_20240722::StatusOr<operations_research::math_opt::TerminationProto> operations_research::math_opt::HighsSolver::MakeTermination(HighsModelStatus, const HighsInfo&, bool, bool, bool, bool, SolutionClaims)':
ortools/math_opt/solvers/highs_solver.cc:491:10: warning: enumeration value 'kSolutionLimit' not handled in switch [-Wswitch]
  491 |   switch (highs_model_status) {
      |          ^
ortools/math_opt/solvers/highs_solver.cc:491:10: warning: enumeration value 'kInterrupt' not handled in switch [-Wswitch]
ortools/math_opt/solvers/highs_solver.cc:491:10: warning: enumeration value 'kMemoryLimit' not handled in switch [-Wswitch]
ortools/math_opt/solvers/highs_solver.cc:491:10: warning: enumeration value 'kMax' not handled in switch [-Wswitch]
INFO: From Compiling ortools/math_opt/cpp/variable_and_expressions.cc:
ortools/math_opt/cpp/variable_and_expressions.cc: In function 'std::ostream& operations_research::math_opt::operator<<(std::ostream&, const QuadraticExpression&)':
ortools/math_opt/cpp/variable_and_expressions.cc:160:19: warning: loop variable 'vs' creates a copy from type 'const operations_research::math_opt::QuadraticTermKey' [-Wrange-loop-construct]
  160 |   for (const auto vs : SortedKeys(expr.quadratic_terms())) {
      |                   ^~
ortools/math_opt/cpp/variable_and_expressions.cc:160:19: note: use reference type to prevent copying
  160 |   for (const auto vs : SortedKeys(expr.quadratic_terms())) {
      |                   ^~
      |                   &
INFO: From Compiling ortools/math_opt/cpp/variable_and_expressions.cc:
ortools/math_opt/cpp/variable_and_expressions.cc: In function 'std::ostream& operations_research::math_opt::operator<<(std::ostream&, const QuadraticExpression&)':
ortools/math_opt/cpp/variable_and_expressions.cc:160:19: warning: loop variable 'vs' creates a copy from type 'const operations_research::math_opt::QuadraticTermKey' [-Wrange-loop-construct]
  160 |   for (const auto vs : SortedKeys(expr.quadratic_terms())) {
      |                   ^~

source:

switch (highs_model_status) {
case HighsModelStatus::kNotset:
case HighsModelStatus::kLoadError:
case HighsModelStatus::kModelError:
case HighsModelStatus::kPresolveError:
case HighsModelStatus::kSolveError:
case HighsModelStatus::kPostsolveError:
case HighsModelStatus::kUnknown:
// Note: we actually deal with kModelEmpty separately in Solve(), this
// case should not be hit.
case HighsModelStatus::kModelEmpty:
return util::InternalErrorBuilder()
<< "HighsModelStatus was "
<< utilModelStatusToString(highs_model_status);
case HighsModelStatus::kOptimal: {
return OptimalTerminationProto(highs_info.objective_function_value,
DualObjective(highs_info, is_integer),
"HighsModelStatus is kOptimal");
}
case HighsModelStatus::kInfeasible:
// By convention infeasible MIPs are always dual feasible.
return InfeasibleTerminationProto(is_maximize,
/*dual_feasibility_status=*/is_integer
? FEASIBILITY_STATUS_FEASIBLE
: dual_feasibility_status);
case HighsModelStatus::kUnboundedOrInfeasible:
return InfeasibleOrUnboundedTerminationProto(
is_maximize, dual_feasibility_status,
"HighsModelStatus is kUnboundedOrInfeasible");
case HighsModelStatus::kUnbounded: {
// TODO(b/271104776): we should potentially always return
// TERMINATION_REASON_UNBOUNDED instead, we need to determine if
// HighsModelStatus::kUnbounded implies the problem is known to be primal
// feasible (for LP and MIP).
if (highs_info.primal_solution_status == ::kSolutionStatusFeasible) {
return UnboundedTerminationProto(is_maximize);
} else {
return InfeasibleOrUnboundedTerminationProto(
is_maximize,
/*dual_feasibility_status=*/FEASIBILITY_STATUS_INFEASIBLE,
"HighsModelStatus is kUnbounded");
}
}
case HighsModelStatus::kObjectiveBound:
return LimitTerminationProto(
is_maximize, LIMIT_OBJECTIVE, optional_finite_primal_objective,
optional_dual_objective, "HighsModelStatus is kObjectiveBound");
case HighsModelStatus::kObjectiveTarget:
return LimitTerminationProto(
is_maximize, LIMIT_OBJECTIVE, optional_finite_primal_objective,
optional_dual_objective, "HighsModelStatus is kObjectiveTarget");
case HighsModelStatus::kTimeLimit:
return LimitTerminationProto(is_maximize, LIMIT_TIME,
optional_finite_primal_objective,
optional_dual_objective);
case HighsModelStatus::kIterationLimit: {

@Mizux Mizux added Bug Solver: HiGHS Issue specific to EDU HiGHS Solver: MathOpt MathOpt related issue labels Nov 12, 2024
@Mizux Mizux added this to the v9.12 milestone Nov 12, 2024
@Mizux Mizux self-assigned this Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Solver: HiGHS Issue specific to EDU HiGHS Solver: MathOpt MathOpt related issue
Projects
Status: To do
Development

No branches or pull requests

1 participant