当前位置: 首页>>代码示例>>C#>>正文


C# IResult.Push方法代码示例

本文整理汇总了C#中IResult.Push方法的典型用法代码示例。如果您正苦于以下问题:C# IResult.Push方法的具体用法?C# IResult.Push怎么用?C# IResult.Push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IResult的用法示例。


在下文中一共展示了IResult.Push方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SearchKNN

        public override IResult SearchKNN(object q, int K, IResult res)
        {
            var n = this.Vertices.Count;
            const int window = 2;

            var prev = double.MaxValue;
            var curr = 0.0;
            var inserted = new HashSet<int> ();
            var candidates = new Result (Math.Max(K, 32));
            // var candidates = new Result (K+K);

            while (prev > curr) {
                prev = res.CoveringRadius;
                for (int i = 0; i < window; ++i) {
                    var next = this.rand.Next (this.Vertices.Count);
                    if (inserted.Add (next)) {
                        var _res = new Result (res.K);
                        var d = this.DB.Dist (q, this.DB [next]);
                        candidates.Push (next, d);
                        res.Push (next, d);
                        this.InternalSearch (q, candidates, inserted, _res);
                        foreach (var p in _res) {
                            res.Push (p.ObjID, p.Dist);
                        }
                    }
                }
                curr = res.CoveringRadius;
            }
            return res;
        }
开发者ID:sadit,项目名称:natix,代码行数:30,代码来源:MetricGraphGreedy.cs

示例2: SearchKNNNode

 protected override void SearchKNNNode(Node node, object q, IResult res)
 {
     // res.Push (node.objID, dist);
     var D = new double[node.Children.Count];
     var closer_child = node.Children[0];
     var closer_dist = this.DB.Dist(q, this.DB[closer_child.objID]);
     res.Push(closer_child.objID, closer_dist);
     D[0] = closer_dist;
     for (int i = 1; i < D.Length; ++i) {
         var child = node.Children[i];
         D[i] = this.DB.Dist(q, this.DB[child.objID]);
         res.Push(child.objID, D[i]);
         if (D[i] < closer_dist) {
             closer_dist = D[i];
             closer_child = child;
         }
     }
     if (closer_child.Children.Count > 0) {
         this.SearchKNNNode (closer_child, q, res);
     }
     //                for (int i = 0; i < D.Length; ++i) {
     //                    if (D[i] <= closer_dist + 2 * res.CoveringRadius) {
     //                        this.SearchKNNNode(D[i], node.Children[i], q, res);
     //                    }
     //                }
 }
开发者ID:KeithNel,项目名称:natix,代码行数:26,代码来源:SAT_ApproxSearch.cs

示例3: SearchKNN

 public override IResult SearchKNN(object q, int K, IResult final_result)
 {
     var state = new SearchState ();
     var beam = this.FirstBeam (q, final_result, state);
     var beamsize = beam.Count;
     double prevcov = 0;
     int count_ties = 0;
     for (int i = 0; i < this.RepeatSearch; ++i) {
         prevcov = final_result.CoveringRadius;
         var _beam = new Result (beamsize);
         //if (this.Vertices.Count == this.DB.Count)
         //	Console.WriteLine ("=== Iteration {0}/{1}, res-count: {2}, res-cov: {3}", i, this.RepeatSearch, final_result.Count, final_result.CoveringRadius);
         foreach (var pair in beam) {
             foreach(var neighbor_docID in this.Vertices [pair.docid]) {
                 // Console.WriteLine ("=== B i: {0}, docID: {1}, parent: {2}, beamsize: {3}", i, neighbor_docID, pair, beam.Count);
                 if (state.evaluated.Add(neighbor_docID)) {
                     var d = this.DB.Dist (q, this.DB [neighbor_docID]);
                     final_result.Push (neighbor_docID, d);
                     _beam.Push (neighbor_docID, d);
                 }
             }
         }
         if (final_result.CoveringRadius == prevcov) {
             if (count_ties == 1) {
                 // we stop after two ties
                 break;
             }
             ++count_ties;
         } else {
             count_ties = 0;
         }
         beam = _beam;
     }
     return final_result;
 }
开发者ID:KeithNel,项目名称:natix,代码行数:35,代码来源:ApproxGraphLocalBeamKNR.cs

示例4: SearchKNN

        public override IResult SearchKNN(object q, int K, IResult res)
        {
            var window = 2;
            if (this.Vertices.Count > 16) {
                window = 8;
            }
            //			if (this.Vertices.Count > 10000) {
            //				Console.WriteLine ("STARTING SEARCH");
            //			}
            var prev = double.MaxValue;
            var curr = 0.0;
            var inserted = new HashSet<int> ();
            var candidates = new Result (this.Vertices.Count);

            while (prev > curr) {
                prev = res.CoveringRadius;
                for (int i = 0; i < window; ++i) {
                    var next = this.rand.Next (this.Vertices.Count);
                    if (inserted.Add (next)) {
                        var d = this.DB.Dist (q, this.DB [next]);
                        candidates.Push (next, d);
                        res.Push (next, d);
                        this.InternalSearch (q, candidates, inserted, res);
                    }
                }
                curr = res.CoveringRadius;
            }
            return res;
        }
