Sync g3 -> gh Part 3

This commit is contained in:
Corentin Le Molgat
2020-03-10 08:38:00 +01:00
parent 22356ff523
commit 2d8c863c2a
33 changed files with 864 additions and 412 deletions

View File

@@ -128,11 +128,11 @@ cc_library(
"//ortools/base",
"//ortools/base:canonical_errors",
"//ortools/base:status",
"@com_google_absl//absl/strings",
"//ortools/graph",
"//ortools/graph:iterators",
"//ortools/graph:util",
"//ortools/util:stats",
"//ortools/util:time_limit",
"@com_google_absl//absl/strings",
],
)

View File

@@ -2,7 +2,7 @@ file(GLOB _SRCS "*.h" "*.cc")
list(REMOVE_ITEM _SRCS
${CMAKE_CURRENT_SOURCE_DIR}/hungarian_test.cc
${CMAKE_CURRENT_SOURCE_DIR}/hungarian_test.h
)
)
set(NAME ${PROJECT_NAME}_algorithms)
@@ -14,7 +14,7 @@ set_target_properties(${NAME} PROPERTIES
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON
)
)
# CMake < 3.12: CMakeError: Object library may not link to anything.
#target_link_libraries(${NAME} PRIVATE
# absl::memory absl::str_format
@@ -22,33 +22,33 @@ set_target_properties(${NAME} PROPERTIES
# protobuf::libprotobuf
# ${PROJECT_NAME}::proto)
target_include_directories(${NAME} PRIVATE
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
$<TARGET_PROPERTY:absl::memory,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:glog::glog,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_INCLUDE_DIRECTORIES>)
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
$<TARGET_PROPERTY:absl::memory,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:glog::glog,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_INCLUDE_DIRECTORIES>)
target_compile_options(${NAME} PRIVATE
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_OPTIONS>
)
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_OPTIONS>
)
target_compile_definitions(${NAME} PRIVATE
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_DEFINITIONS>
)
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_DEFINITIONS>
)
add_dependencies(${NAME}
absl::memory absl::str_format
gflags::gflags glog::glog
protobuf::libprotobuf
protobuf::libprotobuf
${PROJECT_NAME}::proto)
add_library(${PROJECT_NAME}::algorithms ALIAS ${NAME})

View File

@@ -1,3 +1,5 @@
package(default_visibility = ["//visibility:public"])
cc_proto_library(
@@ -33,7 +35,7 @@ cc_library(
"//ortools/base:int_type_indexed_vector",
"@com_google_absl//absl/synchronization",
"//ortools/glop:lp_solver",
# "//ortools/glop",
# "//ortools/glop",
"//ortools/lp_data:base",
"//ortools/sat:boolean_problem",
"//ortools/sat:boolean_problem_cc_proto",

View File

@@ -9,7 +9,7 @@ set_target_properties(${NAME} PROPERTIES
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON
)
)
# CMake < 3.12: CMakeError: Object library may not link to anything.
#target_link_libraries(${NAME} PRIVATE
# absl::memory absl::synchronization absl::str_format
@@ -17,36 +17,36 @@ set_target_properties(${NAME} PROPERTIES
# protobuf::libprotobuf
# ${PROJECT_NAME}::proto)
target_include_directories(${NAME} PRIVATE
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
$<TARGET_PROPERTY:absl::memory,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::synchronization,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:glog::glog,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_INCLUDE_DIRECTORIES>)
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
$<TARGET_PROPERTY:absl::memory,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::synchronization,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:glog::glog,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_INCLUDE_DIRECTORIES>)
target_compile_options(${NAME} PRIVATE
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::synchronization,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_OPTIONS>
)
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::synchronization,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_OPTIONS>
)
target_compile_definitions(${NAME} PRIVATE
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::synchronization,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_DEFINITIONS>
)
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::synchronization,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_DEFINITIONS>
)
add_dependencies(${NAME}
absl::memory absl::synchronization absl::str_format
gflags::gflags glog::glog
protobuf::libprotobuf
protobuf::libprotobuf
${PROJECT_NAME}::proto)
add_library(${PROJECT_NAME}::bop ALIAS ${NAME})

View File

@@ -9,7 +9,7 @@ set_target_properties(${NAME} PROPERTIES
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON
)
)
# CMake < 3.12: CMakeError: Object library may not link to anything.
#target_link_libraries(${NAME} PRIVATE
# ZLIB::ZLIB
@@ -18,44 +18,44 @@ set_target_properties(${NAME} PROPERTIES
# protobuf::libprotobuf
# ${PROJECT_NAME}::proto)
target_include_directories(${NAME} PRIVATE
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
$<TARGET_PROPERTY:ZLIB::ZLIB,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::base,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::memory,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::container,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::strings,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:glog::glog,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_INCLUDE_DIRECTORIES>)
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
$<TARGET_PROPERTY:ZLIB::ZLIB,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::base,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::memory,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::container,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::strings,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:glog::glog,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_INCLUDE_DIRECTORIES>)
target_compile_options(${NAME} PRIVATE
$<TARGET_PROPERTY:ZLIB::ZLIB,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::base,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_OPTIONS>
)
$<TARGET_PROPERTY:ZLIB::ZLIB,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::base,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_OPTIONS>
)
target_compile_definitions(${NAME} PRIVATE
$<TARGET_PROPERTY:ZLIB::ZLIB,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::base,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_DEFINITIONS>
)
$<TARGET_PROPERTY:ZLIB::ZLIB,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::base,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_DEFINITIONS>
)
add_dependencies(${NAME}
ZLIB::ZLIB
ZLIB::ZLIB
absl::base absl::memory absl::container absl::strings absl::str_format
gflags::gflags glog::glog
protobuf::libprotobuf

View File

@@ -192,7 +192,7 @@ class RoutingGlopWrapper : public RoutingLinearSolverWrapper {
// RoutingDimension but we would need to store cumul offsets and use them
// when checking intervals).
allowed_intervals_[index] =
absl::MakeUnique<SortedDisjointIntervalList>(starts, ends);
absl::make_unique<SortedDisjointIntervalList>(starts, ends);
}
int64 GetVariableLowerBound(int index) const override {
return linear_program_.variable_lower_bounds()[glop::ColIndex(index)];

View File

@@ -9,7 +9,7 @@ set_target_properties(${NAME} PROPERTIES
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON
)
)
# CMake < 3.12: CMakeError: Object library may not link to anything.
#target_link_libraries(${NAME} PRIVATE
# absl::strings
@@ -17,30 +17,30 @@ set_target_properties(${NAME} PROPERTIES
# protobuf::libprotobuf
# ${PROJECT_NAME}::proto)
target_include_directories(${NAME} PRIVATE
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
$<TARGET_PROPERTY:absl::strings,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:glog::glog,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_INCLUDE_DIRECTORIES>)
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
$<TARGET_PROPERTY:absl::strings,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:glog::glog,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_INCLUDE_DIRECTORIES>)
target_compile_options(${NAME} PRIVATE
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_OPTIONS>
)
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_OPTIONS>
)
target_compile_definitions(${NAME} PRIVATE
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_DEFINITIONS>
)
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_DEFINITIONS>
)
add_dependencies(${NAME}
absl::strings
gflags::gflags glog::glog
protobuf::libprotobuf
protobuf::libprotobuf
${PROJECT_NAME}::proto)
add_library(${PROJECT_NAME}::data ALIAS ${NAME})

