Package util.iterators

Examples of util.iterators.DisposableIntIterator


    public BitSet inStack;
    private IntVar[] z;

    public void delayedBoundUpdate(TIntStack toRemove, IntVar[] z, int... dim) {
        for (int i = 0; i < offsets.length; i++) {
            DisposableIntIterator iter = this.layers[i].getIterator();
            while (iter.hasNext()) {
                int n = iter.next();
                DisposableIntIterator it = this.GNodes.outArcs[n].getIterator();
                while (it.hasNext()) {
                    int arc = it.next();
                    int val = this.GArcs.values[arc];
                    int orig = this.GArcs.origs[arc];
                    int dest = this.GArcs.dests[arc];
                    for (int k : dim) {
                        if (GNodes.spfsI[orig][k] + GArcs.originalCost[arc][k] + GNodes.spftI[dest][k] > z[k].getUB() ||
                                GNodes.lpfsI[orig][k] + GArcs.originalCost[arc][k] + GNodes.lpftI[dest][k] < z[k].getLB()) {
                            if (!isInStack(arc)) {
                                setInStack(arc);
                                toRemove.push(arc);
                            }
                        }
                    }
                }
                it.dispose();
            }
            iter.dispose();
        }
    }
View Full Code Here


    }

    public int getRegret(int layer, int value, int... resources) {
        int result = Integer.MAX_VALUE;
        StoredIndexedBipartiteSetWithOffset arcs = this.getUBport(layer, value);
        DisposableIntIterator it = arcs.getIterator();

        while (it.hasNext()) {
            int arcId = it.next();
            int origId = GArcs.origs[arcId];
            int destId = GArcs.dests[arcId];
            int cost = 0;
            for (int r : resources) {
                cost += pf.spfs[origId][r] + GArcs.originalCost[arcId][r] + pf.spft[destId][r];
            }
            if (cost < result)
                result = cost;


        }
        it.dispose();
        for (int r : resources) {
            result -= pf.spft[sourceIndex][r];
        }
        if (result < 0)
            ;//   System.err.println("STR");
View Full Code Here

    public int getMinPathCostForAssignment(int layer, int value, int... resources) {
        int result = Integer.MAX_VALUE;
        StoredIndexedBipartiteSetWithOffset arcs = this.getUBport(layer, value);

        DisposableIntIterator it = arcs.getIterator();
        int[] list = arcs._getStructure();
        int size = arcs.size();
        for (int i = 0; i < size; i++) {//while (it.hasNext()) {
            int arcId = list[i];//it.next();
            int origId = GArcs.origs[arcId];
            int destId = GArcs.dests[arcId];
            int cost = 0;
            for (int r : resources) {
                cost += pf.spfs[origId][r] + GArcs.originalCost[arcId][r] + pf.spft[destId][r];
            }
            if (cost < result)
                result = cost;
        }
        it.dispose();
        return result;
    }
View Full Code Here

    public int[] getMinMaxPathCostForAssignment(int layer, int value, int... resources) {
        minmax[0] = Integer.MAX_VALUE;
        minmax[1] = Integer.MIN_VALUE;
        StoredIndexedBipartiteSetWithOffset arcs = this.getUBport(layer, value);
        DisposableIntIterator it = arcs.getIterator();

        while (it.hasNext()) {
            int arcId = it.next();
            int origId = GArcs.origs[arcId];
            int destId = GArcs.dests[arcId];
            int cost = 0;
            for (int r : resources) {
                cost += pf.spfs[origId][r] + GArcs.originalCost[arcId][r] + pf.spft[destId][r];
            }
            if (cost < minmax[0])
                minmax[0] = cost;
            if (cost > minmax[1])
                minmax[1] = cost;
        }
        it.dispose();
        return minmax;
    }
View Full Code Here

        return minmax;
    }

    public double[] getInstantiatedLayerCosts(int layer) {
        StoredIndexedBipartiteSetWithOffset couche = layers[layer];
        DisposableIntIterator it = couche.getIterator();
        int node = it.next();
        it.dispose();
        it = GNodes.outArcs[node].getIterator();
        int arcId = it.next();
        it.dispose();
        return GArcs.originalCost[arcId];
    }
