Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. struct Optimisation {
  2. objective : Box< dyn Fn(f64) -> f64 + 'static >,
  3. diff_objective : Option<Box<dyn Fn(f64) -> f64 + 'static >>
  4. }
  5.  
  6. fn main() {
  7.  
  8. let opt = Optimisation {
  9. objective: Box::new(|x: f64| -x*x),
  10. diff_objective: None
  11. };
  12.  
  13. let opt_closed_form = Optimisation {
  14. objective: Box::new(|x: f64| -x*x),
  15. diff_objective: Some(Box::new(|x| -2.0*x))
  16. };
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement