Пример #1
0
        private void ImportToMCMFAlgorithm()
        {
            this.outputProblem = new NF_ProblemInstance(this.NFNodes.Max(x => x.nodeIndex), this.edgeCounter);
            foreach (NFReducerNode inputNodeToEdge in NFNodes)
            {
                foreach (NFReducerNode outputNodeFromEdge in inputNodeToEdge.edgeTo)
                {
                    int edgeCost, edgeCapacity;
                    if (outputNodeFromEdge.nodeIndex == 0)
                    {
                        edgeCost     = 0;
                        edgeCapacity = this.startPositions.Length;
                    }
                    else if (inputNodeToEdge.isInputNode && !outputNodeFromEdge.isInputNode)
                    {
                        edgeCost     = 0;
                        edgeCapacity = 1;
                    }
                    else
                    {
                        edgeCost     = 1;
                        edgeCapacity = 1;
                    }
                    outputProblem.AddEdge(inputNodeToEdge.nodeIndex, outputNodeFromEdge.nodeIndex, edgeCost, edgeCapacity);
                }
                if (inputNodeToEdge.nodeTime == T && IsStartPosition(inputNodeToEdge))
                {
                    outputProblem.AddSupply(inputNodeToEdge.nodeIndex, 1);
                }
            }

            outputProblem.AddSupply(0, this.startPositions.Length * (-1));
        }
Пример #2
0
 public MinCostMaxFlow(NF_ProblemInstance problem)
 {
     this.numNodes   = problem.numNodes;
     this.numArcs    = problem.numArcs;
     this.startNodes = problem.startNodes;
     this.endNodes   = problem.endNodes;
     this.unitCosts  = problem.unitCosts;
     this.capacities = problem.capacities;
     this.supplies   = problem.supplies;
 }
Пример #3
0
        public CFMAM_MCMF_Reducer(ProblemInstance problem, Move goalState)
        {
            this.problemGrid = problem.m_vGrid;

            startPositions          = new Move[problem.GetNumOfAgents()];
            this.startPositionsDict = new Dictionary <KeyValuePair <int, int>, int>();
            for (int i = 0; i < problem.m_vAgents.Length; i++)
            {
                startPositions[i] = problem.m_vAgents[i].lastMove;
                this.startPositionsDict.Add(new KeyValuePair <int, int>(startPositions[i].x, startPositions[i].y), 1);
            }

            startPositionsToDiscover = problem.GetNumOfAgents();

            this.goalState             = goalState;
            this.NFNodes               = new HashSet <NFReducerNode>();
            this.l                     = -1;
            this.T                     = -1;
            this.edgeCounter           = 0;
            this.outputProblem         = null;
            NFReducerNode.indexCounter = 0;
            this.zeroLayer             = new List <NFReducerNode>();
        }