1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
// Copyright 2018 Stefan Kroboth // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. /// This macro generates the `run` function for every solver which implements `ArgminSolver`. #[macro_export] macro_rules! make_run { ( $ProblemDefinition:ty, $StartingPoints:ty, $Parameter:ty, $CostValue:ty ) => { fn run( &mut self, operator: &'a $ProblemDefinition, init_param: &$StartingPoints, ) -> Result<ArgminResult<$Parameter, $CostValue>> { self.init(operator, init_param)?; let mut res; loop { res = self.next_iter()?; if self.terminate() { break; } } Ok(res) } } }