Skip to content
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

stop_search missing #46

Open
glenbray opened this issue Apr 23, 2023 · 2 comments
Open

stop_search missing #46

glenbray opened this issue Apr 23, 2023 · 2 comments

Comments

@glenbray
Copy link

glenbray commented Apr 23, 2023

Hey, so I was trying to convert this code from Python to Ruby using the following employee scheduling guide here. Towards the end, the Python calls StopSearch, but this isn't available in this lib.

Duno if this is the right approach but I had some success adding this definition into constraint.cpp

#include <ortools/sat/swig_helper.h>
using operations_research::sat::SolutionCallback;

Rice::define_class_under<SolutionCallback>(m, "SolutionCallback")
  .define_method("stop_search", &SolutionCallback::StopSearch);

then Updating cp_solver_solution_callback.rb to:

class CpSolverSolutionCallback < SolutionCallback

I could at least call the stop_search function in the NursesPartialSolutionPrinter from the guide. But I got stuck with the atomic bool here:

https://github.com/google/or-tools/blob/5425dedcfbb22cb74c636c1374a9b5ad684b1eb5/ortools/sat/swig_helper.cc#L90

The CPP stuff is a bit beyond me, to be honest 😢.

Any chance the stop_search method could get added?

@ankane ankane closed this as completed in 6df118b Apr 23, 2023
@ankane
Copy link
Owner

ankane commented Apr 23, 2023

Hi @glenbray, thanks for the suggestion. Added in the commit above.

@ankane
Copy link
Owner

ankane commented Apr 23, 2023

Seeing segfaults on Ubuntu - need to dig into it more.

@ankane ankane reopened this Apr 23, 2023
@ankane ankane closed this as completed in 0337641 Apr 23, 2023
@ankane ankane reopened this Apr 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants