/// <summary>
        /// Adds the specified node to the open nodes collection.
        /// </summary>
        /// <param name="node">Node to be added.</param>
        /// <param name="gValue">Calculated distance from the start.</param>
        /// <param name="predecessor">Predecessor node.</param>
        /// <param name="appliedOperator">Predecessor operator.</param>
        protected override void AddToOpenNodes(ISearchNode node, int gValue, ISearchNode predecessor, IOperator appliedOperator)
        {
            if (gValue > LimitValue)
            {
                return;
            }

            NodeInfo nodeInfo;

            if (NodesInfo.TryGetValue(node, out nodeInfo))
            {
                if (nodeInfo.GValue > gValue)
                {
                    nodeInfo.GValue      = gValue;
                    nodeInfo.Predecessor = Tuple.Create(predecessor, appliedOperator);
                    NodesInfo[node]      = nodeInfo;

                    double hValue = Heuristic.GetValue(node);
                    OpenNodes.Add(gValue + hValue, node);
                }
            }
            else
            {
                double hValue = Heuristic.GetValue(node);
                double fValue = gValue + hValue;
                if (fValue > LimitValue)
                {
                    LowestValueOverLimit = Math.Min(LowestValueOverLimit, fValue);
                    return;
                }
                NodesInfo.Add(node, new NodeInfo(gValue, Tuple.Create(predecessor, appliedOperator)));
                OpenNodes.Add(fValue, node);
            }
        }
Beispiel #2
0
 private NodeInfoResponse _NodeInfo(string path, NodesInfo nodesInfo)
 {
     if (nodesInfo.HasFlag(NodesInfo.All))
     {
         path += "?all=true";
     }
     else
     {
         var options = new List<string>();
         if (nodesInfo.HasFlag(NodesInfo.Settings))
             options.Add("settings=true");
         if (nodesInfo.HasFlag(NodesInfo.OS))
             options.Add("os=true");
         if (nodesInfo.HasFlag(NodesInfo.Process))
             options.Add("process=true");
         if (nodesInfo.HasFlag(NodesInfo.JVM))
             options.Add("jvm=true");
         if (nodesInfo.HasFlag(NodesInfo.ThreadPool))
             options.Add("thread_pool=true");
         if (nodesInfo.HasFlag(NodesInfo.Network))
             options.Add("network=true");
         if (nodesInfo.HasFlag(NodesInfo.Transport))
             options.Add("transport=true");
         if (nodesInfo.HasFlag(NodesInfo.HTTP))
             options.Add("http=true");
         path += "?" + string.Join("&", options);
     }
     var status = this.Connection.GetSync(path);
     var r = this.Deserialize<NodeInfoResponse>(status);
     return r;
 }
 /// <summary>
 /// Sets the initial search node of the search procedure.
 /// </summary>
 /// <param name="initialNode">Initial node of the search.</param>
 protected override void SetInitialNode(ISearchNode initialNode)
 {
     foreach (var item in OpenLists)
     {
         item.Add(0, initialNode);
         ++AllOpenNodesCount;
     }
     NodesInfo.Add(initialNode, new NodeInfo(0, null));
 }
        private NodeInfoResponse _NodeInfo(string path, NodesInfo nodesInfo)
        {
            if (nodesInfo.HasFlag(NodesInfo.All))
            {
                path += "?all=true";
            }
            else
            {
                var options = new List <string>();
                if (nodesInfo.HasFlag(NodesInfo.Settings))
                {
                    options.Add("settings=true");
                }
                if (nodesInfo.HasFlag(NodesInfo.OS))
                {
                    options.Add("os=true");
                }
                if (nodesInfo.HasFlag(NodesInfo.Process))
                {
                    options.Add("process=true");
                }
                if (nodesInfo.HasFlag(NodesInfo.JVM))
                {
                    options.Add("jvm=true");
                }
                if (nodesInfo.HasFlag(NodesInfo.ThreadPool))
                {
                    options.Add("thread_pool=true");
                }
                if (nodesInfo.HasFlag(NodesInfo.Network))
                {
                    options.Add("network=true");
                }
                if (nodesInfo.HasFlag(NodesInfo.Transport))
                {
                    options.Add("transport=true");
                }
                if (nodesInfo.HasFlag(NodesInfo.HTTP))
                {
                    options.Add("http=true");
                }
                path += "?" + string.Join("&", options);
            }
            var status = this.Connection.GetSync(path);
            var r      = this.Deserialize <NodeInfoResponse>(status);

            return(r);
        }
