Maxflow example problem in C++ fails #4524
-
What version of OR-Tools and what language are you using? Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi) What operating system (Linux, Windows, ...) and version? What did you do? cmake_minimum_required(VERSION 3.14)
project(test-maximum-flow VERSION 1.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb")
# Build OR-tools dependencies.
set(BUILD_DEPS ON)
find_package(ortools CONFIG REQUIRED)
add_executable(test-maximum-flow.exe test-maximum-flow.cpp)
target_link_libraries(test-maximum-flow.exe ortools::ortools)
I have a build directory where I execute the following: Then I build the source: When I execute, I get the following: I'm sure that I'm doing something simple incorrectly. Any suggestions? Thank you. What did you expect to see What did you see instead? Make sure you include information that can help us debug (full error message, model Proto). Anything else we should know about your project / environment |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Max flow does not use a MIP solver. |
Beta Was this translation helpful? Give feedback.
-
Your build looks fine (although I observe the same issue with a bazel-based ubuntu-targeting build:
The solver actually solves fine. status 0 is often the OK status and it's also the case here as seen in the enum design. But there seems to be an issue with the status enums vs. inheritance/templated stuff happening... such that we ask about status OPTIMAL and get the anwer "no" despite it being OPTIMAL (but an incompatible enum). @lperron This somewhat looks like a bug? @troyrock For what it's worth: you can fix !this example! with this change: if (status == MaxFlow::OPTIMAL)
->
if (status == SimpleMaxFlow::OPTIMAL) which also matches the earlier constructor. Yes... the code is probably designed such that one should NOT need to pick the enum within the more specialized type, but hey... user@pc:~/Tmp/or-tools$ bazelisk run //ortools/graph/samples:simple_max_flow_program_cc
I0000 00:00:1738015665.140935 148174 simple_max_flow_program.cc:55] Max flow: 60
I0000 00:00:1738015665.141028 148174 simple_max_flow_program.cc:56]
I0000 00:00:1738015665.141037 148174 simple_max_flow_program.cc:57] Arc Flow / Capacity
I0000 00:00:1738015665.141043 148174 simple_max_flow_program.cc:59] 0 -> 1 20 / 20
I0000 00:00:1738015665.141053 148174 simple_max_flow_program.cc:59] 0 -> 2 30 / 30
I0000 00:00:1738015665.141061 148174 simple_max_flow_program.cc:59] 0 -> 3 10 / 10
I0000 00:00:1738015665.141070 148174 simple_max_flow_program.cc:59] 1 -> 2 0 / 40
I0000 00:00:1738015665.141078 148174 simple_max_flow_program.cc:59] 1 -> 4 20 / 30
I0000 00:00:1738015665.141087 148174 simple_max_flow_program.cc:59] 2 -> 3 10 / 10
I0000 00:00:1738015665.141095 148174 simple_max_flow_program.cc:59] 2 -> 4 20 / 20
I0000 00:00:1738015665.141104 148174 simple_max_flow_program.cc:59] 3 -> 2 0 / 5
I0000 00:00:1738015665.141112 148174 simple_max_flow_program.cc:59] 3 -> 4 20 / 20 |
Beta Was this translation helpful? Give feedback.
-
We rewrote all the flow/graph code for 9.12.
And indeed we changed the class of the enum in that example.
So, this is a bug, and it is fixed on main.
Laurent Perron | Operations Research | ***@***.*** | (33) 1 42 68 53
00
Le mar. 28 janv. 2025 à 00:08, Troy Rockwood ***@***.***> a
écrit :
… Great! Making this change does indeed fix the problem. Thanks for the tip.
Too bad it doesn't work "out of the box."
—
Reply to this email directly, view it on GitHub
<#4524 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACUPL3OSW7FMODCWMZ3NQXD2M237PAVCNFSM6AAAAABV7DGCVKVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCOJXG4ZDQNI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
Your build looks fine (although
/apps/spack/linux-rhel8-zen/gcc-8.5.0/gcc-11.2.0-xiaeky3yguq32ddvvibp2o5n4gexejc2/bin/g++
looks funny).I observe the same issue with a bazel-based ubuntu-targeting build: