fn seek_initial_interval<E>(
        &self,
        start_alpha: f64,
        compute: &mut dyn FnMut(f64, How) -> ShortCircuitResult<Bound, Bound, E>,
    ) -> ShortCircuitResult<Interval, Bound, E>
    {
        // Hager (2004) provides no strategy for this.
        // Or rather, it says that we can sample phi(alpha) for
        //   "various choices of alpha"... Harumph.

        // "Most" of our work is already done.
        // All that really remains is to locate an upper bound that is not downhill.
        let mut lo = self.initial;

        let mut cur = compute(start_alpha, How::InitialGuess)?;

        // We could handle this similar to `update_interval`,
        // except that we have no `hi` ready to be returned in the case of (U2).
        // Take care of this case straight away.
        while cur.strictly_downhill() && self.reasonable_value(cur) {
            assert!(lo.alpha < cur.alpha, "lo.alpha < cur.alpha failed:  {:e} vs {:e}", lo.alpha, cur.alpha);
            assert!(lo.strictly_downhill());
            assert!(self.reasonable_value(lo));

            // We're on an interval that appears to be entirely downhill.
            // Travel down along the line until something happens.
            //
            // Pick a point at least twice as far from lo.alpha as cur.alpha is.
            //  (the parameter is >= 1.0 so the linterp argument is >= 2.0)
            let next_alpha = linterp(1.0 + self.params.expansion_growth_factor, (lo.alpha, cur.alpha));
            lo = cur;
            cur = compute(next_alpha, How::SameSlopeExpand)?;
        }

        // the rest plays out like 'update_interval'
        let out = match (cur.strictly_downhill(), self.reasonable_value(cur)) {
            (false, _) => (lo, cur),
            (true, true) => unreachable!(), // taken care of by above loop
            (true, false) => match self.funky_loop_in_u3((lo, cur), compute)? {
                Ok(ivl) => ivl,
                Err(_) => {
                    // so... we COULD try to find another interval to search,
                    // but honestly, this should hardly come up in real problems.

                    // Give up, but do it quite vocally.
                    warn!("Unable to find an initial interval.");
                    return Err(Ok(self.initial));
                }
            },
        };
        self.validate_opposite_slope(out);
        Ok(out)
    }
/// This locates an initial interval that satisfies the opposite slope condition.
This locates an initial interval that satisfies the opposite slope condition.
This locates an initial interval that satisfies the opposite slope condition .
fn seek_initial_interval<E>(
        &self,
        start_alpha: f64,
        compute: &mut dyn FnMut(f64, How) -> ShortCircuitResult<Bound, Bound, E>,
    ) -> ShortCircuitResult<Interval, Bound, E>
    {
        // Hager (2004) provides no strategy for this.
        // Or rather, it says that we can sample phi(alpha) for
        //   "various choices of alpha"... Harumph.
        // "Most" of our work is already done.
        // All that really remains is to locate an upper bound that is not downhill.
        let mut lo = self.initial;
        let mut cur = compute(start_alpha, How::InitialGuess)?;
        // We could handle this similar to `update_interval`,
        // except that we have no `hi` ready to be returned in the case of (U2).
        // Take care of this case straight away.
        while cur.strictly_downhill() && self.reasonable_value(cur) {
            assert!(lo.alpha < cur.alpha, "lo.alpha < cur.alpha failed:  {:e} vs {:e}", lo.alpha, cur.alpha);
            assert!(lo.strictly_downhill());
            assert!(self.reasonable_value(lo));
            // We're on an interval that appears to be entirely downhill.
            // Travel down along the line until something happens.
            //
            // Pick a point at least twice as far from lo.alpha as cur.alpha is.
            //  (the parameter is >= 1.0 so the linterp argument is >= 2.0)
            let next_alpha = linterp(1.0 + self.params.expansion_growth_factor, (lo.alpha, cur.alpha));
            lo = cur;
            cur = compute(next_alpha, How::SameSlopeExpand)?;
        }
        // the rest plays out like 'update_interval'
        let out = match (cur.strictly_downhill(), self.reasonable_value(cur)) {
            (false, _) => (lo, cur),
            (true, true) => unreachable!(), // taken care of by above loop
            (true, false) => match self.funky_loop_in_u3((lo, cur), compute)? {
                Ok(ivl) => ivl,
                Err(_) => {
                    // so... we COULD try to find another interval to search,
                    // but honestly, this should hardly come up in real problems.
                    // Give up, but do it quite vocally.
                    warn!("Unable to find an initial interval.");
                    return Err(Ok(self.initial));
                }
            },
        };
        self.validate_opposite_slope(out);
        Ok(out)
    }
fn seek_initial_interval < E > ( & self , start_alpha : f64 , compute : & mut dyn FnMut ( f64 , How ) -> ShortCircuitResult < Bound , Bound , E > , ) -> ShortCircuitResult < Interval , Bound , E > { // Hager (2004) provides no strategy for this. // Or rather, it says that we can sample phi(alpha) for //   "various choices of alpha"... Harumph. // "Most" of our work is already done. // All that really remains is to locate an upper bound that is not downhill. let mut lo = self . initial ; let mut cur = compute ( start_alpha , How :: InitialGuess ) ? ; // We could handle this similar to `update_interval`, // except that we have no `hi` ready to be returned in the case of (U2). // Take care of this case straight away. while cur . strictly_downhill ( ) && self . reasonable_value ( cur ) { assert ! ( lo alpha cur alpha " " lo alpha cur alpha ) ; assert ! ( lo strictly_downhill ( ) ) ; assert ! ( self reasonable_value ( lo ) ) ; // We're on an interval that appears to be entirely downhill. // Travel down along the line until something happens. // // Pick a point at least twice as far from lo.alpha as cur.alpha is. //  (the parameter is >= 1.0 so the linterp argument is >= 2.0) let next_alpha = linterp ( 1.0 + self . params . expansion_growth_factor , ( lo . alpha , cur . alpha ) ) ; lo = cur ; cur = compute ( next_alpha , How :: SameSlopeExpand ) ? ; } // the rest plays out like 'update_interval' let out = match ( cur . strictly_downhill ( ) , self . reasonable_value ( cur ) ) { ( false , _ ) => ( lo , cur ) , ( true , true ) => unreachable ! ( ) , // taken care of by above loop ( true , false ) => match self . funky_loop_in_u3 ( ( lo , cur ) , compute ) ? { Ok ( ivl ) => ivl , Err ( _ ) => { // so... we COULD try to find another interval to search, // but honestly, this should hardly come up in real problems. // Give up, but do it quite vocally. warn ! ( " " ) ; return Err ( Ok ( self . initial ) ) ; } } , } ; self . validate_opposite_slope ( out ) ; Ok ( out ) }
This locates an initial interval that satisfies the opposite slope condition.
This locates an initial interval that satisfies the opposite slope condition .
&self
start_alpha
f64
compute
&mut dyn FnMut(f64, How) -> ShortCircuitResult<Bound, Bound, E>
&self
start_alpha
f64
compute
&mut dyn FnMut(f64, How) -> ShortCircuitResult<Bound, Bound, E>