Merge branch 'main' of github.com:google/or-tools

This commit is contained in:
Laurent Perron
2025-04-25 19:03:15 +02:00
9 changed files with 274 additions and 103 deletions

View File

@@ -3,8 +3,9 @@ absl-py==2.1.0
immutabledict==3.0.0
numpy==2.2.0
protobuf==6.30.2
requests==2.32.0
requests==2.32.3
scipy==1.14.1
typing-extensions==4.13.1
# OR-Tools build dependencies
mypy==1.6.1
@@ -20,10 +21,10 @@ svgwrite==1.4.3
plotly==5.15.0
# Notebook
jupyterlab==4.2.5
notebook==7.2.2
jupyter-server==2.14.2
jupyterlab==4.4.1
notebook==7.4.1
jupyter-server==2.15.0
tornado==6.4.2
Pygments==2.15.0
jsonschema==4.19.0
jinja2==3.1.5
jinja2==3.1.6

View File

@@ -85,7 +85,7 @@ isoduration==20.11.0
# via jsonschema
jedi==0.19.0
# via ipython
jinja2==3.1.5
jinja2==3.1.6
# via
# -r bazel/notebook_requirements.in
# jupyter-server
@@ -118,11 +118,11 @@ jupyter-core==5.3.1
# nbclient
# nbconvert
# nbformat
jupyter-events==0.9.0
jupyter-events==0.12.0
# via jupyter-server
jupyter-lsp==2.2.2
# via jupyterlab
jupyter-server==2.14.2
jupyter-server==2.15.0
# via
# -r bazel/notebook_requirements.in
# jupyter-lsp
@@ -132,7 +132,7 @@ jupyter-server==2.14.2
# notebook-shim
jupyter-server-terminals==0.4.4
# via jupyter-server
jupyterlab==4.2.5
jupyterlab==4.4.1
# via
# -r bazel/notebook_requirements.in
# notebook
@@ -171,7 +171,7 @@ nbformat==5.9.2
# nbconvert
nest-asyncio==1.5.7
# via ipykernel
notebook==7.2.2
notebook==7.4.1
# via -r bazel/notebook_requirements.in
notebook-shim==0.2.3
# via
@@ -188,6 +188,7 @@ packaging==23.1
# via
# black
# ipykernel
# jupyter-events
# jupyter-server
# jupyterlab
# jupyterlab-server
@@ -256,7 +257,7 @@ referencing==0.30.2
# jsonschema
# jsonschema-specifications
# jupyter-events
requests==2.32.0
requests==2.32.3
# via
# -r bazel/notebook_requirements.in
# jupyterlab-server
@@ -325,8 +326,10 @@ traitlets==5.9.0
# nbformat
types-protobuf==4.24.0.0
# via mypy-protobuf
typing-extensions==4.8.0
# via mypy
typing-extensions==4.13.1
# via
# -r bazel/notebook_requirements.in
# mypy
tzdata==2023.3
# via pandas
uri-template==1.3.0

View File

@@ -5,6 +5,7 @@ numpy==2.2.0
protobuf==6.30.2
requests==2.32.3
scipy==1.14.1
typing-extensions==4.13.1
# OR-Tools build dependencies
mypy==1.6.1

View File

@@ -63,8 +63,10 @@ svgwrite==1.4.3
# via -r bazel/ortools_requirements.in
types-protobuf==4.24.0.0
# via mypy-protobuf
typing-extensions==4.8.0
# via mypy
typing-extensions==4.13.1
# via
# -r bazel/ortools_requirements.in
# mypy
tzdata==2023.3
# via pandas
urllib3==2.2.2

View File

