Package util.objects

Examples of util.objects.StoredIndexedBipartiteSetWithOffset


    }

    for (int i = 0; i < sups.length; i++) {
      if (sups[i] != null)
        supports[i] = new StoredIndexedBipartiteSetWithOffset(environment, sups[i].toArray());
    }

    Set<Node> nodes = graph.vertexSet();
    GNodes.outArcs = new StoredIndexedBipartiteSetWithOffset[nodes.size()];
    GNodes.inArcs = new StoredIndexedBipartiteSetWithOffset[nodes.size()];
    GNodes.layers = new int[nodes.size()];
    GNodes.states = new int[nodes.size()];


    for (Node n : nodes) {
      GNodes.layers[n.id] = n.layer;
      GNodes.states[n.id] = n.state;
      int i;
      Set<Arc> outarc = graph.outgoingEdgesOf(n);
      if (!outarc.isEmpty()) {
        int[] out = new int[outarc.size()];
        i = 0;
        for (Arc a : outarc) {
          out[i++] = a.id;
        }
        GNodes.outArcs[n.id] = new StoredIndexedBipartiteSetWithOffset(environment, out);
      }

      Set<Arc> inarc = graph.incomingEdgesOf(n);
      if (!inarc.isEmpty()) {
        int[] in = new int[inarc.size()];
        i = 0;
        for (Arc a : inarc) {
          in[i++] = a.id;
        }
        GNodes.inArcs[n.id] = new StoredIndexedBipartiteSetWithOffset(environment, in);
      }
    }
  }
View Full Code Here


  //***********************************************************************************
  // EXTERNAL METHODS
  //***********************************************************************************

  public boolean hasSupport(int i, int j) {
    StoredIndexedBipartiteSetWithOffset sup = getSupport(i,j);
    return sup != null && !sup.isEmpty();
  }
View Full Code Here

      int dest = GArcs.dests[arcId];

      int layer = GNodes.layers[orig];
      int value = GArcs.values[arcId];

      StoredIndexedBipartiteSetWithOffset support = getSupport(layer, value);
      support.remove(arcId);

      if (support.isEmpty()) {
        IntVar var = propagator.getVar(layer);
        try {
          var.removeValue(value, propagator);
        } catch (ContradictionException ex) {
          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();
View Full Code Here

        this.z = z;
        this.starts = starts;
        this.offsets = offsets;
        this.layers = new StoredIndexedBipartiteSetWithOffset[layers.length];
        for (int i = 0; i < layers.length; i++) {
            this.layers[i] = new StoredIndexedBipartiteSetWithOffset(environment, layers[i]);
        }
        this.sourceIndex = layers[0][0];
        this.tinIndex = layers[layers.length - 1][0];

        this.GNodes = new Nodes();
        this.GArcs = new Arcs();

        TIntHashSet[] sups = new TIntHashSet[supportLength];
        this.supports = new StoredIndexedBipartiteSetWithOffset[supportLength];


        Set<Arc> arcs = graph.edgeSet();

        this.inStack = new BitSet(arcs.size());//environment.makeBitSet(arcs.size());

        GArcs.values = new int[arcs.size()];
        GArcs.dests = new int[arcs.size()];
        GArcs.origs = new int[arcs.size()];
        GArcs.originalCost = new double[arcs.size()][nbR];
        GArcs.temporaryCost = new double[arcs.size()];


        for (Arc a : arcs) {

            GArcs.values[a.id] = a.value;
            GArcs.dests[a.id] = a.dest.id;
            GArcs.origs[a.id] = a.orig.id;
            int state = a.orig.state;
            int layer = a.orig.layer;
            for (int r = 0; r < nbR; r++) {
                GArcs.originalCost[a.id][r] = layer < layers.length - 2 ? pi.getCostByResourceAndState(layer, a.value, r, state) : 0.0;
            }


            if (a.orig.layer < starts.length) {
                int idx = starts[a.orig.layer] + a.value - offsets[a.orig.layer];
                if (sups[idx] == null)
                    sups[idx] = new TIntHashSet();
                sups[idx].add(a.id);
            }

        }

        for (int i = 0; i < sups.length; i++) {
            if (sups[i] != null)
                supports[i] = new StoredIndexedBipartiteSetWithOffset(environment, sups[i].toArray());
        }

        Set<Node> nodes = graph.vertexSet();
        GNodes.outArcs = new StoredIndexedBipartiteSetWithOffset[nodes.size()];
        GNodes.inArcs = new StoredIndexedBipartiteSetWithOffset[nodes.size()];
        GNodes.layers = new int[nodes.size()];
        GNodes.states = new int[nodes.size()];

        GNodes.prevLP = new int[nodes.size()];
        Arrays.fill(GNodes.prevLP, Integer.MIN_VALUE);
        GNodes.nextLP = new int[nodes.size()];
        Arrays.fill(GNodes.nextLP, Integer.MIN_VALUE);
        GNodes.prevSP = new int[nodes.size()];
        Arrays.fill(GNodes.prevSP, Integer.MIN_VALUE);
        GNodes.nextSP = new int[nodes.size()];
        Arrays.fill(GNodes.nextSP, Integer.MIN_VALUE);


        GNodes.lpfs = new double[nodes.size()];
        GNodes.lpft = new double[nodes.size()];
        GNodes.spfs = new double[nodes.size()];
        GNodes.spft = new double[nodes.size()];


        GNodes.lpfsI = new double[nodes.size()][nbR];
        GNodes.lpftI = new double[nodes.size()][nbR];
        GNodes.spfsI = new double[nodes.size()][nbR];
        GNodes.spftI = new double[nodes.size()][nbR];

        GNodes.prevLPI = new int[nodes.size()][nbR];
        GNodes.nextLPI = new int[nodes.size()][nbR];
        GNodes.prevSPI = new int[nodes.size()][nbR];
        GNodes.nextSPI = new int[nodes.size()][nbR];
        for (int k = 0; k < nbR; k++) {
            Arrays.fill(GNodes.prevLPI[k], Integer.MIN_VALUE);
            Arrays.fill(GNodes.nextLPI[k], Integer.MIN_VALUE);
            Arrays.fill(GNodes.prevSPI[k], Integer.MIN_VALUE);
            Arrays.fill(GNodes.nextSPI[k], Integer.MIN_VALUE);
        }


        for (Node n : nodes) {
            GNodes.layers[n.id] = n.layer;
            GNodes.states[n.id] = n.state;
            int i;
            Set<Arc> outarc = graph.outgoingEdgesOf(n);
            if (!outarc.isEmpty()) {
                int[] out = new int[outarc.size()];
                i = 0;
                for (Arc a : outarc) {
                    out[i++] = a.id;
                }
                GNodes.outArcs[n.id] = new StoredIndexedBipartiteSetWithOffset(environment, out);
            }

            Set<Arc> inarc = graph.incomingEdgesOf(n);
            if (!inarc.isEmpty()) {
                int[] in = new int[inarc.size()];
                i = 0;
                for (Arc a : inarc) {
                    in[i++] = a.id;
                }
                GNodes.inArcs[n.id] = new StoredIndexedBipartiteSetWithOffset(environment, in);
            }
        }


    }
View Full Code Here

        int layer = GNodes.layers[orig];
        int value = GArcs.values[arcId];

        if (layer < starts.length) {
            StoredIndexedBipartiteSetWithOffset support = getUBport(layer, value);
            support.remove(arcId);

            if (support.isEmpty()) {
                IntVar var = propagator.getVar(layer);
                var.removeValue(value, propagator);//, false);
            }
        }

        int[] list;
        int size;
        StoredIndexedBipartiteSetWithOffset out = GNodes.outArcs[orig];
        StoredIndexedBipartiteSetWithOffset in;

        out.remove(arcId);


        if (out.isEmpty()) {
            layers[layer].remove(orig);
            if (layer > 0) {
                in = GNodes.inArcs[orig];
                list = in._getStructure();
                size = in.size();
                for (int i = 0; i < size; i++)//while(it.hasNext())
                {
                    int id = list[i];//it.next();
                    if (!isInStack(id)) {
                        setInStack(id);
                        toRemove.push(id);
                    }
                }
                //it.dispose();
            }
        } else {
            for (int k = 0; k < nbR; k++) {
                //   System.out.println(GNodes.nextSPI[orig][k] + " " + arcId);
                if (GNodes.nextSPI[orig][k] == arcId || GNodes.nextLPI[orig][k] == arcId) {
                    updateRight[k].push(orig);
                    needUpdate = true;
                    //  updateRight(orig,toRemove,k,modBound);
                }
            }
        }


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


        if (in.isEmpty()) {
            layers[layer + 1].remove(dest);
            if (layer + 1 < starts.length) {
                out = GNodes.outArcs[dest];
                list = out._getStructure();
                size = out.size();
View Full Code Here

        inStack.clear(idx);
    }

    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];
View Full Code Here

        return result;
    }

    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;