开发者ID:sadit,项目名称:natix,代码行数:29,代码来源:ApproxGraphOptRestartsIS.cs

示例5: SearchKNN

 public override IResult SearchKNN(object q, int K, IResult res)
 {
     int m = this.nodes.Length; // ~10% of the pivots will be seen
     var distances = new double[m];
     var sortedNodes = new Node[m];
     for (int i = 0; i < m; ++i) {
         sortedNodes [i] = this.nodes [i];
         var objID = this.nodes [i].objID;
         distances [i] = this.DB.Dist (q, this.DB [objID]);
         res.Push (objID, distances [i]);
     }
     this.internal_numdists += m;
     Array.Sort (distances, sortedNodes);
     foreach (var objID in sortedNodes[0].IterateRange(res, distances[0])) {
         bool discarded = false;
         var rad = res.CoveringRadius;
         for (int i = 1; i < m; ++i) {
             var node = sortedNodes [i];
             if (node.Discarded (objID, rad, distances [i])) {
                 discarded = true;
                 break;
             }
         }
         if (discarded) {
             continue;
         }
         var d = this.DB.Dist(q, this.DB[objID]);
         res.Push (objID, d);
     }
     return res;
 }
开发者ID:sadit,项目名称:natix,代码行数:31,代码来源:Spaghetti.cs

示例6: SearchKNN

        public override IResult SearchKNN(object q, int K, IResult final_result)
        {
            var window = 2;
            if (this.Vertices.Count > 16) {
                window = 4;
            }
            var prev = double.MaxValue;
            var curr = 0.0;
            var inserted = new HashSet<int> ();
            var expanded = new HashSet<int> ();

            while (prev > curr) {
                prev = final_result.CoveringRadius;
                for (int i = 0; i < window; ++i) {
                    var res = new Result (K);
                    var next = this.rand.Next (this.Vertices.Count);
                    if (expanded.Add(next)) {
                        this.GreedySearch (q, next, expanded, res);
                        foreach (var p in res) {
                            if (inserted.Add(p.ObjID)) {
                                final_result.Push(p.ObjID, p.Dist);
                            }
                        }
                    }
                }
                curr = final_result.CoveringRadius;
            }
            return final_result;
        }
开发者ID:sadit,项目名称:natix,代码行数:29,代码来源:LocalSearchRestarts.cs

示例7: FirstBeam

 protected override Result FirstBeam(object q, HashSet<int> evaluated, IResult res)
 {
     int samplesize = 0;
     // the real value can bee really complex, Monte Carlo methods
     // just use the larger sustainable value, however we are interested
     // on keep a fixed upper bound
     if (this.Vertices.Count > 4) {
         if (this.Vertices.Count < 10000) {
             samplesize = (int) Math.Sqrt (this.Vertices.Count) * 2;
         } else {
             samplesize = 1000;
         }
     }
     // int samplesize = Math.Min (2, this.Vertices.Count);
     int beamsize = Math.Min (this.BeamSize, this.Vertices.Count);
     var beam = new Result (beamsize);
     // initializing the first beam
     for (int i = 0; i < samplesize; ++i) {
         var docID = this.Vertices.GetRandom().Key;
         if (evaluated.Add (docID)) {
             var d = this.DB.Dist (q, this.DB [docID]);
             beam.Push (docID, d);
             res.Push(docID, d);
         }
     }
     return beam;
 }
开发者ID:sadit,项目名称:natix,代码行数:27,代码来源:LocalSearchMontecarloBeam.cs

示例8: GreedySearchGlobalMinima

 //, Result C)
 protected void GreedySearchGlobalMinima(int parent, object q, IResult res)
 {
     var rs = this.SEQ.Unravel (parent);
     var children_count = rs.Count1;
     var closer_dist = double.MaxValue;
     var closer_objID = -1;
     for (int rank = 1; rank <= children_count; ++rank) {
         var objID = rs.Select1(rank);
         var dist = this.DB.Dist(q, this.DB[objID]);
         res.Push (objID, dist);
         if (dist < closer_dist) {
             closer_dist = dist;
             closer_objID = objID;
         }
         //if (C != null) C.Push (objID, dist);
     }
     if (closer_objID >= 0) {
         this.GreedySearchGlobalMinima (closer_objID, q, res); //, C);
     }
     //			for (int childID = 0; childID < children_count; ++childID) {
     //				var child_objID = C[childID];
     //				var child_dist = D[childID];
     //				var radius = res.CoveringRadius;
     //				//Console.WriteLine ("---- cov: {0}", this.COV[child_objID]);
     //				if (child_dist <= radius + this.GetCOV(child_objID) && child_dist <= closer_dist + radius + radius) {
     //					this.SearchKNNNode(child_objID, q, res);
     //                }
     //            }
 }