View File

@@ -27,8 +27,6 @@ cc_library(
":variable_values",
":variables_info",
"//ortools/base",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"//ortools/lp_data",
"//ortools/lp_data:base",
"//ortools/lp_data:lp_print_utils",
@@ -39,6 +37,8 @@ cc_library(
"//ortools/util:fp_utils",
"//ortools/util:random_engine",
"//ortools/util:time_limit",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
],
)
@@ -102,11 +102,11 @@ cc_library(
":parameters_cc_proto",
":status",
"//ortools/base",
"@com_google_absl//absl/container:inlined_vector",
"//ortools/lp_data:base",
"//ortools/lp_data:lp_utils",
"//ortools/lp_data:sparse",
"//ortools/util:stats",
"@com_google_absl//absl/container:inlined_vector",
],
)
@@ -240,13 +240,13 @@ cc_library(
":update_row",
":variables_info",
"//ortools/base",
"//ortools/base:random",
"//ortools/lp_data",
"//ortools/lp_data:base",
"//ortools/lp_data:lp_utils",
"//ortools/lp_data:scattered_vector",
"//ortools/util:random_engine",
"//ortools/util:stats",
"//ortools/base:random",
],
)
@@ -283,12 +283,12 @@ cc_library(
":update_row",
":variables_info",
"//ortools/base",
"//ortools/base:random",
"//ortools/lp_data",
"//ortools/lp_data:base",
"//ortools/lp_data:lp_utils",
"//ortools/port:proto_utils",
"//ortools/util:bitset",
"//ortools/base:random",
"//ortools/util:random_engine",
"//ortools/util:stats",
],
@@ -306,13 +306,13 @@ cc_library(
":revised_simplex",
":status",
"//ortools/base",
"@com_google_absl//absl/strings:str_format",
"//ortools/lp_data",
"//ortools/lp_data:base",
"//ortools/lp_data:lp_data_utils",
"//ortools/lp_data:lp_utils",
"//ortools/lp_data:matrix_scaler",
"//ortools/lp_data:matrix_utils",
"@com_google_absl//absl/strings:str_format",
],
)
@@ -328,15 +328,15 @@ cc_library(
":preprocessor",
":status",
"//ortools/base",
"@com_google_absl//absl/strings:strings",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/strings:str_format",
"//ortools/lp_data",
"//ortools/lp_data:base",
"//ortools/lp_data:lp_utils",
"//ortools/lp_data:proto_utils",
"//ortools/util:file_util",
"//ortools/util:fp_utils",
"//ortools/util:time_limit",
"//ortools/util:file_util",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
],
)

View File

@@ -9,7 +9,7 @@ set_target_properties(${NAME} PROPERTIES
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON
)
)
# CMake < 3.12: CMakeError: Object library may not link to anything.
#target_link_libraries(${NAME} PRIVATE
# absl::memory absl::container absl::strings absl::str_format
@@ -17,39 +17,39 @@ set_target_properties(${NAME} PROPERTIES
# protobuf::libprotobuf
# ${PROJECT_NAME}::proto)
target_include_directories(${NAME} PRIVATE
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
$<TARGET_PROPERTY:absl::memory,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::container,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::strings,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:glog::glog,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_INCLUDE_DIRECTORIES>)
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
$<TARGET_PROPERTY:absl::memory,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::container,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::strings,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:glog::glog,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_INCLUDE_DIRECTORIES>)
target_compile_options(${NAME} PRIVATE
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_OPTIONS>
)
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_OPTIONS>
)
target_compile_definitions(${NAME} PRIVATE
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_DEFINITIONS>
)
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_DEFINITIONS>
)
add_dependencies(${NAME}
absl::memory absl::container absl::strings absl::str_format
gflags::gflags glog::glog
protobuf::libprotobuf
protobuf::libprotobuf
${PROJECT_NAME}::proto)
add_library(${PROJECT_NAME}::glop ALIAS ${NAME})

View File

@@ -134,9 +134,9 @@ cc_library(
"//ortools/base:hash",
"//ortools/base:int_type",
"//ortools/base:int_type_indexed_vector",
"//ortools/util:time_limit",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/strings",
"//ortools/util:time_limit",
],
)
@@ -229,13 +229,13 @@ cc_library(
hdrs = ["perfect_matching.h"],
visibility = ["//visibility:public"],
deps = [
"@com_google_absl//absl/base",
"@com_google_absl//absl/strings",
"//ortools/base",
"//ortools/base:adjustable_priority_queue",
"//ortools/base:int_type",
"//ortools/base:int_type_indexed_vector",
"//ortools/util:saturated_arithmetic",
"@com_google_absl//absl/base",
"@com_google_absl//absl/strings",
],
)
@@ -267,9 +267,9 @@ cc_library(
":graph",
":graphs",
"//ortools/base",
"@com_google_absl//absl/memory",
"//ortools/util:stats",
"//ortools/util:zvector",
"@com_google_absl//absl/memory",
],
)
@@ -308,10 +308,10 @@ cc_library(
deps = [
":ebert_graph",
"//ortools/base",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"//ortools/util:permutation",
"//ortools/util:zvector",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
],
)
@@ -324,11 +324,11 @@ cc_library(
"connected_components.h",
],
deps = [
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:flat_hash_set",
"//ortools/base",
"//ortools/base:map_util",
"//ortools/base:ptr_util",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:flat_hash_set",
],
)

View File

@@ -9,7 +9,7 @@ set_target_properties(${NAME} PROPERTIES
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON
)
)
# CMake < 3.12: CMakeError: Object library may not link to anything.
#target_link_libraries(${NAME} PRIVATE
# absl::hash absl::meta absl::memory absl::strings absl::str_format
@@ -18,50 +18,50 @@ set_target_properties(${NAME} PROPERTIES
# Coin::Cbc
# ${PROJECT_NAME}::proto)
target_include_directories(${NAME} PRIVATE
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
$<TARGET_PROPERTY:absl::hash,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::meta,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::memory,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::strings,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:glog::glog,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
$<TARGET_PROPERTY:absl::hash,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::meta,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::memory,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::strings,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:glog::glog,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
$<$<BOOL:${USE_COINOR}>:$<TARGET_PROPERTY:Coin::Cbc,INTERFACE_INCLUDE_DIRECTORIES>>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_INCLUDE_DIRECTORIES>)
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_INCLUDE_DIRECTORIES>)
target_compile_options(${NAME} PRIVATE
$<TARGET_PROPERTY:absl::hash,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::meta,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_OPTIONS>
$<$<BOOL:${USE_COINOR}>:$<TARGET_PROPERTY:Coin::Cbc,INTERFACE_COMPILE_OPTIONS>>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_OPTIONS>
)
$<TARGET_PROPERTY:absl::hash,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::meta,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_OPTIONS>
$<$<BOOL:${USE_COINOR}>:$<TARGET_PROPERTY:Coin::Cbc,INTERFACE_COMPILE_OPTIONS>>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_OPTIONS>
)
target_compile_definitions(${NAME} PRIVATE
$<TARGET_PROPERTY:absl::hash,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::meta,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_DEFINITIONS>
$<$<BOOL:${USE_COINOR}>:$<TARGET_PROPERTY:Coin::Cbc,INTERFACE_COMPILE_DEFINITIONS>>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_DEFINITIONS>
)
$<TARGET_PROPERTY:absl::hash,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::meta,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_DEFINITIONS>
$<$<BOOL:${USE_COINOR}>:$<TARGET_PROPERTY:Coin::Cbc,INTERFACE_COMPILE_DEFINITIONS>>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_DEFINITIONS>
)
add_dependencies(${NAME}
absl::hash absl::meta absl::memory absl::strings absl::str_format
gflags::gflags glog::glog
protobuf::libprotobuf
protobuf::libprotobuf
${PROJECT_NAME}::proto)
if(USE_COINOR)
add_dependencies(${NAME} Coin::Cbc)
add_dependencies(${NAME} Coin::Cbc)
endif()
add_library(${PROJECT_NAME}::graph ALIAS ${NAME})