View Full Code Here

    private int[] minmax = new int[2];

    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];
View Full Code Here

        it.dispose();
        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();
View Full Code Here

        // this.inGraph = constraint.getSolver().getEnvironment().makeBitSet(arcs.size());
//        this.inGraph.set(0,arcs.size());
        // System.out.println(this.inGraph.size());
        for (int i = 0; i < sups.length; i++) {
            if (sups[i] != null)
                supports[i] = new StoredIndexedBipartiteSetWithOffset(environment, sups[i].toArray());
        }

        Set<Node> nodes = graph.vertexSet();
        GNodes.outArcs = new StoredIndexedBipartiteSetWithOffset[nodes.size()];
        GNodes.inArcs = new StoredIndexedBipartiteSetWithOffset[nodes.size()];
        GNodes.layers = new int[nodes.size()];
        GNodes.states = new int[nodes.size()];

        GNodes.prevLP = environment.makeIntVector(nodes.size(), Integer.MIN_VALUE);
        GNodes.nextLP = environment.makeIntVector(nodes.size(), Integer.MIN_VALUE);
        GNodes.prevSP = environment.makeIntVector(nodes.size(), Integer.MIN_VALUE);
        GNodes.nextSP = environment.makeIntVector(nodes.size(), Integer.MIN_VALUE);


        GNodes.lpfs = environment.makeDoubleVector(nodes.size(), Double.NEGATIVE_INFINITY);
        GNodes.lpft = environment.makeDoubleVector(nodes.size(), Double.NEGATIVE_INFINITY);
        GNodes.spfs = environment.makeDoubleVector(nodes.size(), Double.POSITIVE_INFINITY);
        GNodes.spft = environment.makeDoubleVector(nodes.size(), Double.POSITIVE_INFINITY);


        for (Node n : nodes) {
            GNodes.layers[n.id] = n.layer;
            GNodes.states[n.id] = n.state;

            int i;
            Set<Arc> outarc = graph.outgoingEdgesOf(n);
            if (!outarc.isEmpty()) {
                int[] out = new int[outarc.size()];
                i = 0;
                for (Arc a : outarc) {
                    out[i++] = a.id;
                }
                GNodes.outArcs[n.id] = new StoredIndexedBipartiteSetWithOffset(environment, out);
            }

            Set<Arc> inarc = graph.incomingEdgesOf(n);
            if (!inarc.isEmpty()) {
                int[] in = new int[inarc.size()];
                i = 0;
                for (Arc a : inarc) {
                    in[i++] = a.id;
                }
                GNodes.inArcs[n.id] = new StoredIndexedBipartiteSetWithOffset(environment, in);
            }
        }


        initPathInfo();
View Full Code Here

TOP

Related Classes of util.objects.StoredIndexedBipartiteSetWithOffset

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.