View Full Code Here


        for (int i = 1; i < layers.length; i++) {
            int[] layer = layers[i];
            for (int q : layer) {
                DisposableIntIterator it = GNodes.inArcs[q].getIterator();
                while (it.hasNext()) {
                    int arc = it.next();
                    double acost = GArcs.costs[arc];
                    int orig = GArcs.origs[arc];
                    double otherS = GNodes.spfs.quickGet(orig) + acost;
                    if (otherS < GNodes.spfs.quickGet(q)) {
                        GNodes.spfs.quickSet(q, otherS);
                        GNodes.prevSP.quickSet(q, arc);
                    }

                    double otherL = GNodes.lpfs.quickGet(orig) + acost;
                    if (otherL > GNodes.lpfs.quickGet(q)) {
                        GNodes.lpfs.quickSet(q, otherL);
                        GNodes.prevLP.quickSet(q, arc);
                    }

                }
                it.dispose();

            }

        }

        for (int i = layers.length - 2; i >= 0; i--) {
            int[] layer = layers[i];
            for (int q : layer) {
                DisposableIntIterator it = GNodes.outArcs[q].getIterator();
                while (it.hasNext()) {
                    int arc = it.next();
                    double acost = GArcs.costs[arc];
                    int dest = GArcs.dests[arc];
                    double otherS = GNodes.spft.quickGet(dest) + acost;
                    if (otherS < GNodes.spft.quickGet(q)) {
                        GNodes.spft.quickSet(q, otherS);
                        GNodes.nextSP.quickSet(q, arc);
                    }

                    double otherL = GNodes.lpft.quickGet(dest) + acost;
                    if (otherL > GNodes.lpft.quickGet(q)) {
                        GNodes.lpft.quickSet(q, otherL);
                        GNodes.nextLP.quickSet(q, arc);
                    }
                }
                it.dispose();
            }
        }

        //   System.out.println(GNodes.lpfs.get(end));
        //   System.out.println(GNodes.lpft.get(start));
View Full Code Here

        double tempPval = Double.POSITIVE_INFINITY;
        double tempPval2 = Double.NEGATIVE_INFINITY;
        int tempP = Integer.MIN_VALUE;
        int temp2 = Integer.MIN_VALUE;
        DisposableIntIterator it = GNodes.outArcs[nid].getIterator();


        while (it.hasNext()) {
            int arcId = it.next();
            int dest = GArcs.dests[arcId];
            double spft = GNodes.spft.quickGet(dest) + GArcs.costs[arcId];
            if (tempPval > spft) {
                tempPval = spft;
                tempP = arcId;
            }

            double lpft = GNodes.lpft.quickGet(dest) + GArcs.costs[arcId];
            if (tempPval2 < lpft) {
                tempPval2 = lpft;
                temp2 = arcId;
            }


        }
        it.dispose();
        double old = GNodes.spft.quickSet(nid, tempPval);
        GNodes.nextSP.quickSet(nid, tempP);

        double old2 = GNodes.lpft.quickSet(nid, tempPval2);
        GNodes.nextLP.quickSet(nid, temp2);

        if (nid != sourceIndex && (old != tempPval || old2 != tempPval2)) {
            it = GNodes.inArcs[nid].getIterator();

            while (it.hasNext()) {
                int arcId = it.next();
                int orig = GArcs.origs[arcId];
                if ((GNodes.nextSP.quickGet(orig) == arcId && old != tempPval) || (old2 != tempPval2 && GNodes.nextLP.quickGet(orig) == arcId)) {
                    toUpdateRight.push(orig);
                    //updateRight(orig,toRemove);
                }
                double spfs = GNodes.spfs.quickGet(orig);
                double lpfs = GNodes.lpfs.quickGet(orig);

                double acost = GArcs.costs[arcId];
                if (!isInStack(arcId) && (tempPval + spfs + acost > propagator.getVar(starts.length).getUB()
                        || tempPval2 + lpfs + acost < propagator.getVar(starts.length).getLB())) {
                    setInStack(arcId);
                    toRemove.push(arcId);
                }
            }
            it.dispose();
        }


    }
