Package ai.domain.interval

Source Code of ai.domain.interval.Utils

package ai.domain.interval;

import ai.domain.DomainException;
import ai.domain.Variable;
import ai.domain.generic.NonRelationalDomain;

public class Utils {
  public static NonRelationalDomain<Interval> updateVariableBy(NonRelationalDomain<Interval> input, Variable var,
      int delta) {
    if (input.isBottom())
      return input;
    if (!input.containsValue(var))
      throw new DomainException("Missing variable: '%s'", var);
    Interval oldValue = input.getValueFor(var);
    Interval newValue = new Interval(oldValue.getValue().add(delta));
    if (newValue.equals(oldValue))
      return input;
    return input.updateVariable(var, newValue);
  }

}
TOP

Related Classes of ai.domain.interval.Utils

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.