Package itc

Examples of itc.Stamp


    out.write("# Ration Loss: " + ratio_loss + "\n");
    out.write("# Test Number: " + number_test + "\n");

    // ITC mechanism
    Bag<Stamp> bag = new Bag<Stamp>();
    Stamp seed = new Stamp();
    bag.push(seed);

    int i, j;


    //create working ids
    int nRepReal_square = (int) (Math.log(nRepReal) / Math.log(2));
//    System.out.println("fake1:"+nRepReal_square+ " de:"+nRepReal);
    for (i = 0; i < nRepReal_square; i++) {

      ArrayList<Stamp> temp = new ArrayList<Stamp>();

//    System.out.println("fake:"+i+" not:"+bag.getList().size());
      for (j = 0; j < (Math.pow(2, i)); j++) {
        Stamp s = bag.pop();
        Stamp s2 = s.fork();
        temp.add(s);
        temp.add(s2);
      }

      for (Stamp ss : temp) {
        bag.push(ss);
      }
//
//      //size
//      int size = 0;
//      int size_for_one = 0;
//      for(Stamp st : bag.getList()) {
//        size += st.sizeInBytes();
//      }
//      size_for_one = (int)(size/nRepReal);
//
//      //printing
//      if(i%5000==0) {
//        System.out.println("It "+i+" - nRep "+bag.getSize()+" - sizeBytes T: "+size+" A:"+size_for_one);
//      }
//      out.write(i+"\t"+size_for_one+"\n");
    }

    int nRep_div = (int) nRep / nRepReal;


    int nRep_div_square = (int) (Math.log(nRep_div) / Math.log(2));

    //create remaining ids
    Stamp worker;
    Bag<Stamp> bag_not_work = new Bag<Stamp>();
    Bag<Stamp> bag_work = new Bag<Stamp>();

    for (Stamp sss : bag.getList()) {
      worker = sss;
      Bag<Stamp> bag_work2 = new Bag<Stamp>();
//      bag_work2.push(worker);

      for (i = 0; i < nRep_div_square; i++) {

        ArrayList<Stamp> temp = new ArrayList<Stamp>();

        boolean first = true;
        for (j = 0; j < (Math.pow(2, i)); j++) {
          Stamp s, s2;
          if (first) {
            first = false;
            s2 = worker.fork();
            temp.add(s2);
          } else {
            s = bag_work2.pop();
            s2 = s.fork();
            temp.add(s);
            temp.add(s2);
          }
        }

        for (Stamp ss : temp) {
          bag_work2.push(ss);
        }
      }

      for (Stamp sss2 : bag_work2.getList()) {
        bag_not_work.push(sss2);
      }
//      bag_work.push(worker);
    }
    bag_work = bag;


    System.out.println("\nATenTION!!!\n\tNOT WORKING:" + bag_not_work.getList().size() + "\n\tWORKING:" + bag_work.getList().size());

    for (; i < nIter; i++) {
      Stamp s;
      Stamp s2;


      //event
      s = bag_work.pop();
      s.event();
View Full Code Here


    out.write("# Ration Loss: " + ratio_loss + "\n");
    out.write("# Test Number: " + number_test + "\n");

    // ITC mechanism
    Bag<Stamp> bag = new Bag<Stamp>();
    Stamp seed = new Stamp();
    bag.push(seed);

    Dice dice = new Dice();
    int i, j;

    for (i = 0; i < nRep - 1; i++) {

      //fork
      Stamp s = bag.pop();
      Stamp s2 = s.fork();
      bag.push(s);
      bag.push(s2);

      //size
      float size = 0.0f;
      float size_for_one = 0.0f;
      for (Stamp st : bag.getList()) {
        size += st.sizeInBytes();
      }
      size_for_one = (size / nRep);

      //printing
      if (i % 5000 == 0) {
        System.out.println("It " + i + " - nRep " + bag.getSize() + " - sizeBytes T: " + size + " A:" + size_for_one);
      }
      out.write(i + "\t" + size_for_one + "\n");
    }

    for (; i < nIter; i++) {
      Stamp s;
      Stamp s2;

      //fork
      int sizeBag = bag.getSize();
      int nForks = (nRep + 1) - sizeBag;
//      System.out.println("nForks "+nForks);
View Full Code Here

  public void testITC_process_causality(int nRep, int nIter, float ratio_events, float ratio) {

    // ITC mechanism
    Bag<Stamp> bag = new Bag<Stamp>();
    Stamp seed = new Stamp();
    bag.push(seed);

    int i, j;

    int nEvents = (int) (nRep * ratio_events);

    for (i = 0; i < nRep - 1; i++) {
      //fork
      Stamp s = bag.pop();
      Stamp s2 = s.fork();
      bag.push(s);
      bag.push(s2);

      //size
      float size = 0.0f;
      for (Stamp st : bag.getList()) {
        size += st.sizeInBytes();
      }

      //printing
      System.out.println("It " + i + " - nRep " + bag.getSize() + " - sizeBytes T: " + size + " A:" + (size / nRep));
    }

    for (i = 0; i < nIter; i++) {
      //peek
      Stamp s = bag.pop();
      Stamp s2 = bag.pop();
      Stamp peek = s.peek();
      s2.join(peek);
      bag.push(s);
      bag.push(s2);

      //events
View Full Code Here

        ene[j] = (byte) in.read();
      }
      long len = (long) ByteInt.byteArrayToInt(ene);

      for (int j = 0; j < len; j++) {
        Stamp s = new Stamp();
        s.loadFromFile(in);
//        System.out.println("in" + s.toString());
        this.push((T) s);
      }

    } catch (Exception ex) {
View Full Code Here

    saco.push(seed);

    // ITC mechanism
    Bag<Stamp> bag = new Bag<Stamp>();

    Stamp seedb = new Stamp();
    bag.push(seedb);

    int forks = 0;
    int joins = 0;
    int events = 0;

    int i;
    int counter = 0;
    for (i = 0; i < 1500; i++) {
      System.out.println(i + 1 + ": bugs->" +counter);
      int tipo = dado.iroll(1, 100);

      if (tipo <= 34 || saco.getSize() == 1) { // fork
        System.out.println("Fork __________________________");
        forks++;
        int ind = saco.getValidIndice();

        // mecanismo hc
        CStamp out = (CStamp) saco.popInd(ind);
        CStamp novo = new CStamp();
        novo = out.fork();

        saco.push(out);
        saco.push(novo);

        // mecanismo itc in place
        Stamp sout = (Stamp) bag.popInd(ind);
        Stamp sin = sout.fork();

        bag.push(sout);
        bag.push(sin);

//        // mecanismo itc funcional
//        Stamp outb = (Stamp) bag.popInd(ind);
//        Stamp[] p = Stamp.fork(outb);
//        Stamp in1 = p[0];
//        Stamp in2 = p[1];
//
//        bag.push(in1);
//        bag.push(in2);
      } else if (tipo <= 66) { // join
        System.out.println("Join __________________________");
        joins++;
        int inda = saco.getValidIndice();

        CStamp outa = (CStamp) saco.popInd(inda);
        Stamp souta = (Stamp) bag.popInd(inda);

        int indb = saco.getValidIndice();

        CStamp outb = (CStamp) saco.popInd(indb);
        Stamp soutb = (Stamp) bag.popInd(indb);

        CStamp novo = new CStamp();
        novo.join(outa, outb);
        saco.push(novo);

//        Stamp novob = Stamp.join(souta, soutb);
//        bag.push(novob);
        souta.join(soutb);
        bag.push(souta);
      } else { // event
        System.out.println("Event _________________________");
        events++;
        int ind = saco.getValidIndice();

        CStamp out = (CStamp) saco.popInd(ind);
        out.event(gen.gera());
        saco.push(out);

        Stamp outb = (Stamp) bag.popInd(ind);
//        System.out.println("ANTES:"+outb.toString());
        outb.event();
//        System.out.println("DPS:"+outb.toString());
        bag.push(outb);
      }

      CStamp tmp = new CStamp();
      tmp = (CStamp) saco.getLast();
      Stamp tmpb = new Stamp();
      tmpb = (Stamp) bag.getLast();
      int len = saco.getSize();

      for (int n = 0; n < len - 1; n++) {
        boolean a = tmp.equals((CStamp) saco.getInd(n));

        Stamp decd = new Stamp();
        char[] coise = bag.getInd(n).Encode();
        decd.Decode(coise);
//        decd.dDecode(bag.getInd(n).dEncode());
        boolean b = tmpb.equals(decd);
//        boolean b = tmpb.equals((Stamp) bag.getInd(n));
        if (!((a && b) || (!a && !b))) {
          System.out.println("Devia ser "+a+", mas e "+b+"\n\t"+tmpb.toString()+ "   E    "+decd.toString());
          counter++;
        }
      }

    }
View Full Code Here

TOP

Related Classes of itc.Stamp

Copyright © 2018 www.massapicom. 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.