Ejemplo n.º 1
0
  @SuppressWarnings("null")
  @Test
  public void flipTestBigA() {
    final int numCases = 1000000;
    System.out.println("flipTestBigA for " + numCases + " tests");
    final BitSet bs = new BitSet();
    final Random r = new Random(3333);
    int checkTime = 2;
    RoaringBitmap rb1 = new RoaringBitmap(), rb2 = null; // alternate
    // between
    // them

    for (int i = 0; i < numCases; ++i) {
      final int start = r.nextInt(65536 * 20);
      int end = r.nextInt(65536 * 20);
      if (r.nextDouble() < 0.1) end = start + r.nextInt(100);

      if ((i & 1) == 0) {
        rb2 = RoaringBitmap.flip(rb1, start, end);
        // tweak the other, catch bad sharing
        rb1.flip(r.nextInt(65536 * 20), r.nextInt(65536 * 20));
      } else {
        rb1 = RoaringBitmap.flip(rb2, start, end);
        rb2.flip(r.nextInt(65536 * 20), r.nextInt(65536 * 20));
      }

      if (start < end) bs.flip(start, end); // throws exception
      // otherwise
      // insert some more ANDs to keep things sparser
      if (r.nextDouble() < 0.2 && (i & 1) == 0) {
        final RoaringBitmap mask = new RoaringBitmap();
        final BitSet mask1 = new BitSet();
        final int startM = r.nextInt(65536 * 20);
        final int endM = startM + 100000;
        mask.flip(startM, endM);
        mask1.flip(startM, endM);
        mask.flip(0, 65536 * 20 + 100000);
        mask1.flip(0, 65536 * 20 + 100000);
        rb2.and(mask);
        bs.and(mask1);
      }

      if (i > checkTime) {
        System.out.println("check after " + i + ", card = " + rb2.getCardinality());
        final RoaringBitmap rb = (i & 1) == 0 ? rb2 : rb1;
        final boolean status = equals(bs, rb);
        Assert.assertTrue(status);
        checkTime *= 1.5;
      }
    }
  }
Ejemplo n.º 2
0
 /**
  * Called to coalesce a successor's usage into the current BB. Important: This should be called
  * before live variable analysis begins, because we don't bother merging this.in or this.born.
  */
 void absorb(Usage succ) {
   BitSet b = (BitSet) this.def.clone();
   b.flip(0, nLocals);
   b.and(succ.use);
   this.use.or(b);
   this.def.or(succ.def);
 }
Ejemplo n.º 3
0
  /**
   * Prob0 precomputation algorithm. i.e. determine the states of an STPG which, with min/max
   * probability 0, reach a state in {@code target}, while remaining in those in @{code remain}.
   * {@code min}=true gives Prob0E, {@code min}=false gives Prob0A.
   *
   * @param stpg The STPG
   * @param remain Remain in these states (optional: null means "all")
   * @param target Target states
   * @param min1 Min or max probabilities for player 1 (true=lower bound, false=upper bound)
   * @param min2 Min or max probabilities for player 2 (true=min, false=max)
   */
  public BitSet prob0(STPG stpg, BitSet remain, BitSet target, boolean min1, boolean min2) {
    int n, iters;
    BitSet u, soln, unknown;
    boolean u_done;
    long timer;

    // Start precomputation
    timer = System.currentTimeMillis();
    if (verbosity >= 1)
      mainLog.println(
          "Starting Prob0 (" + (min1 ? "min" : "max") + (min2 ? "min" : "max") + ")...");

    // Special case: no target states
    if (target.cardinality() == 0) {
      soln = new BitSet(stpg.getNumStates());
      soln.set(0, stpg.getNumStates());
      return soln;
    }

    // Initialise vectors
    n = stpg.getNumStates();
    u = new BitSet(n);
    soln = new BitSet(n);

    // Determine set of states actually need to perform computation for
    unknown = new BitSet();
    unknown.set(0, n);
    unknown.andNot(target);
    if (remain != null) unknown.and(remain);

    // Fixed point loop
    iters = 0;
    u_done = false;
    // Least fixed point - should start from 0 but we optimise by
    // starting from 'target', thus bypassing first iteration
    u.or(target);
    soln.or(target);
    while (!u_done) {
      iters++;
      // Single step of Prob0
      stpg.prob0step(unknown, u, min1, min2, soln);
      // Check termination
      u_done = soln.equals(u);
      // u = soln
      u.clear();
      u.or(soln);
    }

    // Negate
    u.flip(0, n);

    // Finished precomputation
    timer = System.currentTimeMillis() - timer;
    if (verbosity >= 1) {
      mainLog.print("Prob0 (" + (min1 ? "min" : "max") + (min2 ? "min" : "max") + ")");
      mainLog.println(" took " + iters + " iterations and " + timer / 1000.0 + " seconds.");
    }

    return u;
  }
