@@ -48,15 +48,17 @@ pub fn lp_solve(to_solve: UnsolvedProblem) -> LpSolveProblem {
4848
4949 let cols = to_c ( variables. len ( ) ) ;
5050 let mut model = Problem :: new ( 0 , cols) . expect ( "Unable to create problem" ) ;
51- let ( obj_coefs, obj_idx, _const) = expr_to_scatter_vec ( objective) ;
52- assert ! ( model. scatter_objective_function( & obj_coefs, & obj_idx) ) ;
51+ let ( mut obj_coefs, mut obj_idx, _const) = expr_to_scatter_vec ( objective) ;
52+ model
53+ . scatter_objective_function ( obj_coefs. as_mut_slice ( ) , obj_idx. as_mut_slice ( ) )
54+ . unwrap ( ) ;
5355 for ( i, v) in variables. into_iter ( ) . enumerate ( ) {
5456 let col = to_c ( i + 1 ) ;
55- assert ! ( model. set_integer( col, v. is_integer) ) ;
57+ model. set_integer ( col, v. is_integer ) . unwrap ( ) ;
5658 if v. min . is_finite ( ) || v. max . is_finite ( ) {
57- assert ! ( model. set_bounds( col, v. min, v. max) ) ;
59+ model. set_bounds ( col, v. min , v. max ) . unwrap ( ) ;
5860 } else {
59- assert ! ( model. set_unbounded( col) ) ;
61+ model. set_unbounded ( col) . unwrap ( ) ;
6062 }
6163 }
6264 LpSolveProblem ( model)
@@ -114,8 +116,10 @@ impl SolverModel for LpSolveProblem {
114116 } else {
115117 ConstraintType :: Le
116118 } ;
117- let success = self . 0 . add_constraint ( & coeffs, target, constraint_type) ;
118- assert ! ( success, "could not add constraint. memory error." ) ;
119+ let success = self
120+ . 0
121+ . add_constraint ( coeffs. as_mut_slice ( ) , target, constraint_type) ;
122+ assert ! ( success. is_ok( ) , "could not add constraint. memory error." ) ;
119123 ConstraintReference { index }
120124 }
121125
@@ -135,8 +139,13 @@ impl ModelWithSOS1 for LpSolveProblem {
135139 variables. push ( var. index ( ) . try_into ( ) . expect ( "too many vars" ) ) ;
136140 }
137141 let name = CString :: new ( "sos" ) . unwrap ( ) ;
138- self . 0
139- . add_sos_constraint ( & name, SOSType :: Type1 , 1 , & weights, & variables) ;
142+ self . 0 . add_sos_constraint (
143+ & name,
144+ SOSType :: Type1 ,
145+ 1 ,
146+ weights. as_mut_slice ( ) ,
147+ variables. as_mut_slice ( ) ,
148+ ) ;
140149 }
141150}
142151
0 commit comments