예제 #1
0
 // olga: use comatch after step ia done to get values of OUTPUT parameters of a rule
 String getValueOfOutputParameter(VarMember p, Rule r, OrdinaryMorphism comatch) {
   if (p != null && r != null && comatch != null) {
     Enumeration<GraphObject> rightObjs = comatch.getDomain();
     while (rightObjs.hasMoreElements()) {
       GraphObject obj = rightObjs.nextElement();
       if (obj.getAttribute() != null) {
         ValueTuple vt = (ValueTuple) obj.getAttribute();
         for (int i = 0; i < vt.getNumberOfEntries(); i++) {
           ValueMember vm = vt.getEntryAt(i);
           if (vm.isSet() && vm.getExpr().isVariable() && vm.getExprAsText().equals(p.getName())) {
             // we found an object obj inside of the RHS which uses the output parameter p,
             // now we will find an appropriate graph object
             // and to get the value of the output parameter
             GraphObject go = comatch.getImage(obj);
             ValueTuple vt_go = (ValueTuple) go.getAttribute();
             ValueMember vm_go = vt_go.getEntryAt(vm.getName());
             String parVal = vm_go.getExprAsText();
             System.out.println(
                 parVal
                     + "  is value of OUTPUT parameter: --"
                     + p.getName()
                     + "--  of rule: "
                     + r.getName());
             return parVal;
           }
         }
       }
     }
   }
   return null;
 }
예제 #2
0
 void setInputParameter(Rule r) {
   VarTuple vars = (VarTuple) r.getAttrContext().getVariables();
   for (int i = 0; i < vars.getNumberOfEntries(); i++) {
     VarMember var = (VarMember) vars.getMemberAt(i);
     if (var.isInputParameter())
       System.out.println(var.getName() + "  is already input parameter of rule: " + r.getName());
     else {
       // this var should be an input parameter
       var.setInputParameter(true);
       System.out.println(var.getName() + "  is now input parameter of rule: " + r.getName());
     }
   }
 }
예제 #3
0
  // olga
  List<VarMember> getOutputParameters(Rule r, List<VarMember> list) {
    if (list == null) list = new Vector<VarMember>();
    else list.clear();

    VarTuple vars = (VarTuple) r.getAttrContext().getVariables();
    for (int i = 0; i < vars.getNumberOfEntries(); i++) {
      VarMember var = (VarMember) vars.getMemberAt(i);
      if (var.isOutputParameter()) {
        System.out.println(var.getName() + "  is OUTPUT parameter of rule: " + r.getName());
        list.add(var);
      }
      //			else {
      // if this var should be an output parameter
      //				var.setOutputParameter(true);
      //				System.out.println(var.getName()+"  is now OUTPUT parameter of rule: "+r.getName());
      //			}
    }
    return list;
  }
