Exemple #1
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;
  }
Exemple #2
0
  public static DBM mat2matParam(DBM m, DBM paramCoef, Variable paramK) {

    Matrix mat = m.mat();

    Matrix paramCoefMat = (paramCoef == null) ? null : paramCoef.mat();

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

    int size = mat.size();

    FieldStaticInf fs = DeltaClosure.deltaFS();

    Matrix retMat = DBM.newMatrix(size, fs);
    retMat.init();

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

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

        Field f1 = mat.get(i, j);

        if (!f1.isFinite()) continue;

        int i_f1 = f1.toInt();
        int i_f2 = 0;
        {
          if (paramCoefMat != null) {
            Field f2 = paramCoefMat.get(i, j);
            i_f2 = f2.toInt();
          }
        }

        Field f = DeltaClosure.deltaBound(i_f1, i_f2);
        retMat.set(i, j, f);
      }
    }

    return new DBM(DBM.Encoding.DBC, retMat, fs);
  }