RsBundle  Check-in [ee9e94be2a]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add `Update::ModifyPrimal` update information
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | modifyprimals
Files: files | file ages | folders
SHA1: ee9e94be2a9effca78be34a901fd93e39c555d92
User & Date: fifr 2018-08-30 09:04:44.433
Context
2018-08-30
11:07
Implement `Update::ModifyPrimals` check-in: a5c90ab126 user: fifr tags: modifyprimals
09:04
Add `Update::ModifyPrimal` update information check-in: ee9e94be2a user: fifr tags: modifyprimals
09:04
Update version to 0.6.0-dev check-in: a4c479bbc1 user: fifr tags: modifyprimals
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/firstorderproblem.rs.
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81


82
83
84
85
86
87
88
}

/// Problem update information.
///
/// The solver calls the `update` method of the problem regularly.
/// This method can modify the problem by adding (or removing)
/// variables. The possible updates are encoded in this type.
#[derive(Debug, Clone, Copy)]
pub enum Update {
    /// Add a variable with bounds.
    ///
    /// The initial value of the variable will be the feasible value
    /// closest to 0.
    AddVariable { lower: Real, upper: Real },
    /// Add a variable with bounds and initial value.
    AddVariableValue { lower: Real, upper: Real, value: Real },
    /// Change the current value of a variable. The bounds remain
    /// unchanged.
    MoveVariable { index: usize, value: Real },


}

/**
 * Trait for implementing a first-order problem description.
 *
 */
pub trait FirstOrderProblem {







<
|










>
>







63
64
65
66
67
68
69

70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
}

/// Problem update information.
///
/// The solver calls the `update` method of the problem regularly.
/// This method can modify the problem by adding (or removing)
/// variables. The possible updates are encoded in this type.

pub enum Update<P> {
    /// Add a variable with bounds.
    ///
    /// The initial value of the variable will be the feasible value
    /// closest to 0.
    AddVariable { lower: Real, upper: Real },
    /// Add a variable with bounds and initial value.
    AddVariableValue { lower: Real, upper: Real, value: Real },
    /// Change the current value of a variable. The bounds remain
    /// unchanged.
    MoveVariable { index: usize, value: Real },
    /// Update primal variables.
    ModifyPrimal(Box<Fn(&mut P)>),
}

/**
 * Trait for implementing a first-order problem description.
 *
 */
pub trait FirstOrderProblem {
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
        let mut primals = primals;
        primals.pop().unwrap().1
    }

    /// Return updates of the problem.
    ///
    /// The default implementation returns no updates.
    fn update(&mut self, _state: &UpdateState<Self::Primal>) -> Result<Vec<Update>, Self::Err> {
        Ok(vec![])
    }

    /// Return new components for a subgradient.
    ///
    /// The components are typically generated by some primal
    /// information. The corresponding primal is passed as a







|







174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
        let mut primals = primals;
        primals.pop().unwrap().1
    }

    /// Return updates of the problem.
    ///
    /// The default implementation returns no updates.
    fn update(&mut self, _state: &UpdateState<Self::Primal>) -> Result<Vec<Update<Self::Primal>>, Self::Err> {
        Ok(vec![])
    }

    /// Return new components for a subgradient.
    ///
    /// The components are typically generated by some primal
    /// information. The corresponding primal is passed as a
Changes to src/solver.rs.
675
676
677
678
679
680
681

682
683
684
685
686
687
688
                    }
                    let (lower, upper) = self.bounds[index];
                    if value < lower || value > upper {
                        return Err(SolverError::ViolatedBounds { lower, upper, value });
                    }
                    newvars.push((Some(index), lower - value, upper - value, value));
                }

            }
        }

        if !newvars.is_empty() {
            let problem = &mut self.problem;
            let minorants = &self.minorants;
            self.master







>







675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
                    }
                    let (lower, upper) = self.bounds[index];
                    if value < lower || value > upper {
                        return Err(SolverError::ViolatedBounds { lower, upper, value });
                    }
                    newvars.push((Some(index), lower - value, upper - value, value));
                }
                Update::ModifyPrimal(_modify) => unimplemented!(),
            }
        }

        if !newvars.is_empty() {
            let problem = &mut self.problem;
            let minorants = &self.minorants;
            self.master