-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CPSAT 9.1: C++ wrong optimal solution and wrong infeasibility #2896
Comments
I am sorry but I cannot do anything from this report. |
@lperron I could not come up with a small code example, so I would just send you the proto if you don't mind. |
Yes please
Le dim. 14 nov. 2021, 20:13, Phibedy ***@***.***> a écrit :
… @lperron <https://github.com/lperron> I could not come up with a small
code example, so I would just send you the proto if you don't mind.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2896 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACUPL3J5QF2BC3EQS4KJGC3UMAC7JANCNFSM5H6Z5OQA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
I've sent you the models + optimization logs. If you need something else just let me know. |
I ran all protos multiple times on master (1 or multiple threads, always with presolve). |
It currently fails on my computer using But I could set up a Dockerfile to solve it. |
I use the C++ example sat_runner.
The easiest way to run it is to download the sources, install bazel from
bazel.io
then run:
bazel build -c opt --cxxopt=-std=c++17 examples/cpp/sat_runner &&
./bazel-bin/examples/cpp/sat_runner --logtostderr --input <path to proto>
--params num_search_workers:8
Laurent Perron | Operations Research | ***@***.*** | (33) 1 42 68 53
00
Le dim. 14 nov. 2021 à 23:13, Phibedy ***@***.***> a écrit :
… It currently fails on my computer using FetchContent_Declare in CMAKE and
in the CI it fails using
https://github.com/google/or-tools/releases/download/v9.1/or-tools_amd64_ubuntu-20.04_v9.1.9490.tar.gz
with the ubuntu:20.04 as base image.
But I could set up a Dockerfile to solve it.
Can you share the code how you executed the model proto directly?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2896 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACUPL3OE4CCNENYK4V5YDRTUMAYAZANCNFSM5H6Z5OQA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
I just ported the code back up 9.0 (used some functions which were added in 9.1). $ git diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4a25195..01af829 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,7 +25,7 @@ else()
FetchContent_Declare(
ortools
GIT_REPOSITORY https://github.com/google/or-tools.git
- GIT_TAG v9.0
+ GIT_TAG v9.1
) Tomorrow I will build the examples and try the sat_runner. |
you shoult try the master branch. |
Yay today I learned how to store/load the proto-stuff. Code: #include "ortools/sat/cp_model.h"
#include "ortools/base/file.h"
#include "ortools/util/file_util.h"
struct OptimizationSettings
{
int timeoutInSeconds = 3600;
int numberOfThreads = 8;
bool enablePreSolve = false;
};
namespace cpsat = operations_research::sat;
cpsat::CpSolverResponse solveProtoFile(std::string fileName, const OptimizationSettings &optimizationSettings)
{
using namespace operations_research;
using namespace operations_research::sat;
//google::InitGoogleLogging(argv[0]);
// Read the problem.
CpModelProto cpModel = ReadFileToProtoOrDie<CpModelProto>(fileName);
Model solverModel;
SatParameters parameters;
//parameters.set_cp_model_presolve(false);
parameters.set_cp_model_presolve(optimizationSettings.enablePreSolve);
parameters.set_max_time_in_seconds(optimizationSettings.timeoutInSeconds);
parameters.set_num_search_workers(optimizationSettings.numberOfThreads);
solverModel.Add(NewSatParameters(parameters));
int numSolutions = 0;
solverModel.Add(NewFeasibleSolutionObserver([&](const CpSolverResponse &r)
{
LOG(ERROR) << "Solution " << numSolutions << " objective: " << r.objective_value();
numSolutions++;
}));
LOG(ERROR)
<< "Start solve threads:";
const CpSolverResponse response = SolveCpModel(cpModel, &solverModel);
LOG(ERROR) << CpSolverResponseStats(response);
LOG(INFO) << "END solve";
return response;
}
int main(int argc, char **argv)
{
//google::InitGoogleLogging(argv[0]);
OptimizationSettings withPreSolve = {.timeoutInSeconds = 3600, .numberOfThreads = 8, .enablePreSolve = true};
OptimizationSettings withoutPreSolve = {.timeoutInSeconds = 3600, .numberOfThreads = 8, .enablePreSolve = false};
solveProtoFile("./model_fail.proto", withoutPreSolve);
solveProtoFile("./infeasible_model.proto", withoutPreSolve);
LOG(ERROR) << "--------------------------------------";
solveProtoFile("./model_fail.proto", withPreSolve);
solveProtoFile("./infeasible_model.proto", withPreSolve);
return EXIT_SUCCESS;
} So in the master branch,it only works with pre-solve enabled. I will send you a small repo with the test protos + CMAKE stuff etc. |
I just sent you the email. For completeness the
CMAKE: cmake_minimum_required(VERSION 3.16)
project(ortools_runner)
if (USE_PRECOMPILED_ORTOOLS)
link_directories(/usr/local/lib)
set(ORTOOLS_LIBS "ortools")
else()
include(FetchContent)
set (BUILD_SAMPLES OFF)
set (BUILD_EXAMPLES OFF)
FetchContent_Declare(
ortools
GIT_REPOSITORY https://github.com/google/or-tools.git
GIT_TAG master
)
set(BUILD_DEPS ON)
FetchContent_MakeAvailable(ortools)
set(ORTOOLS_LIBS "ortools::ortools")
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)
#is include_directories needed?
include_directories(src)
add_executable(main src/main.cpp)
target_link_libraries(main ${ORTOOLS_LIBS})
add_custom_command(
TARGET main POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/model_fail.proto
${CMAKE_CURRENT_BINARY_DIR}/model_fail.proto)
add_custom_command(
TARGET main POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/infeasible_model.proto
${CMAKE_CURRENT_BINARY_DIR}/infeasible_model.proto) |
I am looking into this. It seems to be a problem with our symmetry detection code. |
@fdid-git Thank you :) |
Should be all fixed on master. |
What version of OR-Tools and what language are you using?
Version: v9.1.
Language: C++
With 9.0 it works.
Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi)
CP-SAT
What operating system (Linux, Windows, ...) and version?
Ubuntu 20.04
What did you do?
I encountered different problems:
What the code does:
Solve two Objectives. After the first objective is minimized a constraint is added which forces the objective to be <= the objective value. Then it optimizes the next objective.
The fun part is "most of the time":
My console log:
second run:
So there are two problems here:
I am 100% sure that I did not change the binary in between the runs or anything else. I just run the command twice.
Just to convince myself the timestamps:
So yes, I am sure that I did nothing stupid in the 0.7 seconds in between the two logging messages.
If I just force the first objective to be 0 the output is:
and sometimes it works:
I also tried the master branch, but there it does nothing. It just idles using one thread. No console message after
SolveCpModel
CMAKE:
The text was updated successfully, but these errors were encountered: