-
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
Multi-threaded CP-SAT solver is crashed #2001
Comments
|
Works flawlessly on mac.
Laurent Perron | Operations Research | lperron@google.com | (33) 1 42 68 53
00
Le dim. 3 mai 2020 à 18:10, vaidzelevich <notifications@github.com> a
écrit :
… *What version of OR-tools and what language are you using?*
Version: stable/v7.6
Language: C++ (Visual Studio 2019, version 16.5.4)
*Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP,
Gurobi)*
CP-SAT
*What operating system (Linux, Windows, ...) and version?*
Windows 10, build 18363.778
*What did you do?*
Solved the following multiple knapsacks problem using the CP-SAT solver
#include "ortools/sat/cp_model.h"
struct DataModel {
const std::vector<int> weights = { 48, 30, 42, 36, 36, 48, 42, 42,
36, 24, 30, 30, 42, 36, 36 };
const std::vector<int> values = { 10, 30, 25, 50, 35, 30, 15, 40,
30, 35, 45, 10, 20, 30, 25 };
const int num_items = (int)weights.size();
const std::vector<int> bin_capacities = { 100, 100, 100, 100, 100 };
const int num_bins = (int)bin_capacities.size();
};
namespace operations_research {
namespace sat {
void MulitpleKnapsackSat() {
DataModel data;
std::vector<BoolVar> variables(data.num_items * data.num_bins);
auto x = [&](int item_index, int bin_index) -> BoolVar& {
return variables[item_index * data.num_bins + bin_index];
};
CpModelBuilder cp_model;
for (auto i = 0; i < data.num_items; ++i) {
for (auto j = 0; j < data.num_bins; ++j) {
x(i, j) = cp_model.NewBoolVar();
}
}
for (auto i = 0; i < data.num_items; ++i) {
LinearExpr sum;
for (auto j = 0; j < data.num_bins; ++j) {
sum.AddTerm(x(i, j), 1);
}
cp_model.AddLessOrEqual(sum, 1);
}
for (auto j = 0; j < data.num_bins; ++j) {
LinearExpr sum;
for (auto i = 0; i < data.num_items; ++i) {
sum.AddTerm(x(i, j), data.weights[i]);
}
cp_model.AddLessOrEqual(sum, data.bin_capacities[j]);
}
LinearExpr obj;
for (auto i = 0; i < data.num_items; ++i) {
for (auto j = 0; j < data.num_bins; ++j) {
obj.AddTerm(x(i, j), data.values[i]);
}
}
cp_model.Maximize(obj);
SatParameters parameters;
parameters.set_num_search_workers(16);
const CpSolverResponse responce = SolveWithParameters(cp_model.Build(),
parameters);
}
} // namespace sat
} // namespace operations_research
int main() {
operations_research::sat::MulitpleKnapsackSat();
return EXIT_SUCCESS;
}
*What did you expect to see*
Successful solving of the problem as the single-threaded solver does
*What did you see instead?*
The solver is crashed in the destructor
LinearConstraintManager::~LinearConstraintManager() while trying to check
the flag sat_parameters_.log_search_progress()
Make sure you include information that can help us debug (full error
message, model Proto).
*Anything else we should know about your project / environment*
The library was built from the sources using cmake
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2001>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACUPL3IKBQLDRJOX424SIDLRPWJPJANCNFSM4MYF6V4Q>
.
|
|
Thank you very much for so quick answer. |
|
The fix is useful when you run multiple solvers in parallel (as in a
server).
Laurent Perron | Operations Research | lperron@google.com | (33) 1 42 68 53
00
Le dim. 3 mai 2020 à 23:52, vaidzelevich <notifications@github.com> a
écrit :
… Thank you very much for so quick answer.
I have tried the master branch. Unfortunately, the CP-SAT solver still
crashes with error.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2001 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACUPL3PPDRR4HHHOPOKSCR3RPXRQPANCNFSM4MYF6V4Q>
.
|
|
I believe this was just fixed. |
|
Thank you for your response. I’ve tried to build the latest version from the master branch, but there is a problem, namely, the compiler says that files ortools/sat/cp_model.pb.h, ortools/sat/sat_parameters.pb.h, … are missed. I will try to fix the problem and provide the answer as soon as possible. |
|
make all_protos
make
Laurent Perron | Operations Research | lperron@google.com | (33) 1 42 68 53
00
Le sam. 22 août 2020 à 10:07, vaidzelevich <notifications@github.com> a
écrit :
… Thank you for your response. I’ve tried to build the latest version from
the master branch, but there is a problem, namely, the compiler says that
files ortools/sat/cp_model.pb.h, ortools/sat/sat_parameters.pb.h, … are
missed. I will try to fix the problem and provide the answer as soon as
possible.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2001 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACUPL3JGVEOHFPTUPE3S473SB54FVANCNFSM4MYF6V4Q>
.
|
|
I use or-tools by incorporating it into my cmake project. It turned out that missed files are in the build directory, so using cmake’s command include_directories I’ve solved the mentioned problem. I rebuilt and checked the test. Everything is good. Thank you very much. |
|
@vaidzelevich out of curiosity how did you incorporate or-tools ? i.e. note: Soon I would like to add some ci tests to test or-tools integration in a super build |
|
I use add_subdirectory, to be more precise, the following commands |
|
Thanks ! BTW many thanks for your feedback, it's always cool to see people integrating it in their process... |
What version of OR-tools and what language are you using?
Version: stable/v7.6
Language: C++ (Visual Studio 2019, version 16.5.4)
Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi)
CP-SAT
What operating system (Linux, Windows, ...) and version?
Windows 10, build 18363.778
What did you do?
Solved the following multiple knapsacks problem using the CP-SAT solver
What did you expect to see
Successful solving of the problem as the single-threaded solver does
What did you see instead?
The solver is crashed in the destructor LinearConstraintManager::~LinearConstraintManager() while trying to check the flag sat_parameters_.log_search_progress()
Make sure you include information that can help us debug (full error message, model Proto).
Anything else we should know about your project / environment
The library was built from the sources using cmake
The text was updated successfully, but these errors were encountered: