ankane / or-tools-ruby

Operations research tools for Ruby

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

stop_search missing

glenbray opened this issue · comments

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?

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

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