View File

@@ -178,6 +178,9 @@ bool PathHasCycle(const Graph& graph, const std::vector<int>& arc_path);
//
// Note that since graphs may have multi-arcs, the mapping isn't necessarily
// unique, hence the function name.
//
// PERFORMANCE: If you see this function taking too much memory and/or too much
// time, reach out to @user: one could halve the memory usage and speed it up.
template <class Graph>
std::vector<int> ComputeOnePossibleReverseArcMapping(const Graph& graph,
bool die_if_not_symmetric);

View File

@@ -65,7 +65,7 @@ cc_library(
"sat_interface.cc",
"sat_proto_solver.cc",
"sat_solver_utils.cc",
] + select({
] + select({
":with_cbc": ["cbc_interface.cc"],
"//conditions:default": [],
}) + select({

View File

@@ -9,7 +9,7 @@ set_target_properties(${NAME} PROPERTIES
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON
)
)
# CMake < 3.12: CMakeError: Object library may not link to anything.
#target_link_libraries(${NAME} PRIVATE
# absl::memory absl::container absl::strings absl::str_format
@@ -18,67 +18,67 @@ set_target_properties(${NAME} PROPERTIES
# Coin::Cbc
# ${PROJECT_NAME}::proto)
target_include_directories(${NAME} PRIVATE
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
$<TARGET_PROPERTY:absl::memory,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::container,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::strings,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:glog::glog,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
$<TARGET_PROPERTY:absl::memory,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::container,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::strings,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:glog::glog,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
$<$<BOOL:${USE_COINOR}>:$<TARGET_PROPERTY:Coin::Cbc,INTERFACE_INCLUDE_DIRECTORIES>>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_INCLUDE_DIRECTORIES>)
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_INCLUDE_DIRECTORIES>)
target_compile_options(${NAME} PRIVATE
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_OPTIONS>
$<$<BOOL:${USE_COINOR}>:$<TARGET_PROPERTY:Coin::Cbc,INTERFACE_COMPILE_OPTIONS>>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_OPTIONS>
)
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_OPTIONS>
$<$<BOOL:${USE_COINOR}>:$<TARGET_PROPERTY:Coin::Cbc,INTERFACE_COMPILE_OPTIONS>>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_OPTIONS>
)
target_compile_definitions(${NAME} PRIVATE
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_DEFINITIONS>
$<$<BOOL:${USE_COINOR}>:$<TARGET_PROPERTY:Coin::Cbc,INTERFACE_COMPILE_DEFINITIONS>>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_DEFINITIONS>
)
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_DEFINITIONS>
$<$<BOOL:${USE_COINOR}>:$<TARGET_PROPERTY:Coin::Cbc,INTERFACE_COMPILE_DEFINITIONS>>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_DEFINITIONS>
)
add_dependencies(${NAME}
absl::memory absl::container absl::strings absl::str_format
gflags::gflags glog::glog
protobuf::libprotobuf
protobuf::libprotobuf
${PROJECT_NAME}::proto)
if(USE_COINOR)
add_dependencies(${NAME} Coin::Cbc)
add_dependencies(${NAME} Coin::Cbc)
endif()
if (USE_XPRESS)
target_include_directories(${NAME} PUBLIC ${XPRESSDIR}/include)
if(UNIX)
target_link_libraries(${NAME} PUBLIC ${XPRESSDIR}/lib/libxprs.so)
elseif(MSVC)
target_link_libraries(${NAME} PUBLIC ${XPRESSDIR}/lib/xprs.lib)
endif()
target_include_directories(${NAME} PUBLIC ${XPRESSDIR}/include)
if(UNIX)
target_link_libraries(${NAME} PUBLIC ${XPRESSDIR}/lib/libxprs.so)
elseif(MSVC)
target_link_libraries(${NAME} PUBLIC ${XPRESSDIR}/lib/xprs.lib)
endif()
endif(USE_XPRESS)
if (USE_CPLEX)
target_include_directories(${NAME} PUBLIC
${CPLEXDIR}/include
)
if(UNIX)
target_link_libraries(${NAME} PUBLIC ${CPLEXDIR}/lib/x64_windows_vs2015/stat_mda/cplex1270.a)
elseif(MSVC)
target_link_libraries(${NAME} PUBLIC ${CPLEXDIR}/lib/x64_windows_vs2015/stat_mda/cplex1270.lib)
endif()
target_include_directories(${NAME} PUBLIC
${CPLEXDIR}/include
)
if(UNIX)
target_link_libraries(${NAME} PUBLIC ${CPLEXDIR}/lib/x64_windows_vs2015/stat_mda/cplex1270.a)
elseif(MSVC)
target_link_libraries(${NAME} PUBLIC ${CPLEXDIR}/lib/x64_windows_vs2015/stat_mda/cplex1270.lib)
endif()
endif(USE_CPLEX)
add_library(${PROJECT_NAME}::linear_solver ALIAS ${NAME})

View File

@@ -516,7 +516,6 @@ constexpr
#if defined(USE_XPRESS)
{MPSolver::XPRESS_MIXED_INTEGER_PROGRAMMING, "xpress_mip"},
#endif
#endif
};
// static
@@ -1524,12 +1523,6 @@ bool MPSolverResponseStatusIsRpcError(MPSolverResponseStatus status) {
case MPSOLVER_MODEL_INVALID_SOLUTION_HINT:
case MPSOLVER_MODEL_INVALID_SOLVER_PARAMETERS:
case MPSOLVER_SOLVER_TYPE_UNAVAILABLE:
case MPSOLVER_SERVER_ERROR:
case MPSOLVER_SERVER_ERROR_REQUEST_IS_QOD:
case MPSOLVER_SERVER_ERROR_RPC_DEADLINE_TOO_SMALL:
case MPSOLVER_SERVER_ERROR_SERVER_IS_SHUTTING_DOWN:
case MPSOLVER_SERVER_ERROR_REQUEST_TOO_LARGE:
case MPSOLVER_SERVER_ERROR_FULL:
return true;
}
LOG(DFATAL)

View File

@@ -728,9 +728,9 @@ class MPSolver {
* not the solver computes them ahead of time or when NextSolution() is called
* is solver specific.
*
* As of 2018-08-09, only Gurobi supports NextSolution(), see
* linear_solver_underlying_gurobi_test for an example of how to configure
* Gurobi for this purpose. The other solvers return false unconditionally.
* As of 2020-02-10, only Gurobi and SCIP support NextSolution(), see
* linear_solver_interfaces_test for an example of how to configure these
* solvers for multiple solutions. Other solvers return false unconditionally.
*/
ABSL_MUST_USE_RESULT bool NextSolution();

View File

@@ -402,18 +402,16 @@ message MPModelRequest {
GLOP_LINEAR_PROGRAMMING = 2; // Recommended default for LP models.
CLP_LINEAR_PROGRAMMING = 0;
GLPK_LINEAR_PROGRAMMING = 1;
GUROBI_LINEAR_PROGRAMMING = 6; // Commercial, needs a valid license.
GUROBI_LINEAR_PROGRAMMING = 6; // Commercial, needs a valid license.
XPRESS_LINEAR_PROGRAMMING = 101; // Commercial, needs a valid license.
CPLEX_LINEAR_PROGRAMMING = 10; // Commercial, needs a valid
// license.
CPLEX_LINEAR_PROGRAMMING = 10; // Commercial, needs a valid license.
SCIP_MIXED_INTEGER_PROGRAMMING = 3; // Recommended default for MIP models.
GLPK_MIXED_INTEGER_PROGRAMMING = 4;
CBC_MIXED_INTEGER_PROGRAMMING = 5;
GUROBI_MIXED_INTEGER_PROGRAMMING = 7; // Commercial, needs a valid license.
XPRESS_MIXED_INTEGER_PROGRAMMING = 102; // Commercial, needs a valid license.
CPLEX_MIXED_INTEGER_PROGRAMMING = 11; // Commercial, needs a
// valid license.
CPLEX_MIXED_INTEGER_PROGRAMMING = 11; // Commercial, needs a valid license.
BOP_INTEGER_PROGRAMMING = 12;
// WARNING: This solver will currently interpret all variables as integer,

View File

@@ -0,0 +1,83 @@
// Copyright 2010-2018 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "ortools/linear_solver/linear_solver_callback.h"
#include "ortools/base/logging.h"
namespace operations_research {
std::string ToString(MPCallbackEvent event) {
switch (event) {
case MPCallbackEvent::kMipSolution:
return "MIP_SOLUTION";
case MPCallbackEvent::kMip:
return "MIP";
case MPCallbackEvent::kMipNode:
return "MIP_NODE";
case MPCallbackEvent::kBarrier:
return "BARRIER";
case MPCallbackEvent::kMessage:
return "MESSAGE";
case MPCallbackEvent::kPresolve:
return "PRESOLVE";
case MPCallbackEvent::kPolling:
return "POLLING";
case MPCallbackEvent::kMultiObj:
return "MULTI_OBJ";
case MPCallbackEvent::kSimplex:
return "SIMPLEX";
case MPCallbackEvent::kUnknown:
return "UNKNOWN";
default:
LOG(FATAL) << "Unrecognized callback event: " << static_cast<int>(event);
}
}
namespace {
// Returns true if any of the callbacks in a list might add cuts.
bool CallbacksMightAddCuts(const std::vector<MPCallback*>& callbacks) {
for (MPCallback* callback : callbacks) {
if (callback->might_add_cuts()) {
return true;
}
}
return false;
}
// Returns true if any of the callbacks in a list might add lazy constraints.
bool CallbacksMightAddLazyConstraints(
const std::vector<MPCallback*>& callbacks) {
for (MPCallback* callback : callbacks) {
if (callback->might_add_lazy_constraints()) {
return true;
}
}
return false;
}
} // namespace
MPCallbackList::MPCallbackList(const std::vector<MPCallback*>& callbacks)
: MPCallback(CallbacksMightAddCuts(callbacks),
CallbacksMightAddLazyConstraints(callbacks)),
callbacks_(callbacks) {}
void MPCallbackList::RunCallback(MPCallbackContext* context) {
for (MPCallback* callback : callbacks_) {
callback->RunCallback(context);
}
}
} // namespace operations_research

View File

@@ -0,0 +1,180 @@
// Copyright 2010-2018 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// See go/mpsolver-callbacks for documentation on how to use this file.
#ifndef OR_TOOLS_LINEAR_SOLVER_LINEAR_SOLVER_CALLBACK_H_
#define OR_TOOLS_LINEAR_SOLVER_LINEAR_SOLVER_CALLBACK_H_
#include <string>
#include "absl/container/flat_hash_map.h"
#include "ortools/base/integral_types.h"
namespace operations_research {
class MPVariable;
class LinearExpr;
class LinearRange;
// The current state of the solver when the callback is invoked.
//
// For Gurobi, similar to the int 'where' in the Gurobi callback API.
// See http://www.gurobi.com/documentation/8.0/refman/callback_codes.html
// for details.
enum class MPCallbackEvent {
kUnknown,
// For regaining control of the main thread in single threaded applications,
// not for interacting with the solver.
kPolling,
// The solver is currently running presolve.
kPresolve,
// The solver is currently running the simplex method.
kSimplex,
// The solver is in the MIP loop (called periodically before starting a new
// node). Useful to early termination.
kMip,
// Called every time a new MIP incumbent is found.
kMipSolution,
// Called once per pass of the cut loop inside each MIP node.
kMipNode,
// Called in each iterate of IPM/barrier method.
kBarrier,
// The solver is about to log out a message, use this callback to capture it.
kMessage,
// The solver is in multi-objective optimization.
kMultiObj,
};
std::string ToString(MPCallbackEvent event);
// When querying solution values or modifying the model during a callback, use
// this API, rather than manipulating MPSolver directly. You should only
// interact with this object from within MPCallback::RunCallback().
class MPCallbackContext {
public:
virtual ~MPCallbackContext() {}
// What the solver is currently doing. How you can interact with the solver
// from the callback depends on this value.
virtual MPCallbackEvent Event() = 0;
// Always false if event is not kMipSolution or kMipNode, otherwise behavior
// may be solver dependent.
//
// For Gurobi, under kMipNode, may be false if the node was not solved to
// optimality, see MIPNODE_REL here for details:
// http://www.gurobi.com/documentation/8.0/refman/callback_codes.html
virtual bool CanQueryVariableValues() = 0;
// Returns the value of variable from the solver's current state.
//
// Call only when CanQueryVariableValues() is true.
//
// At kMipSolution, the solution is integer feasible, while at kMipNode, the
// solution solves the current node's LP relaxation (so integer variables may
// be fractional).
virtual double VariableValue(const MPVariable* variable) = 0;
// Adds a constraint to the model that strengths the LP relaxation.
//
// Call only when the event is kMipNode.
//
// Requires that MPCallback::might_add_cuts() is true.
//
// This constraint must not cut off integer solutions, it should only
// strengthen the LP (behavior is undefined otherwise). Use
// MPCallbackContext::AddLazyConstriant() if you are cutting off integer
// solutions.
virtual void AddCut(const LinearRange& cutting_plane) = 0;
// Adds a constraint to the model that cuts off an undesired integer solution.
//
// Call only when the event is kMipSolution or kMipNode.
//
// Requires that MPCallback::might_add_lazy_constraints() is true.
//
// Use this to avoid adding a large number of constraints to the model where
// most are expected to not be needed.
//
// Given an integral solution, AddLazyConstraint() MUST be able to detect if
// there is a violated constraint, and it is guaranteed that every integer
// solution will be checked by AddLazyConstraint().
//
// Warning(rander): in some solvers, e.g. Gurobi, an integer solution may not
// respect a previously added lazy constraint, so you may need to add a
// constraint more than once (e.g. due to threading issues).
virtual void AddLazyConstraint(const LinearRange& lazy_constraint) = 0;
// Suggests a (potentially partial) variable assignment to the solver, to be
// used as a feasible solution (or part of one). If the assignment is partial,
// certain solvers (e.g. Gurobi) will try to compute a feasible solution from
// the partial assignment. Returns the objective value of the solution if the
// solver supports it.
//
// Call only when the event is kMipNode.
virtual double SuggestSolution(
const absl::flat_hash_map<const MPVariable*, double>& solution) = 0;
// Returns the number of nodes explored so far in the branch and bound tree,
// which 0 at the root node and > 0 otherwise.
//
// Call only when the event is kMipSolution or kMipNode.
virtual int64 NumExploredNodes() = 0;
};
// Extend this class with model specific logic, and register through
// MPSolver::SetCallback, passing a pointer to this object.
//
// See go/mpsolver-callbacks for additional documentation.
class MPCallback {
public:
// If you intend to call call MPCallbackContext::AddCut(), you must set
// might_add_cuts below to be true. Likewise for
// MPCallbackContext::AddLazyConstraint() and might_add_lazy_constraints.
MPCallback(bool might_add_cuts, bool might_add_lazy_constraints)
: might_add_cuts_(might_add_cuts),
might_add_lazy_constraints_(might_add_lazy_constraints) {}
virtual ~MPCallback() {}
// Threading behavior may be solver dependent:
// * Gurobi: RunCallback always runs on the same thread that you called
// MPSolver::Solve() on, even when Gurobi uses multiple threads.
virtual void RunCallback(MPCallbackContext* callback_context) = 0;
bool might_add_cuts() const { return might_add_cuts_; }
bool might_add_lazy_constraints() const {
return might_add_lazy_constraints_;
}
private:
bool might_add_cuts_;
bool might_add_lazy_constraints_;
};
// Single callback that runs the list of callbacks given at construction, in
// sequence.
class MPCallbackList : public MPCallback {
public:
explicit MPCallbackList(const std::vector<MPCallback*>& callbacks);
// Runs all callbacks from the list given at construction, in sequence.
void RunCallback(MPCallbackContext* context) override;
private:
const std::vector<MPCallback*> callbacks_;
};
} // namespace operations_research
#endif // OR_TOOLS_LINEAR_SOLVER_LINEAR_SOLVER_CALLBACK_H_

View File

@@ -37,8 +37,9 @@ inline util::Status ScipCodeToUtilStatus(/*SCIP_Retcode*/ int retcode,
}
} // namespace internal
#define SCIP_TO_STATUS(x) \
internal::ScipCodeToUtilStatus(x, __FILE__, __LINE__, #x)
#define SCIP_TO_STATUS(x) \
::operations_research::internal::ScipCodeToUtilStatus(x, __FILE__, __LINE__, \
#x)
#define RETURN_IF_SCIP_ERROR(x) RETURN_IF_ERROR(SCIP_TO_STATUS(x));

View File

@@ -54,10 +54,10 @@ cc_library(
":base",
":permutation",
"//ortools/base",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"//ortools/graph:iterators",
"//ortools/util:return_macros",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
],
)
@@ -103,9 +103,9 @@ cc_library(
"//ortools/base:int_type",
"//ortools/base:int_type_indexed_vector",
"//ortools/base:random",
"@com_google_absl//absl/strings",
"//ortools/util:fp_utils",
"//ortools/util:return_macros",
"@com_google_absl//absl/strings",
],
)
@@ -154,11 +154,11 @@ cc_library(
"//ortools/base:hash",
"//ortools/base:int_type",
"//ortools/base:int_type_indexed_vector",
"//ortools/glop:parameters_cc_proto",
"//ortools/util:fp_utils",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/strings",
"//ortools/glop:parameters_cc_proto",
"//ortools/util:fp_utils",
],
)
@@ -235,9 +235,9 @@ cc_library(
deps = [
":base",
"//ortools/base",
"//ortools/util:rational_approximation",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"//ortools/util:rational_approximation",
],
)
@@ -273,7 +273,7 @@ cc_library(
"//ortools/base:map_util",
"//ortools/base:protobuf_util",
"//ortools/base:status",
"//ortools/base:status_macros",
"//ortools/base:status_macros",
"//ortools/linear_solver:linear_solver_cc_proto",
"@com_google_absl//absl/strings",
],
@@ -307,7 +307,7 @@ cc_library(
"//ortools/algorithms:dynamic_partition",
"//ortools/base",
"//ortools/base:hash",
"@com_google_absl//absl/synchronization",
"//ortools/glop:parameters_cc_proto",
"@com_google_absl//absl/synchronization",
],
)