Ejemplo n.º 4
0
 public boolean canPermutePalindrome(String s) {
   BitSet testSet = new BitSet();
   for (char c : s.toCharArray()) {
     testSet.flip(c);
   }
   return testSet.cardinality() < 2;
 }
Ejemplo n.º 5
0
  /**
   * This methods adds a constituent table with only null and other constituents. This is required
   * when a message comes with more than the available number of constituents. If wildcard
   * subscriptions are available for those, they should match. Hence need to create these empty
   * constituent tables.
   */
  private void addEmptyConstituentTable() {
    int noOfSubscriptions = subscriptionList.size();
    Map<String, BitSet> constituentTable = new HashMap<String, BitSet>();

    BitSet nullBitSet = new BitSet(noOfSubscriptions);
    BitSet otherBitSet = new BitSet(noOfSubscriptions);

    if (noOfSubscriptions > 0) {

      // Null constituent will always be true for empty constituents, hence need to flip
      nullBitSet.flip(0, noOfSubscriptions - 1);

      for (int subscriptionIndex = 0; subscriptionIndex < noOfSubscriptions; subscriptionIndex++) {
        // For 'other', if subscribers last constituent is multi level wild card then matching
        String[] allConstituent = subscriptionConstituents.get(subscriptionIndex);
        String lastConstituent = allConstituent[allConstituent.length - 1];

        if (multiLevelWildCard.equals(lastConstituent)) {
          otherBitSet.set(subscriptionIndex);
        } else {
          otherBitSet.set(subscriptionIndex, false);
        }
      }
    }

    constituentTable.put(NULL_CONSTITUENT, nullBitSet);
    constituentTable.put(OTHER_CONSTITUENT, otherBitSet);

    constituentTables.add(constituentTable);
  }
Ejemplo n.º 6
0
 public void toggleSelection(AlignedPosition p) {
   selection.flip(p.getPos1());
   // System.out.println("AligPanel: toggle selection " + p.getPos1() + " " +
   // selection.get(p.getPos1()));
   updateJmolDisplay();
   this.repaint();
 }
Ejemplo n.º 7
0
 /**
  * Initialise a CTMain before usage with a first tree, going through and setting up the hash table
  * etc.
  *
  * @param root Root of the initial tree to initialise with
  * @param noOfSamples Current number of samples taken
  */
 public void initialize(TreeNode root, int noOfSamples) {
   // Parameter initialisation
   this.noOfSamples = noOfSamples;
   noOfTrees = 0;
   // TaxaMap initialisation
   List<TreeNode> leaves = root.getLeaves();
   noOfTaxa = leaves.size();
   // Hash initialisation
   hashUtils = new HashUtils();
   hashUtils.initialize(noOfTaxa, noOfSamples, C, seed);
   hashTable = new HashTable(hashUtils.m1);
   // Taxamap initialisation
   taxa = new TaxaMap(noOfTaxa);
   for (int i = 0; i < leaves.size(); i++) {
     taxa.put(leaves.get(i).name, i);
   }
   leafEdgeLengths = new double[noOfTaxa];
   // Adds a single star partition, once and for all.
   BitSet star = new BitSet(noOfTaxa);
   star.flip(0, noOfTaxa);
   HashEntry entry = new HashEntry(-1, star, 0.0d);
   entry.count = noOfSamples + 1;
   partitions.add(entry);
   // Majority threshold initialisation
   updateInterestThreshold();
 }
Ejemplo n.º 8
0
 public void restoreOriginal() {
   isUpdate = false;
   isDelete = false;
   isInsert = false;
   mask.flip(0, columnData.length);
   columnData = originalColumnData.clone();
 }