Beispiel #5
0
        /// <summary>
        /// Adds the specified node to the open nodes collection.
        /// </summary>
        /// <param name="node">Node to be added.</param>
        /// <param name="gValue">Calculated distance from the start.</param>
        /// <param name="hValue">Heuristic distance to the goal.</param>
        /// <param name="predecessor">Predecessor node.</param>
        /// <param name="appliedOperator">Predecessor operator.</param>
        protected void AddToOpenNodes(ISearchNode node, int gValue, double hValue, ISearchNode predecessor, IOperator appliedOperator)
        {
            NodeInfo nodeInfo;

            if (NodesInfo.TryGetValue(node, out nodeInfo))
            {
                if (nodeInfo.GValue > gValue)
                {
                    nodeInfo.GValue      = gValue;
                    nodeInfo.Predecessor = Tuple.Create(predecessor, appliedOperator);
                    NodesInfo[node]      = nodeInfo;

                    OpenNodes.Add(gValue + hValue, node);
                }
            }
            else
            {
                NodesInfo.Add(node, new NodeInfo(gValue, Tuple.Create(predecessor, appliedOperator)));
                OpenNodes.Add(gValue + hValue, node);
            }
        }
Beispiel #6
0
 /// <summary>
 /// Gets the health status of the cluster, for the specified nodes.
 /// </summary>
 public INodeInfoResponse NodeInfo(IEnumerable<string> nodes, NodesInfo nodesInfo)
 {
     var path = this.PathResolver.CreateNodePath(nodes);
     return _NodeInfo(path, nodesInfo);
 }
Beispiel #7
0
 /// <summary>
 /// Gets the health status of the cluster.
 /// </summary>
 public INodeInfoResponse NodeInfo(NodesInfo nodesInfo)
 {
     var path = this.PathResolver.CreateNodePath();
     return _NodeInfo(path, nodesInfo);
 }
Beispiel #8
0
 public void RecordData(List<ElectricityOriginalData> data)
 {
     NodesInfo node = new NodesInfo("NodesInfo.xml");
     foreach (ElectricityOriginalData electricityOriginalData in data)
     {
         node.RecordNodesInfo(electricityOriginalData);
     }
     node.Save();
 }
        /// <summary>
        /// Gets the health status of the cluster, for the specified nodes.
        /// </summary>
        public INodeInfoResponse NodeInfo(IEnumerable <string> nodes, NodesInfo nodesInfo)
        {
            var path = this.PathResolver.CreateNodePath(nodes);

            return(_NodeInfo(path, nodesInfo));
        }
        /// <summary>
        /// Gets the health status of the cluster.
        /// </summary>
        public INodeInfoResponse NodeInfo(NodesInfo nodesInfo)
        {
            var path = this.PathResolver.CreateNodePath();

            return(_NodeInfo(path, nodesInfo));
        }