View Full Code Here

    public void updateSPFT(int nid, TIntStack toRemove, Propagator<IntVar> propagator) {


        double tempPval = Double.POSITIVE_INFINITY;
        int tempP = Integer.MIN_VALUE;
        DisposableIntIterator it = GNodes.outArcs[nid].getIterator();


        while (it.hasNext()) {
            int arcId = it.next();
            int dest = GArcs.dests[arcId];
            double spft = GNodes.spft.quickGet(dest) + GArcs.costs[arcId];
            if (tempPval > spft) {
                tempPval = spft;
                tempP = arcId;
            }

        }
        it.dispose();
        double old = GNodes.spft.quickSet(nid, tempPval);
        GNodes.nextSP.quickSet(nid, tempP);

        if (nid != sourceIndex && old != tempPval) {
            it = GNodes.inArcs[nid].getIterator();

            while (it.hasNext()) {
                int arcId = it.next();
                int orig = GArcs.origs[arcId];
                if (GNodes.nextSP.quickGet(orig) == arcId) {
                    updateSPFT(orig, toRemove, propagator);
                }
                double spfs = GNodes.spfs.quickGet(orig);
                double acost = GArcs.costs[arcId];
                if (!isInStack(arcId) && tempPval + spfs + acost > propagator.getVar(starts.length).getUB()) {
                    setInStack(arcId);
                    toRemove.push(arcId);
                }
            }
            it.dispose();
        }

    }
View Full Code Here

    public void updateLPFT(int nid, TIntStack toRemove, Propagator<IntVar> propagator) {


        double tempPval = Double.NEGATIVE_INFINITY;
        int tempP = Integer.MIN_VALUE;
        DisposableIntIterator it = GNodes.outArcs[nid].getIterator();


        while (it.hasNext()) {
            int arcId = it.next();
            int dest = GArcs.dests[arcId];
            double lpft = GNodes.lpft.quickGet(dest) + GArcs.costs[arcId];
            if (tempPval < lpft) {
                tempPval = lpft;
                tempP = arcId;
            }

        }
        it.dispose();
        double old = GNodes.lpft.quickSet(nid, tempPval);
        GNodes.nextLP.quickSet(nid, tempP);

        if (nid != sourceIndex && old != tempPval) {
            it = GNodes.inArcs[nid].getIterator();

            while (it.hasNext()) {
                int arcId = it.next();
                int orig = GArcs.origs[arcId];
                if (GNodes.nextLP.quickGet(orig) == arcId) {
                    updateLPFT(orig, toRemove, propagator);
                }
                double lpfs = GNodes.lpfs.quickGet(orig);
                double acost = GArcs.costs[arcId];
                if (!isInStack(arcId) && tempPval + lpfs + acost < propagator.getVar(starts.length).getLB()) {
                    setInStack(arcId);
                    toRemove.push(arcId);
                }
            }
            it.dispose();
        }

    }
View Full Code Here

        int tempP = Integer.MIN_VALUE;

        double tempPval2 = Double.NEGATIVE_INFINITY;
        int tempP2 = Integer.MIN_VALUE;

        DisposableIntIterator it = GNodes.inArcs[nid].getIterator();


        while (it.hasNext()) {
            int arcId = it.next();
            int orig = GArcs.origs[arcId];
            double spfs = GNodes.spfs.quickGet(orig) + GArcs.costs[arcId];
            if (tempPval > spfs) {
                tempPval = spfs;
                tempP = arcId;
            }
            double lpfs = GNodes.lpfs.quickGet(orig) + GArcs.costs[arcId];
            if (tempPval2 < lpfs) {
                tempPval2 = lpfs;
                tempP2 = arcId;
            }

        }

        it.dispose();
        double old = GNodes.spfs.quickSet(nid, tempPval);
        GNodes.prevSP.quickSet(nid, tempP);
        double old2 = GNodes.lpfs.quickSet(nid, tempPval2);
        GNodes.prevLP.quickSet(nid, tempP2);

        if (nid != tinkIndex && (old != tempPval || old2 != tempPval2)) {
            it = GNodes.outArcs[nid].getIterator();

            while (it.hasNext()) {
                int arcId = it.next();
                int dest = GArcs.dests[arcId];
                if ((old != tempPval && GNodes.prevSP.quickGet(dest) == arcId) || (old2 != tempPval2 && GNodes.prevLP.quickGet(dest) == arcId)) {
                    // updateLeft(dest,toRemove);
                    toUpdateLeft.push(dest);
                }
                double spft = GNodes.spft.quickGet(dest);
                double acost = GArcs.costs[arcId];
                double lpft = GNodes.lpft.quickGet(dest);
                if (!isInStack(arcId) && (tempPval + spft + acost > propagator.getVar(starts.length).getUB()
                        || tempPval2 + lpft + acost < propagator.getVar(starts.length).getLB())) {
                    setInStack(arcId);
                    toRemove.push(arcId);
                }
            }
            it.dispose();
        }


    }
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.