From df50178365f1cc0f3edd8df4f238eab60569a94e Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Wed, 2 Jul 2025 09:33:25 +0100 Subject: [PATCH 1/2] Add `as_ptr` and `as_mut_ptr` methods to `Model` --- src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index d74898f..bc5552c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -260,6 +260,16 @@ pub enum Sense { } impl Model { + /// Return pointer to underlying HiGHS model + pub fn as_ptr(&self) -> *const c_void{ + self.highs.ptr() + } + + /// Return mutable pointer to underlying HiGHS model + pub fn as_mut_ptr(&mut self) -> *mut c_void{ + self.highs.mut_ptr() + } + /// Set the optimization sense (minimize by default) pub fn set_sense(&mut self, sense: Sense) { let ret = unsafe { Highs_changeObjectiveSense(self.highs.mut_ptr(), sense as c_int) }; From 2a6462c22f9000a69fbb6c10fac8322c1e754ff8 Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Wed, 2 Jul 2025 09:55:39 +0100 Subject: [PATCH 2/2] Add `as_ptr` and `as_mut_ptr` methods to `SolvedModel` --- src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index bc5552c..20d5d4f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -601,6 +601,16 @@ impl HighsPtr { } impl SolvedModel { + /// Return pointer to underlying HiGHS model + pub fn as_ptr(&self) -> *const c_void{ + self.highs.ptr() + } + + /// Return mutable pointer to underlying HiGHS model + pub fn as_mut_ptr(&mut self) -> *mut c_void{ + self.highs.mut_ptr() + } + /// The status of the solution. Should be Optimal if everything went well. pub fn status(&self) -> HighsModelStatus { let model_status = unsafe { Highs_getModelStatus(self.highs.unsafe_mut_ptr()) };