| 43 | } |
| 44 | |
| 45 | virtual void separation_oracle ( |
| 46 | const long idx, |
| 47 | const matrix_type& current_solution, |
| 48 | scalar_type& loss, |
| 49 | feature_vector_type& psi |
| 50 | ) const |
| 51 | { |
| 52 | py::object res = problem.attr("separation_oracle")(idx,std::ref(current_solution)); |
| 53 | pyassert(len(res) == 2, "separation_oracle() must return two objects, the loss and the psi vector"); |
| 54 | py::tuple t = res.cast<py::tuple>(); |
| 55 | // let the user supply the output arguments in any order. |
| 56 | try { |
| 57 | loss = t[0].cast<scalar_type>(); |
| 58 | psi = t[1].cast<feature_vector_type&>(); |
| 59 | } catch(py::cast_error&) { |
| 60 | psi = t[0].cast<feature_vector_type&>(); |
| 61 | loss = t[1].cast<scalar_type>(); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | private: |
| 66 | |