@@ -14,6 +14,7 @@
"""Build definitions for SWIG Java."""
load("@bazel_skylib//lib:paths.bzl", "paths")
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_java//java:java_library.bzl", "java_library")
load("@rules_java//java/common:java_common.bzl", "java_common")
@@ -195,8 +196,7 @@ def ortools_java_wrap_cc(
visibility = ["//visibility:private"],
**kwargs
)
native.cc_library(
cc_library(
name = cc_name,
srcs = [outfile],
hdrs = [outhdr] if use_directors else [],

View File

@@ -184,86 +184,86 @@ Following is a list of available options, for the full list run:
cmake -S. -Bbuild -LH
```
| CMake Option | Default Value | Note |
|:-------------|:--------------|:-----|
| `CMAKE_BUILD_TYPE` | Release | see CMake documentation [here](https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html) |
| `BUILD_CXX` | ON | Build C++ |
| `BUILD_DOTNET` | OFF | Build .Net wrapper and packages |
| `BUILD_JAVA` | OFF | Build Java wrapper and packages |
| `BUILD_PYTHON` | OFF | Build Python wrapper and package |
| | | |
| `BUILD_FLATZINC` | ON\* | Build the flatzinc library<br>**Forced** to OFF if `BUILD_CXX=OFF` |
| `BUILD_GLOP` | OFF\* | Build the standalone Glop library<br>**Forced** to OFF if `BUILD_CXX=ON`, otherwise default to ON |
| | | |
| `BUILD_DEPS` | OFF* | Default to ON if `BUILD_JAVA=ON` or `BUILD_PYTHON=ON` or `BUILD_DOTNET=ON` |
| `BUILD_ZLIB` | OFF* | Build the zlib dynamic library<br>**Forced** to ON if `BUILD_DEPS=ON` |
| `BUILD_BZip2` | OFF* | Build the bzip2 dynamic library<br>**Forced** to ON if `BUILD_DEPS=ON` |
| `BUILD_absl` | OFF* | Build the abseil-cpp dynamic libraries<br>**Forced** to ON if `BUILD_DEPS=ON` |
| `BUILD_Protobuf` | OFF* | Build the protobuf dynamic libraries<br>**Forced** to ON if `BUILD_DEPS=ON` |
| `BUILD_re2` | OFF* | Build the re2 dynamic libraries<br>**Forced** to ON if `BUILD_DEPS=ON` |
| `BUILD_Eigen3` | OFF* | Build the Eigen3 libraries<br>**Forced** to ON if `BUILD_DEPS=ON` |
| | | |
| `USE_COINOR` | ON\* | Enable Coin-OR support<br>**Forced** to OFF if `BUILD_CXX=OFF` |
| `BUILD_CoinUtils` | OFF\* | Build the CoinUtils dynamic library<br>**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON` |
| `BUILD_Osi` | OFF\* | Build the Osi dynamic library<br>**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON` |
| `BUILD_Clp` | OFF\* | Build the Clp dynamic library<br>**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON` |
| `BUILD_Cgl` | OFF\* | Build the Cgl dynamic library<br>**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON` |
| `BUILD_Cbc` | OFF\* | Build the Cbc dynamic library<br>**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON` |
| | | |
| `USE_GLPK` | OFF\* | Enable GLPK support<br>**Forced** to OFF if `BUILD_CXX=OFF` |
| `BUILD_GLPK` | OFF\* | Build the GLPK dynamic libraries<br>**Forced** to ON if `USE_GLPK=ON` **and** `BUILD_DEPS=ON` |
| | | |
| `USE_HIGHS` | ON\* | Enable HIGHS support<br>**Forced** to OFF if `BUILD_CXX=OFF` |
| `BUILD_HIGHS` | OFF\* | Build the HiGHS dynamic libraries<br>**Forced** to ON if `USE_HIGHS=ON` **and** `BUILD_DEPS=ON` |
| | | |
| `USE_SCIP` | ON\* | Enable SCIP support<br>**Forced** to OFF if `BUILD_CXX=OFF` |
| `BUILD_SCIP` | OFF\* | Build the SCIP dynamic libraries<br>**Forced** to ON if `USE_SCIP=ON` **and** `BUILD_DEPS=ON` |
| | | |
| `USE_CPLEX` | OFF | Enable CPLEX support |
| | | |
| `BUILD_DOC` | OFF\* | Build all documentations |
| `BUILD_CXX_DOC` | OFF\* | Build C++ documentation<br>**Forced** to ON if `BUILD_DOC=ON` |
| `BUILD_DOTNET_DOC` | OFF\* | Build .Net documentation<br>**Forced** to ON if `BUILD_DOC=ON` |
| `BUILD_JAVA_DOC` | OFF\* | Build Java documentation<br>**Forced** to ON if `BUILD_DOC=ON` |
| `BUILD_PYTHON_DOC` | OFF\* | Build Python documentation<br>**Forced** to ON if `BUILD_DOC=ON` |
| `INSTALL_DOC` | OFF\* | Install all documentations<br>**Forced** to OFF if `BUILD_CXX=OFF` or `BUILD_DOC=OFF` |
| | | |
| `BUILD_SAMPLES` | ON\* | Build all samples<br>Default to ON if `BUILD_DEPS=ON` |
| `BUILD_CXX_SAMPLES` | ON\* | Build all C++ samples<br>**Forced** to OFF if `BUILD_CXX=OFF` or `BUILD_SAMPLE=OFF` |
| `BUILD_DOTNET_SAMPLES` | ON\* | Build all .Net samples<br>**Forced** to OFF if `BUILD_DOTNET=OFF` or `BUILD_SAMPLE=OFF` |
| `BUILD_JAVA_SAMPLES` | ON\* | Build all Java samples<br>**Forced** to OFF if `BUILD_JAVA=OFF` or `BUILD_SAMPLE=OFF` |
| `BUILD_PYTHON_SAMPLES` | ON\* | Build all Python samples<br>**Forced** to OFF if `BUILD_PYTHON=OFF` or `BUILD_SAMPLE=OFF` |
| | | |
| `BUILD_EXAMPLES` | ON\* | Build all examples<br>Default to ON if `BUILD_DEPS=ON` |
| `BUILD_CXX_EXAMPLES` | ON\* | Build all C++ examples<br>**Forced** to OFF if `BUILD_CXX=OFF` or `BUILD_SAMPLE=OFF` |
| `BUILD_DOTNET_EXAMPLES` | ON\* | Build all .Net examples<br>**Forced** to OFF if `BUILD_DOTNET=OFF` or `BUILD_SAMPLE=OFF` |
| `BUILD_JAVA_EXAMPLES` | ON\* | Build all Java examples<br>**Forced** to OFF if `BUILD_JAVA=OFF` or `BUILD_SAMPLE=OFF` |
| `BUILD_PYTHON_EXAMPLES` | ON\* | Build all Python examples<br>**Forced** to OFF if `BUILD_PYTHON=OFF` or `BUILD_SAMPLE=OFF` |
| | | |
| `USE_DOTNET_46` | OFF | Enable .Net Framework 4.6 support<br>Only available if `BUILD_DOTNET=ON` |
| `USE_DOTNET_461` | OFF | Enable .Net Framework 4.6.1 support<br>Only available if `BUILD_DOTNET=ON` |
| `USE_DOTNET_462` | OFF | Enable .Net Framework 4.6.2 support<br>Only available if `BUILD_DOTNET=ON` |
| `USE_DOTNET_48` | OFF | Enable .Net Framework 4.8 support<br>Only available if `BUILD_DOTNET=ON` |
| `USE_DOTNET_STD_21` | OFF | Enable .Net Standard 2.1 support<br>Only available if `BUILD_DOTNET=ON` and not targeting arm64 platform |
| `USE_DOTNET_CORE_31` | OFF | Enable .Net Core 3.1 LTS support<br>Only available if `BUILD_DOTNET=ON` and not targeting arm64 platform |
| `USE_DOTNET_6` | OFF | Enable .Net 6 LTS support<br>Only available if `BUILD_DOTNET=ON` |
| `USE_DOTNET_7` | OFF | Enable .Net 7 support<br>Only available if `BUILD_DOTNET=ON` |
| `USE_DOTNET_8` | ON | Enable .Net 8 LTS support<br>Only available if `BUILD_DOTNET=ON` |
| `USE_DOTNET_9` | OFF | Enable .Net 9 support<br>Only available if `BUILD_DOTNET=ON` |
| `UNIVERSAL_DOTNET_PACKAGE` | OFF | Build a multi platform package (i.e. `Google.OrTools` will depends on all runtime packages)<br>Only available if `BUILD_DOTNET=ON` |
| | | |
| `SKIP_GPG` | ON | Disable GPG sign<br>Only available if `BUILD_JAVA=ON` |
| `UNIVERSAL_JAVA_PACKAGE` | OFF | Build a multi platform package (i.e. `ortools-java` will depends on all native packages)<br>Only available if `BUILD_JAVA=ON` |
| `BUILD_FAT_JAR` | OFF | Build a `ortools-java` .jar that includes all of its own Maven dependencies, including the native package<br>Only available if `BUILD_JAVA=ON` |
| | | |
| `BUILD_pybind11` | `BUILD_DEPS` | Static build the pybind11 libraries<br>**Forced** to ON if `BUILD_DEPS=ON`<br>Only available if `BUILD_PYTHON=ON` |
| `BUILD_pybind11_abseil` | `BUILD_DEPS` | Static build the pybind11_abseil libraries<br>**Forced** to ON if `BUILD_DEPS=ON`<br>Only available if `BUILD_PYTHON=ON` |
| `BUILD_pybind11_protobuf` | `BUILD_DEPS` | Static build the pybind11_protobuf libraries<br>**Forced** to ON if `BUILD_DEPS=ON`<br>Only available if `BUILD_PYTHON=ON` |
| `GENERATE_PYTHON_STUB` | ON | Generate python stub files<br>Only available if `BUILD_PYTHON=ON` |
| `BUILD_VENV` | `BUILD_TESTING` | Create python venv in `BINARY_DIR/python/venv`<br>**Forced** to ON if `BUILD_TESTING=ON`<br>Only available if `BUILD_PYTHON=ON` |
| `VENV_USE_SYSTEM_SITE_PACKAGES` | OFF | Python venv can use system site package (e.g. `py3-numpy` on Alpine)<br>Only available if `BUILD_PYTHON=ON` and `BUILD_VENV=ON` |
| `FETCH_PYTHON_DEPS` | `BUILD_DEPS` | Fetch python modules needed to build ortools package<br>Only available if `BUILD_PYTHON=ON` |
| | | |
CMake Option | Default Value | Note
:------------------------------ | :-------------- | :---
`CMAKE_BUILD_TYPE` | Release | see CMake documentation [here](https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html)
`BUILD_CXX` | ON | Build C++
`BUILD_DOTNET` | OFF | Build .Net wrapper and packages
`BUILD_JAVA` | OFF | Build Java wrapper and packages
`BUILD_PYTHON` | OFF | Build Python wrapper and package
| |
`BUILD_FLATZINC` | ON\* | Build the flatzinc library<br>**Forced** to OFF if `BUILD_CXX=OFF`
`BUILD_GLOP` | OFF\* | Build the standalone Glop library<br>**Forced** to OFF if `BUILD_CXX=ON`, otherwise default to ON
| |
`BUILD_DEPS` | OFF* | Default to ON if `BUILD_JAVA=ON` or `BUILD_PYTHON=ON` or `BUILD_DOTNET=ON`
`BUILD_ZLIB` | OFF* | Build the zlib dynamic library<br>**Forced** to ON if `BUILD_DEPS=ON`
`BUILD_BZip2` | OFF* | Build the bzip2 dynamic library<br>**Forced** to ON if `BUILD_DEPS=ON`
`BUILD_absl` | OFF* | Build the abseil-cpp dynamic libraries<br>**Forced** to ON if `BUILD_DEPS=ON`
`BUILD_Protobuf` | OFF* | Build the protobuf dynamic libraries<br>**Forced** to ON if `BUILD_DEPS=ON`
`BUILD_re2` | OFF* | Build the re2 dynamic libraries<br>**Forced** to ON if `BUILD_DEPS=ON`
`BUILD_Eigen3` | OFF* | Build the Eigen3 libraries<br>**Forced** to ON if `BUILD_DEPS=ON`
| |
`USE_COINOR` | ON\* | Enable Coin-OR support<br>**Forced** to OFF if `BUILD_CXX=OFF`
`BUILD_CoinUtils` | OFF\* | Build the CoinUtils dynamic library<br>**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON`
`BUILD_Osi` | OFF\* | Build the Osi dynamic library<br>**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON`
`BUILD_Clp` | OFF\* | Build the Clp dynamic library<br>**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON`
`BUILD_Cgl` | OFF\* | Build the Cgl dynamic library<br>**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON`
`BUILD_Cbc` | OFF\* | Build the Cbc dynamic library<br>**Forced** to ON if `USE_COINOR=ON` **and** `BUILD_DEPS=ON`
| |
`USE_GLPK` | OFF\* | Enable GLPK support<br>**Forced** to OFF if `BUILD_CXX=OFF`
`BUILD_GLPK` | OFF\* | Build the GLPK dynamic libraries<br>**Forced** to ON if `USE_GLPK=ON` **and** `BUILD_DEPS=ON`
| |
`USE_HIGHS` | ON\* | Enable HIGHS support<br>**Forced** to OFF if `BUILD_CXX=OFF`
`BUILD_HIGHS` | OFF\* | Build the HiGHS dynamic libraries<br>**Forced** to ON if `USE_HIGHS=ON` **and** `BUILD_DEPS=ON`
| |
`USE_SCIP` | ON\* | Enable SCIP support<br>**Forced** to OFF if `BUILD_CXX=OFF`
`BUILD_SCIP` | OFF\* | Build the SCIP dynamic libraries<br>**Forced** to ON if `USE_SCIP=ON` **and** `BUILD_DEPS=ON`
| |
`USE_CPLEX` | OFF | Enable CPLEX support
| |
`BUILD_DOC` | OFF\* | Build all documentations
`BUILD_CXX_DOC` | OFF\* | Build C++ documentation<br>**Forced** to ON if `BUILD_DOC=ON`
`BUILD_DOTNET_DOC` | OFF\* | Build .Net documentation<br>**Forced** to ON if `BUILD_DOC=ON`
`BUILD_JAVA_DOC` | OFF\* | Build Java documentation<br>**Forced** to ON if `BUILD_DOC=ON`
`BUILD_PYTHON_DOC` | OFF\* | Build Python documentation<br>**Forced** to ON if `BUILD_DOC=ON`
`INSTALL_DOC` | OFF\* | Install all documentations<br>**Forced** to OFF if `BUILD_CXX=OFF` or `BUILD_DOC=OFF`
| |
`BUILD_SAMPLES` | ON\* | Build all samples<br>Default to ON if `BUILD_DEPS=ON`
`BUILD_CXX_SAMPLES` | ON\* | Build all C++ samples<br>**Forced** to OFF if `BUILD_CXX=OFF` or `BUILD_SAMPLE=OFF`
`BUILD_DOTNET_SAMPLES` | ON\* | Build all .Net samples<br>**Forced** to OFF if `BUILD_DOTNET=OFF` or `BUILD_SAMPLE=OFF`
`BUILD_JAVA_SAMPLES` | ON\* | Build all Java samples<br>**Forced** to OFF if `BUILD_JAVA=OFF` or `BUILD_SAMPLE=OFF`
`BUILD_PYTHON_SAMPLES` | ON\* | Build all Python samples<br>**Forced** to OFF if `BUILD_PYTHON=OFF` or `BUILD_SAMPLE=OFF`
| |
`BUILD_EXAMPLES` | ON\* | Build all examples<br>Default to ON if `BUILD_DEPS=ON`
`BUILD_CXX_EXAMPLES` | ON\* | Build all C++ examples<br>**Forced** to OFF if `BUILD_CXX=OFF` or `BUILD_SAMPLE=OFF`
`BUILD_DOTNET_EXAMPLES` | ON\* | Build all .Net examples<br>**Forced** to OFF if `BUILD_DOTNET=OFF` or `BUILD_SAMPLE=OFF`
`BUILD_JAVA_EXAMPLES` | ON\* | Build all Java examples<br>**Forced** to OFF if `BUILD_JAVA=OFF` or `BUILD_SAMPLE=OFF`
`BUILD_PYTHON_EXAMPLES` | ON\* | Build all Python examples<br>**Forced** to OFF if `BUILD_PYTHON=OFF` or `BUILD_SAMPLE=OFF`
| |
`USE_DOTNET_46` | OFF | Enable .Net Framework 4.6 support<br>Only available if `BUILD_DOTNET=ON`
`USE_DOTNET_461` | OFF | Enable .Net Framework 4.6.1 support<br>Only available if `BUILD_DOTNET=ON`
`USE_DOTNET_462` | OFF | Enable .Net Framework 4.6.2 support<br>Only available if `BUILD_DOTNET=ON`
`USE_DOTNET_48` | OFF | Enable .Net Framework 4.8 support<br>Only available if `BUILD_DOTNET=ON`
`USE_DOTNET_STD_21` | OFF | Enable .Net Standard 2.1 support<br>Only available if `BUILD_DOTNET=ON` and not targeting arm64 platform
`USE_DOTNET_CORE_31` | OFF | Enable .Net Core 3.1 LTS support<br>Only available if `BUILD_DOTNET=ON` and not targeting arm64 platform
`USE_DOTNET_6` | OFF | Enable .Net 6 LTS support<br>Only available if `BUILD_DOTNET=ON`
`USE_DOTNET_7` | OFF | Enable .Net 7 support<br>Only available if `BUILD_DOTNET=ON`
`USE_DOTNET_8` | ON | Enable .Net 8 LTS support<br>Only available if `BUILD_DOTNET=ON`
`USE_DOTNET_9` | OFF | Enable .Net 9 support<br>Only available if `BUILD_DOTNET=ON`
`UNIVERSAL_DOTNET_PACKAGE` | OFF | Build a multi platform package (i.e. `Google.OrTools` will depends on all runtime packages)<br>Only available if `BUILD_DOTNET=ON`
| |
`SKIP_GPG` | ON | Disable GPG sign<br>Only available if `BUILD_JAVA=ON`
`UNIVERSAL_JAVA_PACKAGE` | OFF | Build a multi platform package (i.e. `ortools-java` will depends on all native packages)<br>Only available if `BUILD_JAVA=ON`
`BUILD_FAT_JAR` | OFF | Build a `ortools-java` .jar that includes all of its own Maven dependencies, including the native package<br>Only available if `BUILD_JAVA=ON`
| |
`BUILD_pybind11` | `BUILD_DEPS` | Static build the pybind11 libraries<br>**Forced** to ON if `BUILD_DEPS=ON`<br>Only available if `BUILD_PYTHON=ON`
`BUILD_pybind11_abseil` | `BUILD_DEPS` | Static build the pybind11_abseil libraries<br>**Forced** to ON if `BUILD_DEPS=ON`<br>Only available if `BUILD_PYTHON=ON`
`BUILD_pybind11_protobuf` | `BUILD_DEPS` | Static build the pybind11_protobuf libraries<br>**Forced** to ON if `BUILD_DEPS=ON`<br>Only available if `BUILD_PYTHON=ON`
`GENERATE_PYTHON_STUB` | ON | Generate python stub files<br>Only available if `BUILD_PYTHON=ON`
`BUILD_VENV` | `BUILD_TESTING` | Create python venv in `BINARY_DIR/python/venv`<br>**Forced** to ON if `BUILD_TESTING=ON`<br>Only available if `BUILD_PYTHON=ON`
`VENV_USE_SYSTEM_SITE_PACKAGES` | OFF | Python venv can use system site package (e.g. `py3-numpy` on Alpine)<br>Only available if `BUILD_PYTHON=ON` and `BUILD_VENV=ON`
`FETCH_PYTHON_DEPS` | `BUILD_DEPS` | Fetch python modules needed to build ortools package<br>Only available if `BUILD_PYTHON=ON`
| |
## Integrating OR-Tools in your CMake Project

View File

@@ -33,6 +33,6 @@ target_link_libraries(${NAME} PRIVATE
absl::strings
absl::str_format
protobuf::libprotobuf
$<$<BOOL:${USE_SCIP}>:libscip>
SCIP::libscip
${PROJECT_NAMESPACE}::ortools_proto)
#add_library(${PROJECT_NAMESPACE}::gscip ALIAS ${NAME})

View File

@@ -1924,3 +1924,164 @@ function MOI.optimize!(model::Optimizer)
return nothing
end
function MOI.get(model::Optimizer, ::MOI.RawStatusString)::String
if !isnothing(model) && !isnothing(model.solve_result)
return string(model.solve_result.termination.reason)
end
return ""
end
"""
Additional, typically solver-specific information about termination.
"""
struct ExtraTerminationDetailString <: MOI.AbstractOptimizerAttribute end
MOI.attribute_value_type(::ExtraTerminationDetailString) = String
function MOI.get(model::Optimizer, ::ExtraTerminationDetailString)::String
if !isnothing(model) && !isnothing(model.solve_result)
return model.solve_result.termination.detail
end
return ""
end
function MOI.get(model::Optimizer, ::MOI.TerminationStatus)::MOI.TerminationStatusCode
if isnothing(model) || isnothing(model.solve_result)
return MOI.OPTIMIZE_NOT_CALLED
end
if model.solve_result.termination.reason ==
TerminationReasonProto.TERMINATION_REASON_OPTIMAL
# It is expected that the LimitProto is LIMIT_UNSPECIFIED when the termination reason is OPTIMAL.
return MOI.OPTIMAL
elseif model.solve_result.termination.limit == LimitProto.LIMIT_ITERATION
return MOI.ITERATION_LIMIT
elseif model.solve_result.termination.limit == LimitProto.LIMIT_TIME
return MOI.TIME_LIMIT
elseif model.solve_result.termination.limit == LimitProto.LIMIT_NODE
return MOI.NODE_LIMIT
elseif model.solve_result.termination.limit == LimitProto.LIMIT_SOLUTION
return MOI.SOLUTION_LIMIT
elseif model.solve_result.termination.limit == LimitProto.LIMIT_MEMORY
return MOI.MEMORY_LIMIT
elseif model.solve_result.termination.limit == LimitProto.LIMIT_OBJECTIVE
return MOI.OBJECTIVE_LIMIT
elseif model.solve_result.termination.limit == LimitProto.LIMIT_NORM
return MOI.NORM_LIMIT
elseif model.solve_result.termination.limit == LimitProto.LIMIT_INTERRUPTED
return MOI.INTERRUPTED
elseif model.solve_result.termination.limit == LimitProto.LIMIT_SLOW_PROGRESS
return MOI.SLOW_PROGRESS
elseif model.solve_result.termination.limit == LimitProto.LIMIT_OTHER
return MOI.OTHER_LIMIT
elseif model.solve_result.termination.limit == LimitProto.LIMIT_UNDETERMINED
# TODO: b/411325865 Follow up on support for LIMIT_UNDETERMINED in MOI.jl
# A fallback as there's currently no associated MOI.LIMIT_* that can represent this.
@info "The underlying solver does not expose which limit was reached and the actual limit is LIMIT_UNDETERMINED " \
"However, LIMIT_UNDETERMINED is not associated with a MOI.LIMIT_* hence the returned LIMIT is MOI.OTHER_LIMIT."
return MOI.OTHER_LIMIT
elseif model.solve_result.termination.limit == LimitProto.LIMIT_CUTOFF
# TODO: b/411328356 Follow up on support for LIMIT_CUTOFF in MOI.jl
# A fallback as there's currently no associated MOI.LIMIT_* that can represent this.
@info "The solver was run with a cutoff on the objective, indicating that the user did not want any solution " \
"worse than the cutoff, and the solver concluded there were no solutions at least as good as the cutoff. " \
"Typically no further solution information is provided. The actual limit is LIMIT_CUTOFF. " \
"However, LIMIT_CUTOFF is not associated with a MOI.LIMIT_* hence the returned LIMIT is MOI.OTHER_LIMIT."
return MOI.OTHER_LIMIT
else
# TODO: b/411328207 Add attribute to capture more information about the limit when LIMIT_UNSPECIFIED is the returned limit.
# The else bit falls back to MOI.LIMIT_UNSPECIFIED if the termination reason wasn't TERMINATION_REASON_OPTIMAL
@info "The solver terminated but not from a limit and the actual limit is LIMIT_UNSPECIFIED, which is used as a null. " \
"However, LIMIT_UNSPECIFIED is not associated with a MOI.LIMIT_* hence the returned LIMIT is MOI.OTHER_LIMIT."
return MOI.OTHER_LIMIT
end
end
function MOI.get(model::Optimizer, attr::MOI.PrimalStatus)
if isnothing(model) || isnothing(model.solve_result)
return MOI.NO_SOLUTION
end
if attr.result_index != 1
return MOI.NO_SOLUTION
elseif model.solve_result.termination.problem_status.primal_status ==
FeasibilityStatusProto.FEASIBILITY_STATUS_UNDETERMINED
return MOI.UNKNOWN_RESULT_STATUS
elseif model.solve_result.termination.problem_status.primal_status ==
FeasibilityStatusProto.FEASIBILITY_STATUS_FEASIBLE
return MOI.FEASIBLE_POINT
elseif model.solve_result.termination.problem_status.primal_status ==
FeasibilityStatusProto.FEASIBILITY_STATUS_INFEASIBLE
return MOI.INFEASIBLE_POINT
else
# For FEASIBILITY_STATUS_UNSPECIFIED which is a guard value representing no status
return MOI.NO_SOLUTION
end
end
function MOI.get(model::Optimizer, attr::MOI.DualStatus)
if isnothing(model) || isnothing(model.solve_result)
return MOI.NO_SOLUTION
end
if attr.result_index != 1
return MOI.NO_SOLUTION
elseif model.solve_result.termination.problem_status.dual_status ==
FeasibilityStatusProto.FEASIBILITY_STATUS_UNDETERMINED
return MOI.UNKNOWN_RESULT_STATUS
elseif model.solve_result.termination.problem_status.dual_status ==
FeasibilityStatusProto.FEASIBILITY_STATUS_FEASIBLE
return MOI.FEASIBLE_SOLUTION
elseif model.solve_result.termination.problem_status.dual_status ==
FeasibilityStatusProto.FEASIBILITY_STATUS_INFEASIBLE
return MOI.INFEASIBLE_SOLUTION
else
# For FEASIBILITY_STATUS_UNSPECIFIED which is a guard value representing no status
return MOI.NO_SOLUTION
end
end
"""
When the solver claims the the primal or dual problem is infeasible, but
it does not know which (or if both are infeasible), this attribute returns `true`.
It can be true only when primal_status = dual_status = FEASIBILITY_STATUS_UNDETERMINED
(mapped to MOI.UNKNOWN_RESULT_STATUS). This extra information is often needed when
preprocessing determines there is no optimal solution to the problem
(but can't determine if it is due to infeasibility, unboundedness, or both).
"""
struct PrimalOrDualInfeasible <: MOI.AbstractOptimizerAttribute end
MOI.attribute_value_type(::PrimalOrDualInfeasible) = Bool
function MOI.get(model::Optimizer, ::PrimalOrDualInfeasible)::Bool
if isnothing(model) || isnothing(model.solve_result)
return false
end
return model.solve_result.termination.problem_status.primal_status.primal_or_dual_infeasible
end
function MOI.get(model::Optimizer, attr::MOI.ObjectiveBound)
if isnothing(model) || isnothing(model.solve_result)
throw(MOI.GetAttributeNotAllowed(attr))
end
return model.solve_result.termination.objective_bounds.primal_bound
end
"""
When the solver claims there exists a dual solution that is numerically feasible
(i.e. feasible up to the solvers tolerance), and whose objective value is
dual_bound, this attribute returns the dual bound.
"""
struct DualObjectiveBound <: MOI.AbstractOptimizerAttribute end
MOI.attribute_value_type(::DualObjectiveBound) = Float64
function MOI.get(model::Optimizer, attr::DualObjectiveBound)
if isnothing(model) || isnothing(model.solve_result)
throw(MOI.GetAttributeNotAllowed(attr))
end
return model.solve_result.termination.objective_bounds.dual_bound
end

View File

@@ -3,6 +3,9 @@ const OperationsResearch = ORToolsGenerated.Proto.operations_research
const MathOpt = OperationsResearch.math_opt
const SolverType = MathOpt.SolverTypeProto
const SolveResultProto = MathOpt.SolveResultProto
const TerminationReasonProto = MathOpt.TerminationReasonProto
const LimitProto = MathOpt.LimitProto
const FeasibilityStatusProto = MathOpt.FeasibilityStatusProto
const PB = MathOpt.PB
"""
@@ -933,7 +936,7 @@ mutable struct SatParameters <: AbstractSatParameters
exploit_objective::Bool
probing_period_at_root::Int64
use_probing_search::Bool
shaving_deterministic_time_in_probing_search::Float64
use_shaving_in_probing_search::Bool
shaving_search_deterministic_time::Float64
use_objective_lb_search::Bool
use_objective_shaving_search::Bool
@@ -1154,8 +1157,8 @@ mutable struct SatParameters <: AbstractSatParameters
exploit_objective = true,
probing_period_at_root = Int64(0),
use_probing_search = false,
shaving_deterministic_time_in_probing_search = Float64(0.001),
shaving_search_deterministic_time = Float64(0.1),
use_shaving_in_probing_search = true,
shaving_search_deterministic_time = Float64(0.001),
use_objective_lb_search = false,
use_objective_shaving_search = false,
pseudo_cost_reliability_threshold = Int64(100),
@@ -1375,7 +1378,7 @@ mutable struct SatParameters <: AbstractSatParameters
exploit_objective,
probing_period_at_root,
use_probing_search,
shaving_deterministic_time_in_probing_search,
use_shaving_in_probing_search,
shaving_search_deterministic_time,
use_objective_lb_search,
use_objective_shaving_search,
@@ -1603,7 +1606,7 @@ function to_proto_struct(
sat_parameters.exploit_objective,
sat_parameters.probing_period_at_root,
sat_parameters.use_probing_search,
sat_parameters.shaving_deterministic_time_in_probing_search,
sat_parameters.use_shaving_in_probing_search,
sat_parameters.shaving_search_deterministic_time,
sat_parameters.use_objective_lb_search,
sat_parameters.use_objective_shaving_search,