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);
}
}
}