Skip to content

Commit 24e4866

Browse files
committed
Documentation fixes
1 parent 45377f4 commit 24e4866

File tree

1 file changed

+25
-34
lines changed

1 file changed

+25
-34
lines changed

src/model.rs

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl Model<ProblemCreated> {
162162
///
163163
/// # Returns
164164
///
165-
/// A reference-counted pointer to the new variable.
165+
/// The created `Variable`
166166
///
167167
/// # Panics
168168
///
@@ -401,7 +401,7 @@ impl Model<Solving> {
401401
///
402402
/// # Returns
403403
///
404-
/// A reference-counted pointer to the new variable.
404+
/// The created `Variable`
405405
///
406406
/// # Panics
407407
///
@@ -426,10 +426,6 @@ impl Model<Solving> {
426426
}
427427

428428
/// 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.
433429
pub fn focus_node(&self) -> Node {
434430
let scip_node = self.scip.focus_node().expect("Failed to get focus node");
435431
Node {
@@ -439,10 +435,6 @@ impl Model<Solving> {
439435
}
440436

441437
/// 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.
446438
pub fn create_child(&mut self) -> Node {
447439
let node_ptr = self
448440
.scip
@@ -467,7 +459,7 @@ impl Model<Solving> {
467459
///
468460
/// # Returns
469461
///
470-
/// This function returns a reference-counted smart pointer (`Rc`) to the created `Variable` instance.
462+
/// The created `Variable`
471463
pub fn add_priced_var(
472464
&mut self,
473465
lb: f64,
@@ -491,29 +483,28 @@ impl Model<Solving> {
491483
///
492484
/// # Arguments
493485
///
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).
496487
///
497488
/// # Returns
498489
///
499-
/// A reference-counted pointer to the new constraint.
490+
/// The new constraint
500491
///
501492
/// # Panics
502493
///
503494
/// 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();
507498

508499
let cons = self
509500
.scip
510501
.create_cons(
511502
None,
512503
vars,
513504
&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(""),
517508
true,
518509
)
519510
.expect("Failed to create constraint in state ProblemCreated");
@@ -527,29 +518,29 @@ impl Model<Solving> {
527518
///
528519
/// # Arguments
529520
///
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.
532523
///
533524
/// # Returns
534525
///
535-
/// A reference-counted pointer to the new constraint.
526+
/// The created `Constraint`.
536527
///
537528
/// # Panics
538529
///
539530
/// 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();
543534

544535
let cons = self
545536
.scip
546537
.create_cons(
547538
Some(node),
548539
vars,
549540
&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(""),
553544
true,
554545
)
555546
.expect("Failed to create constraint in state ProblemCreated");
@@ -566,7 +557,7 @@ impl Model<Solving> {
566557
/// * `var_prob_id` - The index of the variable in the problem.
567558
///
568559
/// # Returns
569-
/// A reference-counted pointer to the variable.
560+
/// The `Variable` if it exists, otherwise `None`.
570561
pub fn var_in_prob(&self, var_prob_id: usize) -> Option<Variable> {
571562
unsafe {
572563
ScipPtr::var_from_id(self.scip.raw, var_prob_id).map(|v| Variable {
@@ -1142,7 +1133,7 @@ impl<S: ModelStageProblemOrSolving> ProblemOrSolving for Model<S> {
11421133
///
11431134
/// # Returns
11441135
///
1145-
/// A reference-counted pointer to the new constraint.
1136+
/// The new `Constraint`.
11461137
///
11471138
/// # Panics
11481139
///
@@ -1169,7 +1160,7 @@ impl<S: ModelStageProblemOrSolving> ProblemOrSolving for Model<S> {
11691160
///
11701161
/// # Returns
11711162
///
1172-
/// A reference-counted pointer to the new constraint.
1163+
/// The created `Constraint`
11731164
///
11741165
/// # Panics
11751166
///
@@ -1197,7 +1188,7 @@ impl<S: ModelStageProblemOrSolving> ProblemOrSolving for Model<S> {
11971188
///
11981189
/// # Returns
11991190
///
1200-
/// A reference-counted pointer to the new constraint.
1191+
/// The created `Constraint`
12011192
///
12021193
/// # Panics
12031194
///
@@ -1231,7 +1222,7 @@ impl<S: ModelStageProblemOrSolving> ProblemOrSolving for Model<S> {
12311222
///
12321223
/// # Returns
12331224
///
1234-
/// A reference-counted pointer to the new constraint.
1225+
/// The created `Constraint`
12351226
///
12361227
/// # Panics
12371228
///

0 commit comments

Comments
 (0)