View File

@@ -9,7 +9,7 @@ set_target_properties(${NAME} PROPERTIES
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON
)
)
# CMake < 3.12: CMakeError: Object library may not link to anything.
#target_link_libraries(${NAME} PRIVATE
# absl::synchronization absl::strings absl::str_format
@@ -17,36 +17,36 @@ set_target_properties(${NAME} PROPERTIES
# protobuf::libprotobuf
# ${PROJECT_NAME}::proto)
target_include_directories(${NAME} PRIVATE
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
$<TARGET_PROPERTY:absl::synchronization,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::strings,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:glog::glog,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_INCLUDE_DIRECTORIES>)
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
$<TARGET_PROPERTY:absl::synchronization,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::strings,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:glog::glog,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_INCLUDE_DIRECTORIES>)
target_compile_options(${NAME} PRIVATE
$<TARGET_PROPERTY:absl::synchronization,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_OPTIONS>
)
$<TARGET_PROPERTY:absl::synchronization,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_OPTIONS>
)
target_compile_definitions(${NAME} PRIVATE
$<TARGET_PROPERTY:absl::synchronization,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_DEFINITIONS>
)
$<TARGET_PROPERTY:absl::synchronization,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_DEFINITIONS>
)
add_dependencies(${NAME}
absl::synchronization absl::strings absl::str_format
gflags::gflags glog::glog
protobuf::libprotobuf
protobuf::libprotobuf
${PROJECT_NAME}::proto)
add_library(${PROJECT_NAME}::lp_data ALIAS ${NAME})

View File

