Package util.iterators

Examples of util.iterators.DisposableIntIterator



    public boolean isGraphConsistent() {
        boolean ret = true;
        for (int i = 0; i < offset; i++) {
            DisposableIntIterator iter = this.graph.layers[i].getIterator();
            while (iter.hasNext()) {
                int n = iter.next();
                DisposableIntIterator it = this.graph.GNodes.outArcs[n].getIterator();
                while (it.hasNext()) {
                    int arc = it.next();
                    int val = this.graph.GArcs.values[arc];
                    if (!vars[i].contains(val)) {
                        System.err.println("Arc " + arc + " from node " + n + " to node" + this.graph.GArcs.dests[arc] + " with value " + val + " in layer " + i + " should not be here");
                        return false;
                    }
View Full Code Here


            return false;
        }
        int[] gcost = new int[z.length];
        for (int l = 0; l < graph.layers.length - 2; l++) {
            DisposableIntIterator it = graph.layers[l].getIterator();
            while (it.hasNext()) {
                int orig = it.next();
                DisposableIntIterator arcIter = graph.GNodes.outArcs[orig].getIterator();
                while (arcIter.hasNext()) {
                    int arc = arcIter.next();
                    for (int i = 0; i < z.length; i++)
                        gcost[i] += graph.GArcs.originalCost[arc][i];
                }
                arcIter.dispose();

            }
            it.dispose();
        }
        for (int i = 0; i < gcost.length; i++) {
View Full Code Here

            int[] str = new int[vars.length];
            for (int i = 0; i < vars.length - 1; i++) {
                found = false;
                str[i] = vars[i].getValue();
                StoredIndexedBipartiteSet bs = this.graph.GNodes.outArcs[first];
                DisposableIntIterator it = bs.getIterator();
                while (!found && it.hasNext()) {
                    int idx = it.next();
                    if (this.graph.GArcs.values[idx] == vars[i].getValue()) {
                        found = true;
                        first = this.graph.GArcs.dests[idx];
                        cost += this.graph.GArcs.costs[idx];
                    }
View Full Code Here

        double zsup = this.graph.GNodes.lpfs.get(this.graph.tinkIndex);

        vars[zIdx].updateLowerBound((int) Math.ceil(zinf), aCause);
        vars[zIdx].updateUpperBound((int) Math.floor(zsup), aCause);

        DisposableIntIterator it = this.graph.inGraph.getIterator();
        //for (int id = this.graph.inGraph.nextSetBit(0) ; id >=0 ; id = this.graph.inGraph.nextSetBit(id+1))  {
        while (it.hasNext()) {
            int id = it.next();
            int orig = this.graph.GArcs.origs[id];
            int dest = this.graph.GArcs.dests[id];

            double acost = this.graph.GArcs.costs[id];

            double spfs = this.graph.GNodes.spfs.get(orig);
            double lpfs = this.graph.GNodes.lpfs.get(orig);

            double spft = this.graph.GNodes.spft.get(dest);
            double lpft = this.graph.GNodes.lpft.get(dest);


            if ((spfs + spft + acost > vars[zIdx].getUB() || lpfs + lpft + acost < vars[zIdx].getLB()) && !this.graph.isInStack(id)) {
                this.graph.setInStack(id);
                this.toRemove.push(id);
            }
        }

        it.dispose();

        try {
            do {
                while (toRemove.size() > 0) {
                    int id = toRemove.pop();
View Full Code Here

    private void filter() throws ContradictionException {

        if (boundChange.get()) {
            boundChange.set(false);
            DisposableIntIterator it = this.graph.inGraph.getIterator();
            //for (int id = this.graph.inGraph.nextSetBit(0) ; id >=0 ; id = this.graph.inGraph.nextSetBit(id+1))  {
            while (it.hasNext()) {
                int id = it.next();
                int orig = this.graph.GArcs.origs[id];
                int dest = this.graph.GArcs.dests[id];

                double acost = this.graph.GArcs.costs[id];
                double lpfs = this.graph.GNodes.lpfs.get(orig);
                double lpft = this.graph.GNodes.lpft.get(dest);

                double spfs = this.graph.GNodes.spfs.get(orig);
                double spft = this.graph.GNodes.spft.get(dest);


                if ((lpfs + lpft + acost < vars[zIdx].getLB() || spfs + spft + acost > vars[zIdx].getUB()) && !this.graph.isInStack(id)) {
                    this.graph.setInStack(id);
                    this.toRemove.push(id);
                }
            }
            it.dispose();

        }

        do {
            while (toRemove.size() > 0) {
View Full Code Here

        @Override
        public void execute(int i) throws ContradictionException {
            StoredIndexedBipartiteSet sup = p.graph.getSupport(idxVar, i);
            if (sup != null) {
                DisposableIntIterator it = sup.getIterator();
                while (it.hasNext()) {
                    int arcId = it.next();
                    if (!p.graph.isInStack(arcId)) {
                        p.graph.setInStack(arcId);
                        p.toRemove.push(arcId);
//                        mod = true;
                    }
                }
                it.dispose();
            }
        }
View Full Code Here

          stack.clear();
          throw ex;
        }
      }

      DisposableIntIterator it;
      StoredIndexedBipartiteSetWithOffset out = GNodes.outArcs[orig];
      StoredIndexedBipartiteSetWithOffset in;

      out.remove(arcId);

      if (GNodes.layers[orig] > 0 && out.isEmpty()) {
        in = GNodes.inArcs[orig];
        if (in != null) {
          it = in.getIterator();
          while (it.hasNext()) {
            int id = it.next();
            stack.push(id);
          }
          it.dispose();
        }
      }

      in = GNodes.inArcs[dest];
      in.remove(arcId);

      if (GNodes.layers[dest] < propagator.getNbVars() && in.isEmpty()) {
        out = GNodes.outArcs[dest];
        if (out != null) {
          it = out.getIterator();
          while (it.hasNext()) {
            int id = it.next();
            stack.push(id);
          }
          it.dispose();
        }

      }
    }
  }
View Full Code Here

    }
  }

  protected void clearSupports(StoredIndexedBipartiteSet supports, Propagator p) throws ContradictionException {
    if (supports != null) {
      DisposableIntIterator it = supports.getIterator();
      while (it.hasNext()) {
        int arcId = it.next();
        stack.push(arcId);
      }
      it.dispose();
      removeArc(p);
    }
  }
View Full Code Here

    }
    st.append("nb: ").append(nb).append("\n");

    for (int i = 0; i < supports.length; i++) {
      if (supports[i] != null && !supports[i].isEmpty()) {
        DisposableIntIterator it = supports[i].getIterator();
        while (it.hasNext()) {
          int arcId = it.next();
          st.append(arcId).append(",");
        }
        it.dispose();
        st.append("\n");
      }
    }
    return st.toString();
  }
View Full Code Here

            }
        }

        for (int i = 1; i <= nbLayer; i++) {
            update = false;
            DisposableIntIterator destIter = graph.layers[i].getIterator();
            while (destIter.hasNext()) {
                int dest = destIter.next();
                graph.GNodes.spfs[dest] = Double.POSITIVE_INFINITY;
                graph.GNodes.lpfs[dest] = Double.NEGATIVE_INFINITY;
                StoredIndexedBipartiteSet bs = graph.GNodes.inArcs[dest];
                assert (!bs.isEmpty());
                DisposableIntIterator in = bs.getIterator();
                while (in.hasNext()) {
                    int e = in.next();
                    if (!graph.isInStack(e)) {
                        int orig = graph.GArcs.origs[e];//.getDestination();
                        double cost = getCost(e, resource, u, lagrange, max);
                        double newCost = graph.GNodes.spfs[orig] + cost;//cost[i][graph.GArcs.values[e]];
                        if (graph.GNodes.spfs[dest] > newCost) {
                            graph.GNodes.spfs[dest] = newCost;
                            graph.GNodes.prevSP[dest] = e;
                            update = true;

                        }
                        double newCost2 = graph.GNodes.lpfs[orig] + cost;//cost[graph.GNodes.layers[n]][graph.GArcs.values[e]];

                        if (graph.GNodes.lpfs[dest] < newCost2) {
                            graph.GNodes.lpfs[dest] = newCost2;
                            graph.GNodes.prevLP[dest] = e;
                            update = true;
                        }
                    }
                }
                in.dispose();

            }
            destIter.dispose();
            if (!update) propagator.contradiction(null, "no update");
        }
        for (int i = nbLayer - 1; i >= 0; i--) {
            update = false;
            DisposableIntIterator origIter = graph.layers[i].getIterator();
            while (origIter.hasNext()) {
                int orig = origIter.next();
                graph.GNodes.spft[orig] = Double.POSITIVE_INFINITY;
                graph.GNodes.lpft[orig] = Double.NEGATIVE_INFINITY;
                StoredIndexedBipartiteSet bs = graph.GNodes.outArcs[orig];
                assert (!bs.isEmpty());
                DisposableIntIterator out = bs.getIterator();//getInEdgeIterator(n);
                while (out.hasNext()) {
                    int e = out.next();
                    if (!graph.isInStack(e)) {
                        int dest = graph.GArcs.dests[e];//e.getOrigin()  ;
                        double cost = graph.GArcs.temporaryCost[e];

                        double newCost = graph.GNodes.spft[dest] + cost;//cost[graph.GNodes.layers[next]][graph.GArcs.values[e]];
                        if (newCost + graph.GNodes.spfs[orig] - ub >= Configuration.MCR_DECIMAL_PREC) {
                            graph.getInStack().set(e);
                            removed.add(e);
                        } else if (graph.GNodes.spft[orig] > newCost) {
                            graph.GNodes.spft[orig] = newCost;
                            graph.GNodes.nextSP[orig] = e;
                            update = true;
                        }

                        double newCost2 = graph.GNodes.lpft[dest] + cost;//cost[graph.GNodes.layers[next]][graph.GArcs.values[e]];
                        if (newCost2 + graph.GNodes.lpfs[orig] - lb <= -Configuration.MCR_DECIMAL_PREC) {
                            graph.setInStack(e);
                            removed.add(e);
                        } else if (graph.GNodes.lpft[orig] < newCost2) {
                            graph.GNodes.lpft[orig] = newCost2;
                            graph.GNodes.nextLP[orig] = e;
                            update = true;
                        }


                    }
                }
                out.dispose();

            }
            origIter.dispose();
            if (!update) propagator.contradiction(null, "no update");
        }
View Full Code Here

TOP

Related Classes of util.iterators.DisposableIntIterator

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.