Ejemplo n.º 9
0
 /**
  * This is the standard liveness calculation (Dragon Book, section 10.6). At each BB (and its
  * corresponding usage), we evaluate "in" using use and def. in = use U (out \ def) where out = U
  * succ.in, for all successors
  *
  * <p>this algorithm has been modified to treat catch blocks as occurring anywhere ie, that vars
  * defined in a try may never be set however, this only applies to vars that have been defined at
  * least once (ie, born)
  */
 public boolean evalLiveIn(ArrayList<Usage> succUsage, ArrayList<Handler> handUsage) {
   BitSet out = new BitSet(nLocals);
   BitSet old_in = (BitSet) in.clone();
   if (handUsage == null) handUsage = new ArrayList();
   if (succUsage.size() == 0) {
     in = use;
   } else {
     // calculate out = U succ.in
     out = (BitSet) succUsage.get(0).in.clone();
     for (int i = 1; i < succUsage.size(); i++) {
       out.or(succUsage.get(i).in);
     }
     // calc out \ def == out & ~def == ~(out | def)
     // unless a var has been def'd in all catch blocks, assume it may fail to def
     BitSet def1 = (BitSet) def.clone();
     for (Handler handle : handUsage) def1.and(handle.catchBB.usage.def);
     def1.flip(0, nLocals);
     out.and(def1);
     for (Handler handler : handUsage) out.or(handler.catchBB.usage.use);
     // catch block vars may be def'd in this block, but we can't easily know if the
     // def has occurred before the throw
     // if the var has never been def'd (or was a parameter), then it can't be live
     out.and(born);
     out.or(use);
     in = out;
   }
   return !(in.equals(old_in));
 }
Ejemplo n.º 10
0
 public boolean canPermutePalindromeBitSet(String s) {
   char[] chs = s.toCharArray();
   BitSet bs = new BitSet();
   for (char c : chs) {
     bs.flip(c);
   }
   return bs.cardinality() <= 1;
 }
Ejemplo n.º 11
0
  public int selectBestBlockForDownload(Friend remoteFriend) throws IOException {
    if (T.t) {
      T.debug("Selecting best block for download. Remote: " + remoteFriend);
    }
    BlockMask bm = blockMasks.get(remoteFriend.getGuid());
    if (bm == null) {
      if (T.t) {
        T.info("Ehh. Don't know anything about this friends block mask. Can't download.");
      }
      return -1;
    }

    BitSet interestingBlocks = getInterestingBlocks(bm);

    // remove bocks in progress from interesting blocks:
    BlockFile bf = storage.getBlockFile(root);
    BitSet blocksInProgress = bf == null ? new BitSet() : bf.getBlocksInProgress();
    blocksInProgress.flip(0, fd.getNumberOfBlocks());
    blocksInProgress.and(interestingBlocks);

    if (blocksInProgress.cardinality() > 0) {
      // there are blocks of interest that are NOT in progress. Take one of these
      interestingBlocks = blocksInProgress;
    } // else there are only blocks in progress. Use any of them

    int highestBlockNumber = 0;
    if (bf != null) {
      highestBlockNumber = bf.getHighestCompleteBlock();
    }
    highestBlockNumber += manager.getCore().getSettings().getInternal().getMaxfileexpandinblocks();
    // we prefer to load blocks below highestBlockNumber
    if (interestingBlocks.nextSetBit(0) < highestBlockNumber) {
      // we're good - there are interesting blocks below the highest block number.

      // remove all blocks above highest block number:
      if (highestBlockNumber + 1 < fd.getNumberOfBlocks()) {
        interestingBlocks.clear(highestBlockNumber + 1, fd.getNumberOfBlocks());
      }
    }

    // select a random block of the ones we're interested in - change this to rarest first in the
    // future
    int c = interestingBlocks.cardinality();
    int n = (int) (Math.random() * c);
    for (int i = interestingBlocks.nextSetBit(0), j = 0;
        i >= 0;
        i = interestingBlocks.nextSetBit(i + 1), j++) {
      if (j == n) {
        return i;
      }
    }

    if (T.t) {
      T.trace("Can't find any block to download from " + remoteFriend);
    }
    return -1;
  }
Ejemplo n.º 12
0
 /** Change this SprayPattern to be (!this), flipping every bit. */
 public SprayPattern not() {
   if (is(false)) set(true);
   else if (is(true)) set(false);
   else {
     array.flip(0, size);
     ones = size - ones;
   }
   return this; // Return a pointer to this SprayPattern object so you can call this method in a
                // chain
 }
