コード例 #1
0
        private void Run()
        {
            // direct all edges from the red nodes to the blue nodes
            RedirectedGraph redToBlue = new RedirectedGraph(Graph,
                                                            x => (IsRed(Graph.U(x)) ? RedirectedGraph.Direction.Forward : RedirectedGraph.Direction.Backward));

            // add a source and a target to the graph and some edges
            Supergraph flowGraph = new Supergraph(redToBlue);
            Node       source    = flowGraph.AddNode();
            Node       target    = flowGraph.AddNode();

            foreach (var node in Graph.Nodes())
            {
                if (IsRed(node))
                {
                    flowGraph.AddArc(source, node, Directedness.Directed);
                }
                else
                {
                    flowGraph.AddArc(node, target, Directedness.Directed);
                }
            }
            Arc reflow = flowGraph.AddArc(target, source, Directedness.Directed);

            // run the network simplex
            NetworkSimplex ns = new NetworkSimplex(flowGraph,
                                                   lowerBound: x => (x == reflow ? MinimumMatchingSize : 0),
                                                   upperBound: x => (x == reflow ? MaximumMatchingSize : 1),
                                                   cost: x => (Graph.HasArc(x) ? Cost(x) : 0));

            ns.Run();

            if (ns.State == SimplexState.Optimal)
            {
                var matching = new Matching(Graph);
                foreach (var arc in ns.UpperBoundArcs.Concat
                             (ns.Forest.Where(kv => kv.Value == 1).Select(kv => kv.Key)))
                {
                    if (Graph.HasArc(arc))
                    {
                        matching.Enable(arc, true);
                    }
                }
                Matching = matching;
            }
        }
コード例 #2
0
        private void cmbMatchingToolSelect_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (mat2dManger == null)
            {
                return;
            }
            int index = cmbMatchingToolSelect.SelectedIndex;

            if (index > -1)
            {
                mat2dManger.Mat2DToolName = mat2dTools[index];
                IMatching matchingTool = ToolsFactory.GetToolList(mat2dManger.SettingIndex).Find(
                    x => x.Name == mat2dTools[index]) as IMatching;
                if (matchingTool != null)
                {
                    mat2dManger.Mat2DToolName = ((ToolBase)matchingTool).Name;
                    if (mat2dManger.SelectMatchingToolObserver != null)
                    {
                        mat2dManger.SelectMatchingToolObserver(matchingTool);
                    }
                }
            }
        }
コード例 #3
0
        private void Run()
        {
            RedirectedGraph graph      = new RedirectedGraph(Graph, (Arc x) => (!IsRed(Graph.U(x))) ? RedirectedGraph.Direction.Backward : RedirectedGraph.Direction.Forward);
            Supergraph      supergraph = new Supergraph(graph);
            Node            node       = supergraph.AddNode();
            Node            node2      = supergraph.AddNode();

            foreach (Node item in Graph.Nodes())
            {
                if (IsRed(item))
                {
                    supergraph.AddArc(node, item, Directedness.Directed);
                }
                else
                {
                    supergraph.AddArc(item, node2, Directedness.Directed);
                }
            }
            Arc            reflow         = supergraph.AddArc(node2, node, Directedness.Directed);
            NetworkSimplex networkSimplex = new NetworkSimplex(supergraph, (Arc x) => (x == reflow) ? MinimumMatchingSize : 0, (Arc x) => (!(x == reflow)) ? 1 : MaximumMatchingSize, null, (Arc x) => (!Graph.HasArc(x)) ? 0.0 : Cost(x));

            networkSimplex.Run();
            if (networkSimplex.State == SimplexState.Optimal)
            {
                Matching matching = new Matching(Graph);
                foreach (Arc item2 in networkSimplex.UpperBoundArcs.Concat(from kv in networkSimplex.Forest
                                                                           where kv.Value == 1
                                                                           select kv.Key))
                {
                    if (Graph.HasArc(item2))
                    {
                        matching.Enable(item2, true);
                    }
                }
                Matching = matching;
            }
        }
コード例 #4
0
        static void Main(string[] args)
        {
            try
            {
                ucsAPI = new UCSAPIClass();

                serveruserData       = ucsAPI.ServerUserData as IServerUserData;
                terminalUserData     = ucsAPI.TerminalUserData as ITerminalUserData;
                accessLogData        = ucsAPI.AccessLogData as IAccessLogData;
                serverAuthentication = ucsAPI.ServerAuthentication as IServerAuthentication;
                terminalOption       = ucsAPI.TerminalOption as ITerminalOption;
                // create UCBioBSP Instance
                ucBioBSP   = new UCBioBSPClass();
                fpData     = ucBioBSP.FPData as IFPData;
                device     = ucBioBSP.Device as IDevice;
                extraction = ucBioBSP.Extraction as IExtraction;
                fastSearch = ucBioBSP.FastSearch as IFastSearch;
                matching   = ucBioBSP.Matching as IMatching;

                ucsAPI.EventTerminalConnected += UCSCOMObj_EventTerminalConnected;

                ucsAPI.EventRealTimeAccessLog += UcsAPI_EventRealTimeAccessLog;
                ucsAPI.EventOpenDoor          += ucsAPI_EventOpenDoor;
                ucsAPI.EventFirmwareVersion   += (id, terminalId, version) =>
                {
                    Console.WriteLine("*EVENTFIRMAREVERSION*");
                    Console.WriteLine("+    ERROR CODE: {0}", ucsAPI.ErrorCode);
                };

                ucsAPI.ServerStart(255, 9840);

                ucsAPI.EventVerifyCard += (id, mode, level, rfid) =>
                {
                    Console.WriteLine("<--EventVerifyCard");
                    Console.WriteLine($"   +ErrorCode:{ucsAPI.ErrorCode}");
                    Console.WriteLine($"   +TerminalID:{id}");
                    Console.WriteLine($"   +AuthMode:{mode}");
                    Console.WriteLine($"   +Antipassback Level:{level}");
                    Console.WriteLine($"   +TextRFID:{rfid}");
                };

                ucsAPI.EventTerminalStatus += (id, terminalId, status, doorStatus, coverStatus) =>
                {
                    Console.WriteLine("<--EventTerminal Status");
                    Console.WriteLine($"   +ClientID:{0}", id);
                    Console.WriteLine($"   +TerminalID:{0}", terminalId);
                    Console.WriteLine($"   +Terminal Status:{status}");
                    Console.WriteLine($"   +Door Status:{doorStatus}");
                    Console.WriteLine($"   +Cover Status:{coverStatus}");
                    Console.WriteLine($"   +Error Code: {ucsAPI.ErrorCode}");
                    Console.WriteLine($"    +MAC: {ucsAPI.TerminalMacAddr[1]}");
                };

                ucBioBSP.OnCaptureEvent += UcBioBSP_OnCaptureEvent;

                Console.ReadKey();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
コード例 #5
0
 public MatchedObjects(IMatching match, MatchingObject[] objects)
 {
     _match   = match;
     _objects = objects;
 }
コード例 #6
0
 public Rule(IMatching cond, IEffect effect)
 {
     _cond   = cond;
     _effect = effect;
 }
コード例 #7
0
ファイル: TimerMatching.cs プロジェクト: bouro412/Kirikabu
 public TimerMatching(IMatching matching, float timerSec)
 {
     _anotherMatching = matching;
     _timerSec        = timerSec;
     _lastSec         = UnityEngine.Time.time;
 }