Unity-Technologies/ml-agents · error · TrainerConfigError

Minimum value is greater than maximum value in interval {int

Error message

Minimum value is greater than maximum value in interval {interval}.

What it means

After checking interval length, the same attrs validator on MultiRangeUniformSamplerSettings verifies each [min, max] pair is ordered correctly. An interval where min exceeds max is rejected because the uniform sampling range would be inverted.

Source

Thrown at ml-agents/mlagents/trainers/settings.py:438

        """
        Helper method to output sampler stats to console.
        """
        return f"MultiRangeUniform sampler: intervals={self.intervals}"

    @intervals.default
    def _intervals_default(self):
        return [[0.0, 1.0]]

    @intervals.validator
    def _check_intervals(self, attribute, value):
        for interval in self.intervals:
            if len(interval) != 2:
                raise TrainerConfigError(
                    f"The sampling interval {interval} must contain exactly two values."
                )
            min_value, max_value = interval
            if min_value > max_value:
                raise TrainerConfigError(
                    f"Minimum value is greater than maximum value in interval {interval}."
                )

    def apply(self, key: str, env_channel: EnvironmentParametersChannel) -> None:
        """
        Helper method to send sampler settings over EnvironmentParametersChannel
        Calls the multirangeuniform sampler type set method.
        :param key: environment parameter to be sampled
        :param env_channel: The EnvironmentParametersChannel to communicate sampler settings to environment
        """
        env_channel.set_multirangeuniform_sampler_parameters(
            key, self.intervals, self.seed
        )


# ENVIRONMENT PARAMETERS ###############################################################
@attr.s(auto_attribs=True)
class CompletionCriteriaSettings:

View on GitHub (pinned to 3ecb446f75)

Solutions

  1. Swap the pair so each interval is [min, max] with min <= max.
  2. Adjust endpoints so every interval is ordered ascending.
  3. Add a config pre-check asserting all(min <= max for min, max in intervals).

Example fix

# before
intervals: [[5.0, 1.0]]

# after
intervals: [[1.0, 5.0]]
Defensive patterns

Strategy: validation

Validate before calling

for lo, hi in spec['sampler_parameters']['intervals']:
    if lo > hi:
        raise ValueError(f'interval [{lo}, {hi}] has min > max')

Type guard

def intervals_are_ordered(intervals) -> bool:
    return all(lo <= hi for lo, hi in intervals)

Try / catch

try:
    sampler = MultiRangeUniformSamplerSettings(**sp)
except TrainerConfigError as e:
    print(f'Fix interval ordering: {e}')
    sp['intervals'] = [sorted(iv) for iv in sp['intervals']]

Prevention

When it happens

Trigger: Configuring intervals like [[5.0, 1.0]] in a multirangeuniform sampler — the pair parses as two values but min > max.

Common situations: Swapping endpoints while editing ranges, or merging/shrinking ranges so min crosses above max.

Related errors


AI-assisted analysis of Unity-Technologies/ml-agents@3ecb446f75 (2026-09-02). Data as JSON: /api/errors/a1030616d38e0457. Report an issue: GitHub.