Ejemplo n.º 13
0
  @Test
  public void flipTestBig() {
    final int numCases = 1000000;
    System.out.println("flipTestBig for " + numCases + " tests");
    final RoaringBitmap rb = new RoaringBitmap();
    final BitSet bs = new BitSet();
    final Random r = new Random(3333);
    int checkTime = 2;

    for (int i = 0; i < numCases; ++i) {
      final int start = r.nextInt(65536 * 20);
      int end = r.nextInt(65536 * 20);
      if (r.nextDouble() < 0.1) end = start + r.nextInt(100);
      rb.flip(start, end);
      if (start < end) bs.flip(start, end); // throws exception
      // otherwise
      // insert some more ANDs to keep things sparser
      if (r.nextDouble() < 0.2) {
        final RoaringBitmap mask = new RoaringBitmap();
        final BitSet mask1 = new BitSet();
        final int startM = r.nextInt(65536 * 20);
        final int endM = startM + 100000;
        mask.flip(startM, endM);
        mask1.flip(startM, endM);
        mask.flip(0, 65536 * 20 + 100000);
        mask1.flip(0, 65536 * 20 + 100000);
        rb.and(mask);
        bs.and(mask1);
      }
      // see if we can detect incorrectly shared containers
      if (r.nextDouble() < 0.1) {
        final RoaringBitmap irrelevant = RoaringBitmap.flip(rb, 10, 100000);
        irrelevant.flip(5, 200000);
        irrelevant.flip(190000, 260000);
      }
      if (i > checkTime) {
        System.out.println("check after " + i + ", card = " + rb.getCardinality());
        Assert.assertTrue(equals(bs, rb));
        checkTime *= 1.5;
      }
    }
  }
Ejemplo n.º 14
0
 /** Hydra task to execution ops, then stop scheduling. */
 public static void HydraTask_doOps() {
   BitSet availableOps = new BitSet(operations.length);
   availableOps.flip(FIRST_OP, LAST_OP + 1);
   // don't do local ops in bridge configuration
   availableOps.clear(LOCAL_INVALIDATE);
   availableOps.clear(LOCAL_DESTROY);
   testInstance.doOps(availableOps);
   if (availableOps.cardinality() == 0) {
     CQUtilBB.getBB().getSharedCounters().increment(CQUtilBB.TimeToStop);
     throw new StopSchedulingTaskOnClientOrder("Finished with ops");
   }
 }
Ejemplo n.º 15
0
  private void selectEQR() {

    selection.clear();

    List<Integer> pos1 = DisplayAFP.getEQRAlignmentPos(afpChain);

    for (int pos : pos1) {
      selection.flip(pos);
    }
    mouseMoLi.triggerSelectionLocked(true);
    updateJmolDisplay();
    this.repaint();
  }
Ejemplo n.º 16
0
 private BitSet getInterestingBlocks(BlockMask remote) throws IOException {
   if (T.t) {
     T.ass(fd != null, "Need a FD for this call to work");
   }
   BitSet interestingBlocks = new BitSet();
   BlockMask myBm = manager.getCore().getFileManager().getBlockMask(fd.getRootHash());
   if (myBm != null) {
     interestingBlocks.or(myBm);
   }
   interestingBlocks.flip(0, fd.getNumberOfBlocks());
   interestingBlocks.and(remote);
   return interestingBlocks;
 }
 /** flip exactly one bit */
 private List<Integer> mutateIndividual(List<Integer> individual, Random random) {
   List<Integer> mutated = new ArrayList<Integer>();
   mutated.addAll(individual);
   int mutationIndex = r.nextInt(individual.size());
   int mutationBit =
       r.nextInt(6); // integers value is 0 to 100. 100 is represented with a max of 6 bits
   BitSet bs = toBitSet(individual.get(mutationIndex));
   bs.flip(mutationBit);
   int mutatedInt = toInt(bs);
   if (mutatedInt > 100) mutatedInt = 100;
   if (mutatedInt < 0) mutatedInt = 0;
   mutated.set(mutationIndex, mutatedInt);
   return mutated;
 }
Ejemplo n.º 18
0
  BitSet singleBitDiff(BitSet x, BitSet y) {
    BitSet t = new BitSet(x.length());
    t.or(x);
    t.flip(0, t.size());
    t.and(y);

    switch (t.cardinality()) {
      case 0:
        return t;
      case 1:
        return t;
      default:
        return new BitSet();
    }
  }
Ejemplo n.º 19
0
 public List<TOE> next() {
   List<TOE> ret = new LinkedList<TOE>();
   for (int i = 0; i < N; i++)
     for (int j = 0; j < M; j++)
     // if(G.get(i*M+j))
     {
       BitSet Gnew = (BitSet) (G.clone());
       int[] x = {0, 1, -1, 0, 0};
       int[] y = {0, 0, 0, 1, -1};
       for (int k = 0; k < 5; k++) {
         int xi = x[k];
         int yi = y[k];
         if ((i + xi) >= 0 && (i + xi) < N && (j + yi) >= 0 && (j + yi) < M) {
           Gnew.flip((i + xi) * M + (j + yi));
         }
       }
       TOE to = new TOE(N, M, Gnew);
       to.mx = i;
       to.my = j;
       ret.add(to);
     }
   return ret;
 }
