@@ -162,7 +162,7 @@ impl Model<ProblemCreated> {
162
162
///
163
163
/// # Returns
164
164
///
165
- /// A reference-counted pointer to the new variable.
165
+ /// The created `Variable`
166
166
///
167
167
/// # Panics
168
168
///
@@ -401,7 +401,7 @@ impl Model<Solving> {
401
401
///
402
402
/// # Returns
403
403
///
404
- /// A reference-counted pointer to the new variable.
404
+ /// The created `Variable`
405
405
///
406
406
/// # Panics
407
407
///
@@ -426,10 +426,6 @@ impl Model<Solving> {
426
426
}
427
427
428
428
/// Returns the current node of the model.
429
- ///
430
- /// # Panics
431
- ///
432
- /// This method panics if not called in the `Solving` state, it should only be used from plugins implementations.
433
429
pub fn focus_node ( & self ) -> Node {
434
430
let scip_node = self . scip . focus_node ( ) . expect ( "Failed to get focus node" ) ;
435
431
Node {
@@ -439,10 +435,6 @@ impl Model<Solving> {
439
435
}
440
436
441
437
/// Creates a new child node of the current node and returns it.
442
- ///
443
- /// # Panics
444
- ///
445
- /// This method panics if not called from plugins implementations.
446
438
pub fn create_child ( & mut self ) -> Node {
447
439
let node_ptr = self
448
440
. scip
@@ -467,7 +459,7 @@ impl Model<Solving> {
467
459
///
468
460
/// # Returns
469
461
///
470
- /// This function returns a reference-counted smart pointer (`Rc`) to the created `Variable` instance.
462
+ /// The created `Variable`
471
463
pub fn add_priced_var (
472
464
& mut self ,
473
465
lb : f64 ,
@@ -491,29 +483,28 @@ impl Model<Solving> {
491
483
///
492
484
/// # Arguments
493
485
///
494
- /// * `cons` - The constraint to add.
495
- /// * `validnode` - The node with the lowest depth for which the constraint is valid.
486
+ /// * `cons` - The constraint to add (can be built by calling the cons() function).
496
487
///
497
488
/// # Returns
498
489
///
499
- /// A reference-counted pointer to the new constraint.
490
+ /// The new constraint
500
491
///
501
492
/// # Panics
502
493
///
503
494
/// This method panics if the constraint cannot be created in the current state.
504
- pub fn add_cons_local ( & mut self , cons_builder : & ConsBuilder ) -> Constraint {
505
- let vars: Vec < & Variable > = cons_builder . coefs . iter ( ) . map ( |( var, _) | * var) . collect ( ) ;
506
- let coefs: Vec < f64 > = cons_builder . coefs . iter ( ) . map ( |( _, coef) | * coef) . collect ( ) ;
495
+ pub fn add_cons_local ( & mut self , cons : & ConsBuilder ) -> Constraint {
496
+ let vars: Vec < & Variable > = cons . coefs . iter ( ) . map ( |( var, _) | * var) . collect ( ) ;
497
+ let coefs: Vec < f64 > = cons . coefs . iter ( ) . map ( |( _, coef) | * coef) . collect ( ) ;
507
498
508
499
let cons = self
509
500
. scip
510
501
. create_cons (
511
502
None ,
512
503
vars,
513
504
& coefs,
514
- cons_builder . lhs ,
515
- cons_builder . rhs ,
516
- cons_builder . name . unwrap_or ( "" ) ,
505
+ cons . lhs ,
506
+ cons . rhs ,
507
+ cons . name . unwrap_or ( "" ) ,
517
508
true ,
518
509
)
519
510
. expect ( "Failed to create constraint in state ProblemCreated" ) ;
@@ -527,29 +518,29 @@ impl Model<Solving> {
527
518
///
528
519
/// # Arguments
529
520
///
530
- /// * `cons` - The constraint to add .
531
- /// * `validnode ` - The node at which the constraint is valid .
521
+ /// * `node` - The node to which the constraint should be added .
522
+ /// * `cons ` - The constraint to add .
532
523
///
533
524
/// # Returns
534
525
///
535
- /// A reference-counted pointer to the new constraint .
526
+ /// The created `Constraint` .
536
527
///
537
528
/// # Panics
538
529
///
539
530
/// This method panics if the constraint cannot be created in the current state.
540
- pub fn add_cons_node ( & mut self , node : & Node , cons_builder : & ConsBuilder ) -> Constraint {
541
- let vars: Vec < & Variable > = cons_builder . coefs . iter ( ) . map ( |( var, _) | * var) . collect ( ) ;
542
- let coefs: Vec < f64 > = cons_builder . coefs . iter ( ) . map ( |( _, coef) | * coef) . collect ( ) ;
531
+ pub fn add_cons_node ( & mut self , node : & Node , cons : & ConsBuilder ) -> Constraint {
532
+ let vars: Vec < & Variable > = cons . coefs . iter ( ) . map ( |( var, _) | * var) . collect ( ) ;
533
+ let coefs: Vec < f64 > = cons . coefs . iter ( ) . map ( |( _, coef) | * coef) . collect ( ) ;
543
534
544
535
let cons = self
545
536
. scip
546
537
. create_cons (
547
538
Some ( node) ,
548
539
vars,
549
540
& coefs,
550
- cons_builder . lhs ,
551
- cons_builder . rhs ,
552
- cons_builder . name . unwrap_or ( "" ) ,
541
+ cons . lhs ,
542
+ cons . rhs ,
543
+ cons . name . unwrap_or ( "" ) ,
553
544
true ,
554
545
)
555
546
. expect ( "Failed to create constraint in state ProblemCreated" ) ;
@@ -566,7 +557,7 @@ impl Model<Solving> {
566
557
/// * `var_prob_id` - The index of the variable in the problem.
567
558
///
568
559
/// # Returns
569
- /// A reference-counted pointer to the variable .
560
+ /// The `Variable` if it exists, otherwise `None` .
570
561
pub fn var_in_prob ( & self , var_prob_id : usize ) -> Option < Variable > {
571
562
unsafe {
572
563
ScipPtr :: var_from_id ( self . scip . raw , var_prob_id) . map ( |v| Variable {
@@ -1142,7 +1133,7 @@ impl<S: ModelStageProblemOrSolving> ProblemOrSolving for Model<S> {
1142
1133
///
1143
1134
/// # Returns
1144
1135
///
1145
- /// A reference-counted pointer to the new constraint .
1136
+ /// The new `Constraint` .
1146
1137
///
1147
1138
/// # Panics
1148
1139
///
@@ -1169,7 +1160,7 @@ impl<S: ModelStageProblemOrSolving> ProblemOrSolving for Model<S> {
1169
1160
///
1170
1161
/// # Returns
1171
1162
///
1172
- /// A reference-counted pointer to the new constraint.
1163
+ /// The created `Constraint`
1173
1164
///
1174
1165
/// # Panics
1175
1166
///
@@ -1197,7 +1188,7 @@ impl<S: ModelStageProblemOrSolving> ProblemOrSolving for Model<S> {
1197
1188
///
1198
1189
/// # Returns
1199
1190
///
1200
- /// A reference-counted pointer to the new constraint.
1191
+ /// The created `Constraint`
1201
1192
///
1202
1193
/// # Panics
1203
1194
///
@@ -1231,7 +1222,7 @@ impl<S: ModelStageProblemOrSolving> ProblemOrSolving for Model<S> {
1231
1222
///
1232
1223
/// # Returns
1233
1224
///
1234
- /// A reference-counted pointer to the new constraint.
1225
+ /// The created `Constraint`
1235
1226
///
1236
1227
/// # Panics
1237
1228
///
0 commit comments