コード例 #1
0
  /**
   * Return the bound value for the variable.
   *
   * @param v The variable.
   * @param bset The source solution.
   * @param required <code>true</code> iff the variable must be bound.
   * @return The bound value and <code>null</code> if the variable is not bound.
   */
  @SuppressWarnings("rawtypes")
  protected static IV getIV(
      final IVariable<?> var, final IBindingSet bset, final boolean required) {

    @SuppressWarnings("unchecked")
    final IConstant<IV> constant = bset.get(var);

    if (constant == null) {

      if (required) throw new RuntimeException("Variable is not bound: " + var);

      return null;
    }

    final IV _s = (IV) constant.get();

    return _s;
  }