Exemplo n.º 1
0
        internal Edge[] ShortestPath(int start, int end)
        {
            bool [] fnodes = new Boolean[this.NumberOfVertices];
            fnodes[end] = true;
            SSMTSP dm = new SSMTSP(this, start, fnodes /*,this.pq */);

            return(dm.GetPathAsEdges());
        }
Exemplo n.º 2
0
//N-stages
        internal void stages()
        {
            bool[] fnodes = new bool[2 * N];         //init with trues the second half
            for (int i = 0; i < N; i++)
            {
                fnodes[N + i] = true;
            }
            GraphWithMatching graph = new GraphWithMatching(M, w, P, flatA, flatB);

            //IntBinaryHeapPriorityQueue pq=new IntBinaryHeapPriorityQueue(graph.NumberOfVertices);
            for (int i = 0; i < N; i++)
            {
                //match i-th node
                SSMTSP spa              = new SSMTSP(graph, i, fnodes /*,pq */);
                int[]  path             = spa.GetPath();
                int    theClosestVertex = path[path.Length - 1];
                int    db0              = spa.dist[theClosestVertex];
                fnodes[theClosestVertex] = false;
                //db0 gives the shortest reduced price cost path
                //fix potential
                for (int j = 0; j < N; j++)
                {
                    int m = db0 - spa.dist[j];
                    if (m > 0)
                    {
                        P[j] -= m;
                    }

                    m = db0 - spa.dist[N + j];
                    if (m > 0)
                    {
                        P[N + j] += m;
                    }
                }

                for (int j = 1; j < path.Length; j += 2)
                {
                    M[path[j] - N] = path[j - 1];
                }
            }
        }
Exemplo n.º 3
0
Arquivo: WCBM.cs Projeto: juhan/NModel
        //N-stages
        internal void stages()
        {
            bool[] fnodes=new bool[2*N]; //init with trues the second half
            for(int i=0;i<N;i++)
            {
                fnodes[N+i]=true;
            }
            GraphWithMatching graph=new GraphWithMatching(M,w,P,flatA,flatB);
            //IntBinaryHeapPriorityQueue pq=new IntBinaryHeapPriorityQueue(graph.NumberOfVertices);
            for(int i=0;i<N;i++)
            {

            //match i-th node
                SSMTSP spa=new SSMTSP(graph,i, fnodes /*,pq */);
                int[] path=spa.GetPath();
                int theClosestVertex=path[path.Length-1];
                int db0=spa.dist[theClosestVertex];
                fnodes[theClosestVertex]=false;
                //db0 gives the shortest reduced price cost path
                //fix potential
                for(int j=0;j<N;j++)
                {
                    int m=db0-spa.dist[j];
                    if (m>0)
                        P[j]-=m;

                    m=db0-spa.dist[N+j];
                    if(m>0)
                        P[N+j]+=m;
                }

                for(int j=1;j<path.Length;j+=2)
                {
                    M[path[j]-N]=path[j-1];
                }

            }
        }
Exemplo n.º 4
0
 internal Edge[] ShortestPath(int start, int end)
 {
     bool [] fnodes=new Boolean[this.NumberOfVertices];
     fnodes[end]=true;
     SSMTSP dm=new SSMTSP(this,start,fnodes /*,this.pq */);
     return dm.GetPathAsEdges();
 }