/// Validates that a list of thermal states are valid, meeting the criteria:
///  - State 0 has min_performance of 0.0;
///  - For any input `desired_performance`, the admissible states (states for which
///    `state.min_performance <= desired_performance`) are in order of strictly decreasing modeled
///    power.
///
/// To address the power criterion, two further definitions are necessary:
///  - Power is modeled as
///
///    ```
///      power = static_power
///              + dynamic_power_per_normperf * min(desired_performance, performance_capacity).
///    ```
///
///  - Two states are *adjacent* at `desired_performance` if and only if they are both admissible at
///    `desired_performance`, and no state between them in the full list of states is admissible.
///
/// Power is strictly decreasing if the following conditions are met:
///  - dynamic_power_per_normperf is non-increasing;
///  - performance_capacity is non-increasing;
///  - When any two states are adjacent, the lower-index state draws more power at the first
///    performance value at which they are adjacent.
///
/// The first two conditions guarantee that the power delta between a lower-index state and a
/// higher-index state is non-decreasing with respect to performance. The third condition implies
/// that the power delta between any two adjacent states is initially positive; since the delta is
/// non-decreasing by the first two conditions, it will continue to be positive for all subsequent
/// performance values.
Validates that a list of thermal states are valid, meeting the criteria:
State 0 has min_performance of 0.0;
For any input `desired_performance`, the admissible states (states for which
`state.min_performance <= desired_performance`) are in order of strictly decreasing modeled
power.

To address the power criterion, two further definitions are necessary:
Power is modeled as



Two states are *adjacent* at `desired_performance` if and only if they are both admissible at
`desired_performance`, and no state between them in the full list of states is admissible.

Power is strictly decreasing if the following conditions are met:
dynamic_power_per_normperf is non-increasing;
performance_capacity is non-increasing;
When any two states are adjacent, the lower-index state draws more power at the first
performance value at which they are adjacent.

The first two conditions guarantee that the power delta between a lower-index state and a
higher-index state is non-decreasing with respect to performance. The third condition implies
that the power delta between any two adjacent states is initially positive; since the delta is
non-decreasing by the first two conditions, it will continue to be positive for all subsequent
performance values.
Validates that a list of thermal states are valid meeting the criteria : State 0 has min_performance of 0 . 0 ; For any input ` desired_performance ` the admissible states ( states for which ` state . min_performance < = desired_performance ` ) are in order of strictly decreasing modeled power . To address the power criterion two further definitions are necessary : Power is modeled as Two states are * adjacent * at ` desired_performance ` if and only if they are both admissible at ` desired_performance ` and no state between them in the full list of states is admissible . Power is strictly decreasing if the following conditions are met : dynamic_power_per_normperf is non - increasing ; performance_capacity is non - increasing ; When any two states are adjacent the lower - index state draws more power at the first performance value at which they are adjacent . The first two conditions guarantee that the power delta between a lower - index state and a higher - index state is non - decreasing with respect to performance . The third condition implies that the power delta between any two adjacent states is initially positive ; since the delta is non - decreasing by the first two conditions it will continue to be positive for all subsequent performance values .
fn validate_thermal_states(states: &Vec<ThermalState>) -> Result<(), Error> {
    anyhow::ensure!(
        states[0].min_performance == NormPerfs(0.0),
        "State 0 ({:?}) must have min_performance == 0.0.",
        states[0]
    );
    for i in 0..states.len() - 1 {
        let state = &states[i];
        let next_state = &states[i + 1];
        anyhow::ensure!(
            next_state.dynamic_power_per_normperf <= state.dynamic_power_per_normperf,
            "Thermal states' dynamic_power_per_normperf must be non-increasing; violated by \
            {:?} and {:?}",
            state,
            next_state
        );
        anyhow::ensure!(
            next_state.performance_capacity <= state.performance_capacity,
            "Thermal states' performance_capacity must be non-increasing; violated by {:?} and \
            {:?}",
            state,
            next_state
        );
        // Compare `state` to each state further down the list that will be adjacent to it at some
        // performance value. Verify that the adjacent state has lower power at the first shared
        // performance.
        for adjacent_state in &states[i + 1..] {
            let first_shared_performance =
                FixedValue(NormPerfs::max(state.min_performance, adjacent_state.min_performance));
            let power = state.estimate_power(first_shared_performance);
            let adjacent_power = adjacent_state.estimate_power(first_shared_performance);
            anyhow::ensure!(
                adjacent_power < power,
                "Power is not strictly decreasing at performance {:?}; state {:?} consumes {:?}, \
                while state {:?} consumes {:?}.",
                first_shared_performance,
                state,
                power,
                adjacent_state,
                adjacent_power
            );
            if adjacent_state.min_performance <= state.min_performance {
                // `adjacent_state` is always between `state` and any state later in the list.
                break;
            }
        }
    }
    Ok(())
}
fn validate_thermal_states ( states : & Vec < ThermalState > ) -> Result < ( ) , Error > { anyhow :: ensure ! ( states [ 0 ] min_performance NormPerfs ( 0.0 ) " " states [ 0 ] ) ; for i in 0 .. states . len ( ) - 1 { let state = & states [ i ] ; let next_state = & states [ i + 1 ] ; anyhow :: ensure ! ( next_state dynamic_power_per_normperf state dynamic_power_per_normperf " \
 " state next_state ) ; anyhow :: ensure ! ( next_state performance_capacity state performance_capacity " \
 " state next_state ) ; // Compare `state` to each state further down the list that will be adjacent to it at some // performance value. Verify that the adjacent state has lower power at the first shared // performance. for adjacent_state in & states [ i + 1 .. ] { let first_shared_performance = FixedValue ( NormPerfs :: max ( state . min_performance , adjacent_state . min_performance ) ) ; let power = state . estimate_power ( first_shared_performance ) ; let adjacent_power = adjacent_state . estimate_power ( first_shared_performance ) ; anyhow :: ensure ! ( adjacent_power power " \
 " first_shared_performance state power adjacent_state adjacent_power ) ; if adjacent_state . min_performance <= state . min_performance { // `adjacent_state` is always between `state` and any state later in the list. break ; } } } Ok ( ( ) ) }
Validates that a list of thermal states are valid, meeting the criteria:
 State 0 has min_performance of 0.0;
 For any input `desired_performance`, the admissible states (states for which
`state.min_performance <= desired_performance`) are in order of strictly decreasing modeled
power.
Validates that a list of thermal states are valid meeting the criteria : State 0 has min_performance of 0 . 0 ; For any input ` desired_performance ` the admissible states ( states for which ` state . min_performance < = desired_performance ` ) are in order of strictly decreasing modeled power .
states
&Vec<ThermalState>