Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Optimisation {
- objective : Box< dyn Fn(f64) -> f64 + 'static >,
- diff_objective : Option<Box<dyn Fn(f64) -> f64 + 'static >>
- }
- fn main() {
- let opt = Optimisation {
- objective: Box::new(|x: f64| -x*x),
- diff_objective: None
- };
- let opt_closed_form = Optimisation {
- objective: Box::new(|x: f64| -x*x),
- diff_objective: Some(Box::new(|x| -2.0*x))
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement