{"record":{"id":"a1030616d38e0457","repo":"Unity-Technologies/ml-agents","slug":"minimum-value-is-greater-than-maximum-value-in-int","errorCode":null,"errorMessage":"Minimum value is greater than maximum value in interval {interval}.","messagePattern":"Minimum value is greater than maximum value in interval (.+?)\\.","errorType":"validation","errorClass":"TrainerConfigError","httpStatus":null,"severity":"error","filePath":"ml-agents/mlagents/trainers/settings.py","lineNumber":438,"sourceCode":"        \"\"\"\n        Helper method to output sampler stats to console.\n        \"\"\"\n        return f\"MultiRangeUniform sampler: intervals={self.intervals}\"\n\n    @intervals.default\n    def _intervals_default(self):\n        return [[0.0, 1.0]]\n\n    @intervals.validator\n    def _check_intervals(self, attribute, value):\n        for interval in self.intervals:\n            if len(interval) != 2:\n                raise TrainerConfigError(\n                    f\"The sampling interval {interval} must contain exactly two values.\"\n                )\n            min_value, max_value = interval\n            if min_value > max_value:\n                raise TrainerConfigError(\n                    f\"Minimum value is greater than maximum value in interval {interval}.\"\n                )\n\n    def apply(self, key: str, env_channel: EnvironmentParametersChannel) -> None:\n        \"\"\"\n        Helper method to send sampler settings over EnvironmentParametersChannel\n        Calls the multirangeuniform sampler type set method.\n        :param key: environment parameter to be sampled\n        :param env_channel: The EnvironmentParametersChannel to communicate sampler settings to environment\n        \"\"\"\n        env_channel.set_multirangeuniform_sampler_parameters(\n            key, self.intervals, self.seed\n        )\n\n\n# ENVIRONMENT PARAMETERS ###############################################################\n@attr.s(auto_attribs=True)\nclass CompletionCriteriaSettings:","sourceCodeStart":420,"sourceCodeEnd":456,"githubUrl":"https://github.com/Unity-Technologies/ml-agents/blob/3ecb446f75d1e7400eb404c562dc005d3164cffc/ml-agents/mlagents/trainers/settings.py#L420-L456","documentation":"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.","triggerScenarios":"Configuring intervals like [[5.0, 1.0]] in a multirangeuniform sampler — the pair parses as two values but min > max.","commonSituations":"Swapping endpoints while editing ranges, or merging/shrinking ranges so min crosses above max.","solutions":["Swap the pair so each interval is [min, max] with min <= max.","Adjust endpoints so every interval is ordered ascending.","Add a config pre-check asserting all(min <= max for min, max in intervals)."],"exampleFix":"# before\nintervals: [[5.0, 1.0]]\n\n# after\nintervals: [[1.0, 5.0]]","handlingStrategy":"validation","validationCode":"for lo, hi in spec['sampler_parameters']['intervals']:\n    if lo > hi:\n        raise ValueError(f'interval [{lo}, {hi}] has min > max')","typeGuard":"def intervals_are_ordered(intervals) -> bool:\n    return all(lo <= hi for lo, hi in intervals)","tryCatchPattern":"try:\n    sampler = MultiRangeUniformSamplerSettings(**sp)\nexcept TrainerConfigError as e:\n    print(f'Fix interval ordering: {e}')\n    sp['intervals'] = [sorted(iv) for iv in sp['intervals']]","preventionTips":["Write intervals in ascending order by convention","Sort each pair in a preprocessing step","Assert ordering in a config validation test"],"tags":["config","validation","sampler","parameter-randomization"],"backgroundTag":"invalid-range","analyzedSha":"3ecb446f75d1e7400eb404c562dc005d3164cffc","analyzedAt":"2026-09-02T16:33:12.832Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}