@@ -794,9 +794,10 @@ util::Status MPSReaderImpl::StoreBound(const std::string& bound_type_mnemonic,
if (integer_type_names_set_.count(bound_type_mnemonic) != 0) {
data->SetVariableTypeToInteger(col);
}
// Resize the is_binary_by_default_ in case it is the first time this column
// is encountered.
is_binary_by_default_.resize(col + 1, false);
if (is_binary_by_default_.size() <= col) {
// This is the first time that this column has been encountered.
is_binary_by_default_.resize(col + 1, false);
}
// Check that "binary by default" implies "integer".
DCHECK(!is_binary_by_default_[col] || data->VariableIsInteger(col));
Fractional lower_bound = data->VariableLowerBound(col);

View File

@@ -9,7 +9,7 @@ set_target_properties(${NAME} PROPERTIES
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON
)
)
# CMake < 3.12: CMakeError: Object library may not link to anything.
#target_link_libraries(${NAME} PRIVATE
# absl::strings
@@ -17,30 +17,30 @@ set_target_properties(${NAME} PROPERTIES
# protobuf::libprotobuf
# ${PROJECT_NAME}::proto)
target_include_directories(${NAME} PRIVATE
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
$<TARGET_PROPERTY:absl::strings,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:glog::glog,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_INCLUDE_DIRECTORIES>)
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
$<TARGET_PROPERTY:absl::strings,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:glog::glog,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_INCLUDE_DIRECTORIES>)
target_compile_options(${NAME} PRIVATE
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_OPTIONS>
)
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_OPTIONS>
)
target_compile_definitions(${NAME} PRIVATE
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_DEFINITIONS>
)
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_DEFINITIONS>
)
add_dependencies(${NAME}
absl::strings
gflags::gflags glog::glog
protobuf::libprotobuf
protobuf::libprotobuf
${PROJECT_NAME}::proto)
add_library(${PROJECT_NAME}::port ALIAS ${NAME})

View File

@@ -172,7 +172,6 @@ cc_library(
":integer_search",
":linear_programming_constraint",
":linear_relaxation",
":subsolver",
":model",
":optimization",
":precedences",
@@ -182,6 +181,7 @@ cc_library(
":sat_parameters_cc_proto",
":sat_solver",
":simplification",
":subsolver",
":synchronization",
"//ortools/base",
"//ortools/base:file",
@@ -268,6 +268,10 @@ cc_library(
srcs = ["presolve_context.cc"],
hdrs = ["presolve_context.h"],
deps = [
":cp_model_cc_proto",
":cp_model_utils",
":presolve_util",
":sat_parameters_cc_proto",
"//ortools/base",
"//ortools/base:int_type",
"//ortools/base:int_type_indexed_vector",
@@ -278,10 +282,6 @@ cc_library(
"//ortools/util:bitset",
"//ortools/util:sorted_interval_list",
"//ortools/util:time_limit",
":cp_model_cc_proto",
":cp_model_utils",
":presolve_util",
":sat_parameters_cc_proto",
"@com_google_absl//absl/container:flat_hash_map",
],
)
@@ -642,8 +642,8 @@ cc_library(
hdrs = ["integer_expr.h"],
deps = [
":integer",
":model",
":linear_constraint",
":model",
":precedences",
":sat_base",
":sat_solver",
@@ -699,8 +699,8 @@ cc_library(
":sat_base",
":sat_parameters_cc_proto",
":sat_solver",
":timetable",
":theta_tree",
":timetable",
"//ortools/base",
"//ortools/base:int_type",
"//ortools/base:iterator_adaptors",
@@ -974,8 +974,8 @@ cc_library(
"//ortools/base",
"//ortools/base:random",
"//ortools/util:random_engine",
"@com_google_absl//absl/random",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/random",
"@com_google_protobuf_cc//:protobuf",
],
)

View File

@@ -9,7 +9,7 @@ set_target_properties(${NAME} PROPERTIES
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON
)
)
# CMake < 3.12: CMakeError: Object library may not link to anything.
#target_link_libraries(${NAME} PRIVATE
# absl::any absl::memory absl::synchronization absl::container absl::strings absl::str_format
@@ -18,53 +18,53 @@ set_target_properties(${NAME} PROPERTIES
# Coin::Cbc
# ${PROJECT_NAME}::proto)
target_include_directories(${NAME} PRIVATE
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
$<TARGET_PROPERTY:absl::any,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::memory,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::synchronization,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::container,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::strings,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:glog::glog,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
$<TARGET_PROPERTY:absl::any,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::memory,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::synchronization,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::container,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::strings,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:glog::glog,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
$<$<BOOL:${USE_COINOR}>:$<TARGET_PROPERTY:Coin::Cbc,INTERFACE_INCLUDE_DIRECTORIES>>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_INCLUDE_DIRECTORIES>)
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_INCLUDE_DIRECTORIES>)
target_compile_options(${NAME} PRIVATE
$<TARGET_PROPERTY:absl::any,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::synchronization,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_OPTIONS>
$<$<BOOL:${USE_COINOR}>:$<TARGET_PROPERTY:Coin::Cbc,INTERFACE_COMPILE_OPTIONS>>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_OPTIONS>
)
$<TARGET_PROPERTY:absl::any,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::synchronization,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_OPTIONS>
$<$<BOOL:${USE_COINOR}>:$<TARGET_PROPERTY:Coin::Cbc,INTERFACE_COMPILE_OPTIONS>>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_OPTIONS>
)
target_compile_definitions(${NAME} PRIVATE
$<TARGET_PROPERTY:absl::any,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::synchronization,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_DEFINITIONS>
$<$<BOOL:${USE_COINOR}>:$<TARGET_PROPERTY:Coin::Cbc,INTERFACE_COMPILE_DEFINITIONS>>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_DEFINITIONS>
)
$<TARGET_PROPERTY:absl::any,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::synchronization,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::container,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_DEFINITIONS>
$<$<BOOL:${USE_COINOR}>:$<TARGET_PROPERTY:Coin::Cbc,INTERFACE_COMPILE_DEFINITIONS>>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_DEFINITIONS>
)
add_dependencies(${NAME}
absl::any absl::memory absl::synchronization absl::container absl::strings absl::str_format
gflags::gflags glog::glog
protobuf::libprotobuf
protobuf::libprotobuf
${PROJECT_NAME}::proto)
if(USE_COINOR)
add_dependencies(${NAME} Coin::Cbc)
add_dependencies(${NAME} Coin::Cbc)
endif()
add_library(${PROJECT_NAME}::sat ALIAS ${NAME})

View File

@@ -50,6 +50,15 @@ std::function<void(Model*)> AllDifferentBinary(
model->Add(AtMostOneConstraint(entry.second));
}
}
// If the number of values is equal to the number of variables, we have
// a permutation. We can add a bool_or for each literals attached to a
// value.
if (value_to_literals.size() == vars.size()) {
for (const auto& entry : value_to_literals) {
model->Add(ClauseConstraint(entry.second));
}
}
};
}

View File