Ejemplo n.º 20
0
  public static int maximumGap2(int[] nums) {
    if (nums == null || nums.length == 0 || nums.length == 1) return 0;

    int max = 0;
    for (int i = 0; i < nums.length; i++) if (nums[i] > max) max = nums[i];

    BitSet bitSet = new BitSet(max + 1);
    for (int i = 0; i < nums.length; i++) {
      bitSet.flip(nums[i]);
      if (nums[i] > max) max = nums[i];
    }

    int maxGap = 0;
    int currentGap = 0;
    for (int i = 0; i < max + 1; i++)
      if (bitSet.get(i)) {
        if (maxGap < currentGap) maxGap = currentGap;
        currentGap = 0;

      } else currentGap++;

    return maxGap;
  }
Ejemplo n.º 21
0
  /**
   * FOR TESTING ONLY Function called to initialise the Network Tester hash table & rest of CTMain
   *
   * @param noOfTestTaxa Number of taxa
   * @param noOfTestSamples number of trees input
   */
  public void InitialiseNetworkTester(int noOfTestTaxa, int noOfTestSamples) {
    // TaxaMap initialisation
    noOfTrees = 0;
    noOfTaxa = noOfTestTaxa;
    noOfSamples = noOfTestSamples;
    // Hash initialisation
    hashUtils = new HashUtils();
    hashUtils.initialize(noOfTaxa, noOfSamples, C, seed);
    hashTable = new HashTable(hashUtils.m1);
    leafEdgeLengths = new double[noOfTaxa];
    taxa = new TaxaMap(noOfTaxa);
    for (int i = 0; i < noOfTaxa; i++) {
      taxa.put("" + i, i);
      leafEdgeLengths[i] = 1;
    }

    // Adds a single star partition, once and for all.
    BitSet star = new BitSet(noOfTaxa);
    star.flip(0, noOfTaxa);
    HashEntry entry = new HashEntry(-1, star, 0.0d);
    entry.count = noOfSamples + 1;
    partitions.add(entry);
    updateInterestThreshold();
  }
Ejemplo n.º 22
0
 /* (non-Javadoc)
  * @see java.util.BitSet#flip(int)
  */
 public void flip(int bitIndex) {
   super.flip(bitIndex);
   makeDirty();
 }
Ejemplo n.º 23
0
 /* (non-Javadoc)
  * @see java.util.BitSet#flip(int, int)
  */
 public void flip(int fromIndex, int toIndex) {
   super.flip(fromIndex, toIndex);
   makeDirty();
 }
Ejemplo n.º 24
0
 @Override
 public BitSet solveSet(Assignment val) {
   BitSet bs = c1.solveSet(val);
   bs.flip(0, this.size);
   return bs;
 }
Ejemplo n.º 25
0
 public void undoUpdate() {
   isUpdate = false;
   mask.flip(0, columnData.length);
   columnData = originalColumnData.clone();
 }
Ejemplo n.º 26
0
 @Override
 public void not() {
   bits.flip(0, vectorSize - 1);
 }
Ejemplo n.º 27
0
 public void flip(int bitIndex) {
   checkIndex(bitIndex);
   flip(array, bitIndex);
 }