开发者ID:sadit,项目名称:natix,代码行数:30,代码来源:SATSEQ_ApproxSearch.cs

示例9: SearchKNN

 /// <summary>
 /// KNN Search
 /// </summary>
 public override IResult SearchKNN(object q, int k, IResult R)
 {
     int L = this.DB.Count;
     for (int docid = 0; docid < L; docid++) {
         double d = this.DB.Dist (q, this.DB[docid]);
         R.Push (docid, d);
     }
     return R;
 }
开发者ID:sadit,项目名称:natix,代码行数:12,代码来源:Sequential.cs

示例10: SearchKNN

 public override IResult SearchKNN(object q, int K, IResult res)
 {
     var n = this.DB.Count;
     for (int i = 0; i < this.SampleSize; ++i) {
         var objID = this.rand.Next (0, n);
         var d = this.DB.Dist (q, this.DB [objID]);
         res.Push (objID, d);
     }
     return res;
 }
开发者ID:sadit,项目名称:natix,代码行数:10,代码来源:RandomizedSearch.cs

示例11: SearchKNN

 public override IResult SearchKNN(object q, int K, IResult res)
 {
     if (this.root == null) {
         return res;
     }
     var dist_root = this.DB.Dist(q, this.DB[this.root.objID]);
     res.Push(this.root.objID, dist_root);
     if (this.root.Children.Count > 0) {
         this.SearchKNNNode (this.root, q, res);
     }
     return res;
 }
开发者ID:KeithNel,项目名称:natix,代码行数:12,代码来源:SAT_ApproxSearch.cs

示例12: ApproxSearchKNNNode

 protected void ApproxSearchKNNNode(Node node, object q, IResult res)
 {
     // res.Push (node.objID, dist);
     var D = new double[node.Children.Count];
     var closer_child = node.Children[0];
     var closer_dist = this.DB.Dist(q, this.DB[closer_child.objID]);
     res.Push(closer_child.objID, closer_dist);
     D[0] = closer_dist;
     for (int i = 1; i < D.Length; ++i) {
         var child = node.Children[i];
         D[i] = this.DB.Dist(q, this.DB[child.objID]);
         res.Push(child.objID, D[i]);
         if (D[i] < closer_dist) {
             closer_dist = D[i];
             closer_child = child;
         }
     }
     if (closer_child.Children.Count > 0) {
         this.ApproxSearchKNNNode (closer_child, q, res);
     }
 }
开发者ID:sadit,项目名称:natix,代码行数:21,代码来源:SAT_ApproxSearch.cs

示例13: ExpandNode

 protected void ExpandNode(object q, IResult res, int startID, SearchState state, int level)
 {
     var nodeS = this.Vertices [startID];
     foreach (var nodeID in nodeS) {
         if (state.visited.Add(nodeID)) {
             if (level > 0) {
                 this.ExpandNode (q, res, nodeID, state, level - 1);
             }
         }
         if (state.evaluated.Add (nodeID)) {
             var d = this.DB.Dist (q, this.DB [nodeID]);
             res.Push(nodeID, d);
         }
     }
 }
开发者ID:sadit,项目名称:natix,代码行数:15,代码来源:ApproxGraphNearExpand.cs

示例14: SearchKNN

 public override IResult SearchKNN(object q, int K, IResult res)
 {
     var visited = new HashSet<int> ();
     var evaluated = new HashSet<int> ();
     for (int i = 0; i < this.RepeatSearch; ++i) {
         var objID = this.rand.Next (this.Vertices.Count);
         while (visited.Add (objID)) {
             if (evaluated.Add (objID)) {
                 var d = this.DB.Dist (this.DB [objID], q);
                 res.Push (objID, d);
             }
             this.GreedySearch(q, res, visited, evaluated, objID);
         }
     }
     return res;
 }
开发者ID:sadit,项目名称:natix,代码行数:16,代码来源:ApproxGraphSeq.cs

示例15: FirstBeam

 protected override Result FirstBeam(object q, IResult final_result, SearchState state)
 {
     int samplesize = Math.Min (1024, this.Vertices.Count);
     //WARNING fixing the parameter beamsize for construction step for testing purposes
     int beamsize = Math.Min (this.BeamSize, this.Vertices.Count);
     var beam = new Result (beamsize);
     // initializing the first beam
     for (int i = 0; i < samplesize; ++i) {
         var docID = this.rand.Next(this.Vertices.Count);
         if (state.evaluated.Add (docID)) {
             var d = this.DB.Dist (q, this.DB [docID]);
             beam.Push (docID, d);
             final_result.Push(docID, d);
         }
     }
     return beam;
 }
开发者ID:KeithNel,项目名称:natix,代码行数:17,代码来源:ApproxGraphLocalBeamKNR.cs


注:本文中的IResult.Push方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。