@@ -2393,6 +2393,15 @@ bool CpModelPresolver::PresolveTable(ConstraintProto* ct) {
std::vector<absl::flat_hash_set<int64>> new_domains(num_vars);
std::vector<AffineRelation::Relation> affine_relations;
absl::flat_hash_set<int> visited;
for (const int ref : ct->table().vars()) {
if (visited.contains(PositiveRef(ref))) {
context_->UpdateRuleStats("TODO table: duplicate variables");
} else {
visited.insert(PositiveRef(ref));
}
}
bool modified_variables = false;
for (int v = 0; v < num_vars; ++v) {
const int ref = ct->table().vars(v);

View File

@@ -55,6 +55,7 @@ LinearConstraintManager::~LinearConstraintManager() {
VLOG(2) << "num_coeff_strenghtening: " << num_coeff_strenghtening_;
}
if (sat_parameters_.log_search_progress()) {
LOG(INFO) << "Total cuts added: " << num_cuts_;
for (const auto entry : type_to_num_cuts_) {
LOG(INFO) << "Added " << entry.second << " cuts of type '" << entry.first
<< "'.";
@@ -62,6 +63,14 @@ LinearConstraintManager::~LinearConstraintManager() {
}
}
void LinearConstraintManager::RescaleActiveCounts(const double scaling_factor) {
for (ConstraintIndex i(0); i < constraint_infos_.size(); ++i) {
constraint_infos_[i].active_count *= scaling_factor;
}
constraint_active_count_increase_ *= scaling_factor;
VLOG(2) << "Rescaled active counts by " << scaling_factor;
}
bool LinearConstraintManager::MaybeRemoveSomeInactiveConstraints(
glop::BasisState* solution_state) {
if (solution_state->IsEmpty()) return false; // Mainly to simplify tests.
@@ -145,13 +154,9 @@ LinearConstraintManager::ConstraintIndex LinearConstraintManager::Add(
ConstraintInfo ct_info;
ct_info.constraint = std::move(ct);
ct_info.l2_norm = ComputeL2Norm(ct_info.constraint);
ct_info.is_in_lp = false;
ct_info.objective_parallelism_computed = false;
ct_info.objective_parallelism = 0.0;
ct_info.inactive_count = 0;
ct_info.hash = key;
equiv_constraints_[key] = ct_index;
ct_info.active_count = constraint_active_count_increase_;
constraint_infos_.push_back(std::move(ct_info));
return ct_index;
}
@@ -212,8 +217,15 @@ bool LinearConstraintManager::AddCut(
// update of an already existing one.
bool added = false;
const ConstraintIndex ct_index = Add(std::move(ct), &added);
// We only mark the constraint as a cut if it is not an update of an already
// existing one.
if (!added) return false;
// TODO(user): Use better heuristic here for detecting good cuts and mark
// them undeletable.
constraint_infos_[ct_index].is_deletable = true;
VLOG(1) << "Cut '" << type_name << "'"
<< " size=" << constraint_infos_[ct_index].constraint.vars.size()
<< " max_magnitude="
@@ -222,10 +234,84 @@ bool LinearConstraintManager::AddCut(
<< " eff=" << violation / l2_norm;
num_cuts_++;
num_deletable_constraints_++;
type_to_num_cuts_[type_name]++;
return true;
}
void LinearConstraintManager::PermanentlyRemoveSomeConstraints() {
std::vector<ConstraintIndex> deletable_constraints;
for (ConstraintIndex i(0); i < constraint_infos_.size(); ++i) {
if (constraint_infos_[i].is_deletable && !constraint_infos_[i].is_in_lp) {
deletable_constraints.push_back(i);
}
}
std::sort(deletable_constraints.begin(), deletable_constraints.end(),
[&](const ConstraintIndex a, const ConstraintIndex b) {
return constraint_infos_[a].active_count <
constraint_infos_[b].active_count;
});
// The constraints we want to delete are in the front of the vector.
int32 num_deleted_constraints =
std::min(static_cast<int32>(deletable_constraints.size()),
sat_parameters_.cut_cleanup_target());
// We keep the constraints that have the same active count as the first kept
// constraint.
if (deletable_constraints.size() > num_deleted_constraints) {
const ConstraintIndex first_kept_constraint =
deletable_constraints[num_deleted_constraints];
const double active_counts_to_keep =
constraint_infos_[first_kept_constraint].active_count;
while (num_deleted_constraints > 0) {
const ConstraintIndex last_deleted_constraint =
deletable_constraints[num_deleted_constraints - 1];
if (constraint_infos_[last_deleted_constraint].active_count <
active_counts_to_keep) {
break;
}
num_deleted_constraints--;
}
}
absl::flat_hash_set<ConstraintIndex> to_delete(
deletable_constraints.begin(),
deletable_constraints.begin() + num_deleted_constraints);
ConstraintIndex new_size(0);
equiv_constraints_.clear();
gtl::ITIVector<ConstraintIndex, ConstraintIndex> index_mapping(
constraint_infos_.size());
for (ConstraintIndex i(0); i < constraint_infos_.size(); ++i) {
if (to_delete.contains(i)) continue;
if (i != new_size) {
constraint_infos_[new_size] = std::move(constraint_infos_[i]);
}
index_mapping[i] = new_size;
// Make sure we recompute the hash_map of identical constraints.
const size_t key =
ComputeHashOfTerms(constraint_infos_[new_size].constraint);
equiv_constraints_[key] = new_size;
new_size++;
}
// Also update lp_constraints_
for (int i = 0; i < lp_constraints_.size(); ++i) {
lp_constraints_[i] = index_mapping[lp_constraints_[i]];
}
constraint_infos_.resize(new_size.value());
if (num_deleted_constraints > 0) {
VLOG(1) << "Constraint manager cleanup: #deleted:"
<< num_deleted_constraints;
}
num_deletable_constraints_ -= num_deleted_constraints;
}
void LinearConstraintManager::SetObjectiveCoefficient(IntegerVariable var,
IntegerValue coeff) {
if (coeff == IntegerValue(0)) return;
@@ -380,6 +466,7 @@ bool LinearConstraintManager::ChangeLp(
// We keep any constraints that is already present, and otherwise, we add the
// ones that are currently not satisfied by at least "tolerance".
bool rescale_active_count = false;
const double tolerance = 1e-6;
for (ConstraintIndex i(0); i < constraint_infos_.size(); ++i) {
// Inprocessing of the constraint.
@@ -431,9 +518,48 @@ bool LinearConstraintManager::ChangeLp(
constraint_infos_[i].current_score =
new_constraints_efficacies.back() +
constraint_infos_[i].objective_parallelism;
if (constraint_infos_[i].is_deletable) {
constraint_infos_[i].active_count += constraint_active_count_increase_;
if (constraint_infos_[i].active_count >
sat_parameters_.cut_max_active_count_value()) {
rescale_active_count = true;
}
}
}
}
// Bump activities of active constraints in LP.
if (solution_state != nullptr) {
const glop::RowIndex num_rows(lp_constraints_.size());
const glop::ColIndex num_cols =
solution_state->statuses.size() - RowToColIndex(num_rows);
for (int i = 0; i < num_rows; ++i) {
const ConstraintIndex constraint_index = lp_constraints_[i];
const glop::VariableStatus row_status =
solution_state->statuses[num_cols + glop::ColIndex(i)];
if (row_status != glop::VariableStatus::BASIC &&
constraint_infos_[constraint_index].is_deletable) {
constraint_infos_[constraint_index].active_count +=
constraint_active_count_increase_;
if (constraint_infos_[constraint_index].active_count >
sat_parameters_.cut_max_active_count_value()) {
rescale_active_count = true;
}
}
}
}
if (rescale_active_count) {
CHECK_GT(sat_parameters_.cut_max_active_count_value(), 0.0);
RescaleActiveCounts(1.0 / sat_parameters_.cut_max_active_count_value());
}
// Update the increment counter.
constraint_active_count_increase_ *=
1.0 / sat_parameters_.cut_active_count_decay();
// Remove constraints from the current LP that have been inactive for a while.
// We do that after we computed new_constraints so we do not need to iterate
// over the just deleted constraints.
@@ -542,6 +668,12 @@ bool LinearConstraintManager::ChangeLp(
glop::VariableStatus::BASIC);
}
// TODO(user): Instead of comparing num_deletable_constraints with cut
// limit, compare number of deletable constraints not in lp against the limit.
if (num_deletable_constraints_ > sat_parameters_.max_num_cuts()) {
PermanentlyRemoveSomeConstraints();
}
// The LP changed only if we added new constraints or if some constraints
// already inside changed (simplification or tighter bounds).
if (current_lp_is_changed_) {

View File

@@ -44,13 +44,25 @@ class LinearConstraintManager {
public:
struct ConstraintInfo {
LinearConstraint constraint;
double l2_norm;
int64 inactive_count;
double objective_parallelism;
bool objective_parallelism_computed;
bool is_in_lp;
double l2_norm = 0.0;
int64 inactive_count = 0;
double objective_parallelism = 0.0;
bool objective_parallelism_computed = false;
bool is_in_lp = false;
size_t hash;
double current_score;
double current_score = 0.0;
// Updated only for deletable constraints. This is incremented every time
// ChangeLp() is called and the constraint is active in the LP or not in the
// LP and violated.
double active_count = 0.0;
// For now, we mark all the generated cuts as deletable and the problem
// constraints as undeletable.
// TODO(user): We can have a better heuristics. Some generated good cuts
// can be marked undeletable and some unused problem specified constraints
// can be marked deletable.
bool is_deletable = false;
};
explicit LinearConstraintManager(Model* model)
@@ -140,6 +152,15 @@ class LinearConstraintManager {
// also lazily computes objective norm.
void ComputeObjectiveParallelism(const ConstraintIndex ct_index);
// Multiplies all active counts and the increment counter by the given
// 'scaling_factor'. This should be called when at least one of the active
// counts is too high.
void RescaleActiveCounts(double scaling_factor);
// Removes some deletable constraints with low active counts. For now, we
// don't remove any constraints which are already in LP.
void PermanentlyRemoveSomeConstraints();
const SatParameters& sat_parameters_;
const IntegerTrail& integer_trail_;
@@ -180,6 +201,17 @@ class LinearConstraintManager {
TimeLimit* time_limit_;
Model* model_;
// We want to decay the active counts of all constraints at each call and
// increase the active counts of active/violated constraints. However this can
// be too slow in practice. So instead, we keep an increment counter and
// update only the active/violated constraints. The counter itself is
// increased by a factor at each call. This has the same effect as decaying
// all the active counts at each call. This trick is similar to sat clause
// management.
double constraint_active_count_increase_ = 1.0;
int32 num_deletable_constraints_ = 0;
};
} // namespace sat

View File

@@ -21,7 +21,7 @@ option java_multiple_files = true;
// Contains the definitions for all the sat algorithm parameters and their
// default values.
//
// NEXT TAG: 155
// NEXT TAG: 158
message SatParameters {
// ==========================================================================
// Branching and polarity
@@ -605,6 +605,15 @@ message SatParameters {
// it become violated by the current LP solution.
optional int32 max_consecutive_inactive_count = 121 [default = 100];
// These parameters are similar to sat clause management activity parameters.
// They are effective only if the number of generated cuts exceed the storage
// limit. Default values are based on a few experiments on miplib instances.
optional double cut_max_active_count_value = 155 [default = 1e10];
optional double cut_active_count_decay = 156 [default = 0.8];
// Target number of constraints to remove during cleanup.
optional int32 cut_cleanup_target = 157 [default = 1000];
// Add that many lazy contraints (or cuts) at once in the LP. Note that at the
// beginning of the solve, we do add more than this.
optional int32 new_constraints_batch_size = 122 [default = 50];

View File

@@ -64,10 +64,10 @@ cc_library(
srcs = ["graph_export.cc"],
hdrs = ["graph_export.h"],
deps = [
"@com_google_absl//absl/strings:str_format",
"//ortools/base",
"//ortools/base:file",
"//ortools/base:status",
"@com_google_absl//absl/strings:str_format",
],
)
@@ -178,11 +178,11 @@ cc_library(
deps = [
":running_stat",
"//ortools/base",
"//ortools/base:sysinfo",
"//ortools/base:timer",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/strings",
"//ortools/base:sysinfo",
"//ortools/base:timer",
],
)

View File

@@ -9,7 +9,7 @@ set_target_properties(${NAME} PROPERTIES
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON
)
)
# CMake < 3.12: CMakeError: Object library may not link to anything.
#target_link_libraries(${NAME} PRIVATE
# absl::base absl::memory absl::strings absl::str_format
@@ -17,39 +17,39 @@ set_target_properties(${NAME} PROPERTIES
# protobuf::libprotobuf
# ${PROJECT_NAME}::proto)
target_include_directories(${NAME} PRIVATE
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
$<TARGET_PROPERTY:absl::base,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::memory,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::strings,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:glog::glog,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_INCLUDE_DIRECTORIES>)
${PROJECT_SOURCE_DIR}
${PROJECT_BINARY_DIR}
$<TARGET_PROPERTY:absl::base,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::memory,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::strings,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:glog::glog,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_INCLUDE_DIRECTORIES>)
target_compile_options(${NAME} PRIVATE
$<TARGET_PROPERTY:absl::base,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_OPTIONS>
)
$<TARGET_PROPERTY:absl::base,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_OPTIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_OPTIONS>
)
target_compile_definitions(${NAME} PRIVATE
$<TARGET_PROPERTY:absl::base,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_DEFINITIONS>
)
$<TARGET_PROPERTY:absl::base,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::memory,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::strings,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:absl::str_format,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:gflags::gflags,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:glog::glog,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:protobuf::libprotobuf,INTERFACE_COMPILE_DEFINITIONS>
$<TARGET_PROPERTY:${PROJECT_NAME}::proto,INTERFACE_COMPILE_DEFINITIONS>
)
add_dependencies(${NAME}
absl::base absl::memory absl::strings absl::str_format
gflags::gflags glog::glog
protobuf::libprotobuf
protobuf::libprotobuf
${PROJECT_NAME}::proto)
add_library(${PROJECT_NAME}::util ALIAS ${NAME})