diff --git a/src/cp_sat_wrapper.cpp b/src/cp_sat_wrapper.cpp index 1dc82db..13ec927 100644 --- a/src/cp_sat_wrapper.cpp +++ b/src/cp_sat_wrapper.cpp @@ -61,20 +61,6 @@ cp_sat_wrapper_cp_model_stats(unsigned char* model_buf, size_t model_size) { return strdup(stats.c_str()); } -extern "C" char* -cp_sat_wrapper_cp_solver_response_stats( - unsigned char* response_buf, - size_t response_size, - bool has_objective) -{ - sat::CpSolverResponse response; - const bool res = response.ParseFromArray(response_buf, response_size); - assert(res); - - const std::string stats = sat::CpSolverResponseStats(response, has_objective); - return strdup(stats.c_str()); -} - extern "C" char* cp_sat_wrapper_validate_cp_model(unsigned char* model_buf, size_t model_size) { sat::CpModelProto model; diff --git a/src/ffi.rs b/src/ffi.rs index 681d5f3..d1a3e25 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -17,11 +17,6 @@ extern "C" { out_size: &mut usize, ) -> *mut u8; fn cp_sat_wrapper_cp_model_stats(model_buf: *const u8, model_size: usize) -> *mut c_char; - fn cp_sat_wrapper_cp_solver_response_stats( - response_buf: *const u8, - response_size: usize, - has_objective: bool, - ) -> *mut c_char; fn cp_sat_wrapper_validate_cp_model(model_buf: *const u8, model_size: usize) -> *mut c_char; fn cp_sat_wrapper_solution_is_feasible( model_buf: *const u8, @@ -86,29 +81,6 @@ pub fn cp_model_stats(model: &proto::CpModelProto) -> String { res } -/// Returns a string with some statistics on the solver response. -/// -/// If the second argument is false, we will just display NA for the -/// objective value instead of zero. It is not really needed but it -/// makes things a bit clearer to see that there is no objective. -pub fn cp_solver_response_stats(response: &proto::CpSolverResponse, has_objective: bool) -> String { - let mut response_buf = Vec::default(); - response.encode(&mut response_buf).unwrap(); - let char_ptr = unsafe { - cp_sat_wrapper_cp_solver_response_stats( - response_buf.as_ptr(), - response_buf.len(), - has_objective, - ) - }; - let res = unsafe { CStr::from_ptr(char_ptr) } - .to_str() - .unwrap() - .to_owned(); - unsafe { libc::free(char_ptr as _) }; - res -} - /// Verifies that the given model satisfies all the properties /// described in the proto comments. Returns an empty string if it is /// the case, otherwise fails at the first error and returns a diff --git a/src/lib.rs b/src/lib.rs index b04bfd6..df2fce9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,7 +33,7 @@ //! let response = model.solve(); //! println!( //! "{}", -//! cp_sat::ffi::cp_solver_response_stats(&response, false) +//! cp_sat::ffi::cp_model_stats(&model.proto()) //! ); //! //! if response.status() == CpSolverStatus::Optimal {