예제 #4
0
  void setPars(Rule r) throws IOException {
    System.out.println("\n TAKING INPUTS to APPLY Rule: " + r.getName() + "\n");
    List<String> list = r.getInputParameterNames();
    System.out.println("The parameters for " + r.getName() + " are: " + list);
    //		System.out.println("The parameters values for " + r.getName() + " are: " +
    // r.getInputParameters());
    System.out.println("The parameters values:");
    for (int i = 0; i < list.size(); i++) {
      String pname = list.get(i);
      VarMember var = (VarMember) ((VarTuple) r.getAttrContext().getVariables()).getMemberAt(pname);
      if (var.isSet()) System.out.println(pname + " is set to value: " + var.getExprAsText());
      else System.out.println(pname + " is not set");
    }

    VarTuple vars = (VarTuple) r.getAttrContext().getVariables();

    for (int i = 0; i < vars.getNumberOfEntries(); i++) {
      VarMember var = (VarMember) vars.getMemberAt(i);
      if (var.isInputParameter()) {
        // olga:
        if (!var.isSet()) {
          System.out.println(
              var.getName() + "  is already input parameter of rule: " + r.getName());

          System.out.println(
              "\n \n Please Enter the value for input parameter for rule -- "
                  + r.getName()
                  + " --, parameter name -- "
                  + var.getName()
                  + " --: ");
          Scanner scan = new Scanner(System.in);
          String value = scan.nextLine();
          System.out.println("The given input was: " + value);
          var.setInputParameter(true);
          var.setExprAsText(value);
          // in1.close();
          System.out.println(var.getName() + "  is now input parameter of rule: " + r.getName());
        } else {
          System.out.println(
              var.getExprAsText()
                  + " is value of the INPUT parameter: "
                  + var.getName()
                  + "  of rule: "
                  + r.getName());
        }
      }
    }
    // in.close();
  }
  /**
   * Computes if the first rule exclude the second rule. The result is added to the container.
   *
   * @param r1 The first rule.
   * @param r2 The second rule.
   */
  protected synchronized void computeCritical(Rule r1, Rule r2) {
    Report.trace("LayeredDependencyPairContainer: starte computeCritical", 2);
    // System.out.println("LayeredDependencyPairContainer.computeCritical(r1,
    // r2): "+r1.getName()+" "+r2.getName()+" "+this.getEntry(r1,
    // r2).state);
    // mark Entry
    if (!r1.isEnabled() || !r2.isEnabled()) { // test disabled rule
      this.getEntry(r1, r2).state = Entry.DISABLED;
      addEntry(r1, r2, false, null);
      addQuadruple(this.excludeContainer, r1, r2, false, null);
      addQuadruple(this.conflictFreeContainer, r1, r2, false, null);
      firePairEvent(
          new CriticalPairEvent(
              this,
              r1,
              r2,
              "<" + r1.getName() + ">  and  <" + r2.getName() + ">  should not be computed."));
      return;
    }

    if (r1.getLayer() != r2.getLayer()) { // test rule layer
      this.getEntry(r1, r2).state = Entry.NOT_RELATED;
      addEntry(r1, r2, false, null);
      addQuadruple(this.excludeContainer, r1, r2, false, null);
      addQuadruple(this.conflictFreeContainer, r1, r2, false, null);
      firePairEvent(new CriticalPairEvent(this, r1, r2, ""));
      return;
    }

    if ((this.layer > -1) && (r1.getLayer() != this.layer)) {
      return;
    }

    if ((this.getEntry(r1, r2).state == Entry.SCHEDULED_FOR_COMPUTING)
        || (this.getEntry(r1, r2).state == Entry.NOT_SET)) {
      getEntry(r1, r2).setState(Entry.COMPUTING_IS_RUNNING);

      firePairEvent(
          new CriticalPairEvent(
              this,
              r1,
              r2,
              "Computing critical rule pair  [  " + r1.getName() + "  ,  " + r2.getName() + "  ]"));

      if (!this.complete) {
        this.layeredPair = null;

        this.layeredSimplePair = new LayeredSimpleDependencyPair();
        this.excludePair = this.layeredSimplePair;
      } else {
        this.layeredSimplePair = null;

        this.layeredPair = new LayeredDependencyPair();
        this.excludePair = this.layeredPair;
      }

      setOptionsOfExcludePair();

      Vector<
              Pair<
                  Pair<OrdinaryMorphism, OrdinaryMorphism>,
                  Pair<OrdinaryMorphism, OrdinaryMorphism>>>
          overlapping = null;

      try {
        if (this.layeredPair != null) {
          overlapping = this.layeredPair.isCritical(CriticalPair.EXCLUDE, r1, r2);
        } else if (this.layeredSimplePair != null) {
          overlapping = this.layeredSimplePair.isCritical(CriticalPair.EXCLUDE, r1, r2);
        }
      } catch (InvalidAlgorithmException iae) {
        System.out.println(iae.getLocalizedMessage());
      }

      if (this.excludePair != null) this.excludePair.dispose();
      this.excludePair = null;
      this.layeredPair = null;
      this.layeredSimplePair = null;
      //			System.gc();

      boolean critic = (overlapping != null);

      // new container
      addEntry(r1, r2, critic, overlapping);

      /*
       * Wenn overlapping Elemente enthaelt sind r1/r2 kritisch critic
       * wird daher true. Alle wichtigen Informationen werden eingetragen.
       * Enthaelt r1/r2 keine Elementen, so wird critic auf false gesetzt.
       * Wenn excludeContainer nach r1/r2 gefragt wird, liefert die
       * Antwort auch false. overlapping kann daher null sein.
       */

      /*
       * Achtung, wenn r1 r2 nicht kritisch ist gibt es keine
       * Ueberlappungen
       */
      addQuadruple(this.excludeContainer, r1, r2, critic, overlapping);

      /*
       * conflictfree braucht keine ueberlappungsgraphen daher ist das
       * letzte Argument null
       */
      addQuadruple(this.conflictFreeContainer, r1, r2, !critic, null);

      if (overlapping != null)
        firePairEvent(
            new CriticalPairEvent(
                this,
                r1,
                r2,
                "<" + r1.getName() + ">  and  <" + r2.getName() + ">  have critical pairs"));
      else
        firePairEvent(
            new CriticalPairEvent(
                this,
                r1,
                r2,
                "<" + r1.getName() + ">  and  <" + r2.getName() + ">  have no critical pairs"));
    }
    Report.trace("LayeredDependencyPairContainer: beende computeCritical", -2);
  }