Пример #1
0
  public static DeltaDisjunct mat2modRels(
      DBM dbm, MyEnum keep, LinearTerm[] substitution, boolean isOctagon, IntegerInf maxK) {

    Matrix m = dbm.mat();

    LinearRel lcs = new LinearRel();

    int size = m.size();

    boolean onlyZeroK = true; // coefficients of K always 0

    for (int i = 0; i < size; ++i) {

      for (int j = 0; j < size; ++j) {

        if (i == j) continue;

        Field f = m.get(i, j);

        if (!f.isFinite()) continue;

        // skip $0-$0'<=0 and $0'-$0<=0
        if (!isOctagon && ((i == size / 2 && j == 0) || (j == size / 2 && i == 0))) continue;

        LinearConstr lc = new LinearConstr();

        lc.addLinTerm(substitution[i].times(1));
        lc.addLinTerm(substitution[j].times(-1));

        boolean zeroK = f.fillLinTerms(lc, DeltaClosure.v_k);
        onlyZeroK &= zeroK;

        lcs.add(lc);
      }
    }
    if (!onlyZeroK) {
      if (m.fs() instanceof FieldStatic.ParametricFS) lcs.addConstraint(DeltaClosure.lc_k);

      if (maxK.isFinite()) {
        lcs.add(DeltaClosure.maxKconstr(maxK.toInt()));
      }
    }

    if (DeltaClosure.DEBUG_LEVEL >= DeltaClosure.DEBUG_LOW)
      System.out.println(lcs.toSBClever(Variable.ePRINT_prime));

    if (onlyZeroK) {
      Relation r = Relation.toMinType(lcs);

      Relation[] l;
      if (!r.contradictory()) l = new Relation[] {r};
      else l = new Relation[0];
      return new DeltaDisjunct(l, lcs, onlyZeroK);
    } else {
      Relation[] tmp = null;
      tmp = lcs.existElim1(DeltaClosure.v_k);
      // else keep null
      return new DeltaDisjunct(tmp, lcs, onlyZeroK);
    }
  }
Пример #2
0
  public static LinearRel mat2LCsWithParam(
      DBM dbm, DBM dbmParamCoef, Variable param, LinearTerm[] substitution) {

    Matrix m = dbm.mat();
    Matrix paramCoef = (dbmParamCoef == null) ? null : dbmParamCoef.mat();

    if (paramCoef != null)
      if (m.size() != paramCoef.size())
        throw new RuntimeException("Operation on matrices of incompatible sizes");

    LinearRel lcs = new LinearRel();

    int size = m.size();

    for (int i = 0; i < size; ++i) {

      for (int j = 0; j < size; ++j) {

        if (i == j) continue;

        // if (!isOctagon && ( (i == size/2 && j == 0) || (j == size/2 && i == 0) ))
        //	continue;

        Field f = m.get(i, j);

        if (!f.isFinite()) continue;

        if (isZero(dbm, i) && isZero(dbm, j)) continue;

        LinearConstr lc = new LinearConstr();

        if (!isZero(dbm, i)) lc.addLinTerm(new LinearTerm(substitution[i]));
        if (!isZero(dbm, j)) lc.addLinTerm(new LinearTerm(substitution[j]));

        lc.addLinTerm(new LinearTerm(null, -f.toInt()));

        if (paramCoef != null) {
          Field f_paramCoef = paramCoef.get(i, j);
          lc.addLinTerm(new LinearTerm(param, -f_paramCoef.toInt()));
        }

        lcs.add(lc);
      }
    }

    return lcs;
  }