Ejemplo n.º 28
0
  /** {@inheritDoc} */
  @Override
  public Set<AndesSubscription> getMatchingSubscriptions(
      String destination, DestinationType destinationType) {
    Set<AndesSubscription> subscriptions = new HashSet<>();

    if (StringUtils.isNotEmpty(destination)) {

      // constituentDelimiter is quoted to avoid making the delimiter a regex symbol
      String[] constituents = destination.split(Pattern.quote(constituentsDelimiter), -1);

      int noOfCurrentMaxConstituents = constituentTables.size();

      // If given destination has more constituents than any subscriber has, then create constituent
      // tables
      // for those before collecting matching subscribers
      if (constituents.length > noOfCurrentMaxConstituents) {
        for (int i = noOfCurrentMaxConstituents; i < constituents.length; i++) {
          addEmptyConstituentTable();
        }
      }

      // Keeps the results of 'AND' operations between each bit sets
      BitSet andBitSet = new BitSet(subscriptionList.size());

      // Since BitSet is initialized with false for each element we need to flip
      andBitSet.flip(0, subscriptionList.size());

      // Get corresponding bit set for each constituent in the destination and operate bitwise AND
      // operation
      for (int constituentIndex = 0; constituentIndex < constituents.length; constituentIndex++) {
        String constituent = constituents[constituentIndex];
        Map<String, BitSet> constituentTable = constituentTables.get(constituentIndex);

        BitSet bitSetForAnd = constituentTable.get(constituent);

        if (null == bitSetForAnd) {
          // The constituent is not found in the table, hence matching with 'other' constituent
          bitSetForAnd = constituentTable.get(OTHER_CONSTITUENT);
        }

        andBitSet.and(bitSetForAnd);
      }

      // If there are more constituent tables, get the null constituent in each of them and operate
      // bitwise AND
      for (int constituentIndex = constituents.length;
          constituentIndex < constituentTables.size();
          constituentIndex++) {
        Map<String, BitSet> constituentTable = constituentTables.get(constituentIndex);
        andBitSet.and(constituentTable.get(NULL_CONSTITUENT));
      }

      // Valid subscriptions are filtered, need to pick from subscription pool
      int nextSetBitIndex = andBitSet.nextSetBit(0);
      while (nextSetBitIndex > -1) {
        subscriptions.add(subscriptionList.get(nextSetBitIndex));
        nextSetBitIndex = andBitSet.nextSetBit(nextSetBitIndex + 1);
      }

    } else {
      log.warn(
          "Cannot retrieve subscriptions via bitmap handler since destination to match is empty");
    }

    return subscriptions;
  }
Ejemplo n.º 29
0
  /**
   * Compute expected reachability rewards. i.e. compute the min/max reward accumulated to reach a
   * state in {@code target}.
   *
   * @param stpg The STPG
   * @param rewards The rewards
   * @param target Target states
   * @param min1 Min or max rewards for player 1 (true=min, false=max)
   * @param min2 Min or max rewards for player 2 (true=min, false=max)
   * @param init Optionally, an initial solution vector (may be overwritten)
   * @param known Optionally, a set of states for which the exact answer is known Note: if 'known'
   *     is specified (i.e. is non-null, 'init' must also be given and is used for the exact values.
   */
  public ModelCheckerResult computeReachRewards(
      STPG stpg,
      STPGRewards rewards,
      BitSet target,
      boolean min1,
      boolean min2,
      double init[],
      BitSet known)
      throws PrismException {
    ModelCheckerResult res = null;
    BitSet inf;
    int i, n, numTarget, numInf;
    long timer, timerProb1;

    // Start expected reachability
    timer = System.currentTimeMillis();
    if (verbosity >= 1) mainLog.println("\nStarting expected reachability...");

    // Check for deadlocks in non-target state (because breaks e.g. prob1)
    stpg.checkForDeadlocks(target);

    // Store num states
    n = stpg.getNumStates();

    // Optimise by enlarging target set (if more info is available)
    if (init != null && known != null) {
      BitSet targetNew = new BitSet(n);
      for (i = 0; i < n; i++) {
        targetNew.set(i, target.get(i) || (known.get(i) && init[i] == 0.0));
      }
      target = targetNew;
    }

    // Precomputation (not optional)
    timerProb1 = System.currentTimeMillis();
    inf = prob1(stpg, null, target, !min1, !min2);
    inf.flip(0, n);
    timerProb1 = System.currentTimeMillis() - timerProb1;

    // Print results of precomputation
    numTarget = target.cardinality();
    numInf = inf.cardinality();
    if (verbosity >= 1)
      mainLog.println(
          "target=" + numTarget + ", inf=" + numInf + ", rest=" + (n - (numTarget + numInf)));

    // Compute rewards
    switch (solnMethod) {
      case VALUE_ITERATION:
        res = computeReachRewardsValIter(stpg, rewards, target, inf, min1, min2, init, known);
        break;
      default:
        throw new PrismException("Unknown STPG solution method " + solnMethod);
    }

    // Finished expected reachability
    timer = System.currentTimeMillis() - timer;
    if (verbosity >= 1)
      mainLog.println("Expected reachability took " + timer / 1000.0 + " seconds.");

    // Update time taken
    res.timeTaken = timer / 1000.0;
    res.timePre = timerProb1 / 1000.0;

    return res;
  }
Ejemplo n.º 30
0
 static {
   RELEVANT.flip(0);
   INTERIOR.flip(1);
 }