Beispiel #11
0
        public virtual int AddCourseInfo(IudicoCourseInfo courseInfo)
        {
            var db = this.GetDbContext();

            CoursesInfo ci = new CoursesInfo
            {
                CourseId        = courseInfo.Id,
                OverallMaxScore = (float)courseInfo.OverallMaxScore
            };

            db.CoursesInfo.InsertOnSubmit(ci);
            db.SubmitChanges();

            foreach (IudicoNodeInfo nodeInfo in courseInfo.NodesInfo)
            {
                NodesInfo ni = new NodesInfo
                {
                    CourseId = courseInfo.Id,
                    NodeId   = nodeInfo.Id,
                    MaxScore = (float)nodeInfo.MaxScore
                };

                db.NodesInfo.InsertOnSubmit(ni);
                db.SubmitChanges();

                foreach (IudicoQuestionInfo questionInfo in nodeInfo.QuestionsInfo)
                {
                    QuestionsInfo qi = new QuestionsInfo
                    {
                        NodeId   = nodeInfo.Id,
                        Text     = questionInfo.QuestionText,
                        MaxScore = (float)questionInfo.MaxScore
                    };

                    switch (questionInfo.Type)
                    {
                    case IudicoQuestionType.IudicoSimple:
                        qi.Type = 1;
                        break;

                    case IudicoQuestionType.IudicoChoice:
                        qi.Type = 2;
                        break;

                    case IudicoQuestionType.IudicoCompile:
                        qi.Type = 3;
                        break;
                    }

                    db.QuestionsInfo.InsertOnSubmit(qi);
                    db.SubmitChanges();

                    switch (questionInfo.Type)
                    {
                    case IudicoQuestionType.IudicoSimple:
                        SimpleQuestion sq = new SimpleQuestion
                        {
                            QuestionId    = qi.Id,
                            CorrectAnswer = (questionInfo as IudicoSimpleQuestion).CorrectAnswer
                        };

                        db.SimpleQuestions.InsertOnSubmit(sq);
                        db.SubmitChanges();
                        break;

                    case IudicoQuestionType.IudicoChoice:
                        ChoiceQuestionsCorrectChoice cqcc = new ChoiceQuestionsCorrectChoice
                        {
                            QuestionId    = qi.Id,
                            CorrectChoice = (questionInfo as IudicoChoiceQuestion).CorrectChoice
                        };

                        db.ChoiceQuestionsCorrectChoices.InsertOnSubmit(cqcc);
                        db.SubmitChanges();

                        foreach (var option in (questionInfo as IudicoChoiceQuestion).Options)
                        {
                            ChoiceQuestionsOption cqo = new ChoiceQuestionsOption
                            {
                                QuestionId  = qi.Id,
                                Option      = option.Item1,
                                Description = option.Item2
                            };

                            db.ChoiceQuestionsOptions.InsertOnSubmit(cqo);
                            db.SubmitChanges();
                        }
                        break;

                    case IudicoQuestionType.IudicoCompile:
                        for (int i = 0; i < (questionInfo as IudicoCompiledTest).NumberOfTests; ++i)
                        {
                            CompiledTestQuestion ctq = new CompiledTestQuestion
                            {
                                QuestionId = qi.Id,
                                TestNumber = i,
                                TestInput  = (questionInfo as IudicoCompiledTest).TestInputs[i].Item2,
                                TestOutput = (questionInfo as IudicoCompiledTest).TestOutputs[i].Item2
                            };


                            db.CompiledTestQuestions.InsertOnSubmit(ctq);
                            db.SubmitChanges();
                        }
                        break;
                    }
                }
            }

            return(courseInfo.Id);
        }
Beispiel #12
0
 private void InitNodesTree()
 {
     NodeTreeCtr.GetStateImage += TreeList_GetStateImage;
     NodesInfo nodes = new NodesInfo("NodesInfo.xml");
     data = nodes.Nodes;
     selectedData = data[0];
     TreeListColumn column = NodeTreeCtr.Columns.Add();
     column.Caption = "电表位置";
     column.FieldName = "Name";
     column.Visible = true;
     TreeListColumn columnHasChildren = NodeTreeCtr.Columns.Add();
     columnHasChildren.Caption = "是否叶子节点";
     columnHasChildren.FieldName = "HasChildren";
     columnHasChildren.Visible = false;
     TreeListColumn columnID = NodeTreeCtr.Columns.Add();
     columnID.Caption = "MID";
     columnID.FieldName = "MID";
     columnID.Visible = false;
     NodeTreeCtr.DataSource = nodes.Nodes;
     NodeTreeCtr.ParentFieldName = "ParentID";
     NodeTreeCtr.KeyFieldName = "MID";
     NodeTreeCtr.ExpandAll();
     NodeTreeCtr.FocusedNode = NodeTreeCtr.Nodes[0];
 }
Beispiel #13
0
 private void barButtonItem1_ItemClick(object sender, ItemClickEventArgs e)
 {
     Calculate(NodeTreeCtr.Nodes[0], false);
     NodesInfo node = new NodesInfo("NodesInfo.xml");
     foreach (ElectricityOriginalData electricityOriginalData in data)
     {
         node.RecordNodesInfo(electricityOriginalData);
     }
     node.Save();
 }