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


C# IState.GetHashCode方法代码示例

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


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

示例1: AddOrGetExistingIntermediateNode

 public IIntermediateForestNode AddOrGetExistingIntermediateNode(IState trigger, int origin, int location)
 {
     var hash = trigger.GetHashCode();
     IIntermediateForestNode intermediateNode = null;
     if (_intermediateNodes.TryGetValue(hash, out intermediateNode))
         return intermediateNode;
     intermediateNode = new IntermediateForestNode(trigger, origin, location);
     _intermediateNodes.Add(hash, intermediateNode);
     return intermediateNode;
 }
开发者ID:bilsaboob,项目名称:Pliant,代码行数:10,代码来源:ForestNodeSet.cs

示例2: DefaultCoveragePointProvider

 /// <summary>
 /// Returns a bag containing a single coverage point that is a pair of integers 
 /// that are the hashcodes of the state and the action.
 /// </summary>
 static Bag<Term> DefaultCoveragePointProvider(IState state, CompoundTerm action)
 {
     return new Bag<Term>(new Pair<int, int>(state.GetHashCode(), action.GetHashCode()).AsTerm);
 }
开发者ID:juhan,项目名称:NModel,代码行数:8,代码来源:StrategyWithCoverage.cs

示例3: Update

 private void Update(IState iState, CompoundTerm action)
 {
     int hash = iState.GetHashCode();
     //System.Console.WriteLine("action taken "+ action.ToString());
     if (!cps.ContainsKey(hash))
         cps[hash] = new Set<int>();
     cps[hash] = cps[hash].Add(action.GetHashCode());
     /*
     foreach (Symbol s in this.ObservableActionSymbols)
     {
         System.Console.WriteLine(s);
     }*/
 }
开发者ID:juhan,项目名称:NModel,代码行数:13,代码来源:Algorithms.cs

示例4: findCoveredActs

 private Set<int> findCoveredActs(IState iState)
 {
     int hash = iState.GetHashCode();
     if (cps.ContainsKey(hash))
         return cps[hash];
     else
         return new Set<int> ();
 }
开发者ID:juhan,项目名称:NModel,代码行数:8,代码来源:Algorithms.cs

示例5: UpdateRequirementMaps

 private void UpdateRequirementMaps(Sequence<CompoundTerm> actions, IState iState)
 {
     Set<string> yesStrings = new Set<string>();
     foreach (Action a in actions)
     {
         System.Console.WriteLine(iState.GetHashCode() + a.ToString());
         foreach (string s in this.modelProgram.GetEnablingConditionDescriptions(iState, a, false))
         {
             yesStrings = yesStrings.Add(s);
             if (!requirementProperties.Contains(s))
             {
                 requirementProperties = requirementProperties.AddLast(s);
                 requireEnabledStateMap = requireEnabledStateMap.Add(s, Set<int>.EmptySet);
             }
             requireEnabledStateMap = requireEnabledStateMap.Override(s, requireEnabledStateMap[s].Add(iState.GetHashCode()));
         }
     }
     bdt = bdt.addState(yesStrings, iState.GetHashCode());
     if (i == 0)
     {
         if (i < requirementProperties.Count)
         {
             string s1 = requirementProperties[i++];
             bdt = bdt.Refine(s1, requireEnabledStateMap[s1]);
             bdt.PrintTree(0);
         }
     }            
 }
开发者ID:juhan,项目名称:NModel,代码行数:28,代码来源:AbstractMDP.cs

示例6: ChooseAction

        private CompoundTerm ChooseAction(Sequence<Action> actions, IState iState)
        {
            Action maxAct = actions.Head;
            int sState = iState.GetHashCode();
            int tState;
            IExtendedState iestate = (IExtendedState)iState;
            int c = iestate.LocationValuesCount;

            foreach (Action a in actions)
                foreach (string s in this.modelProgram.GetEnablingConditionDescriptions(iState, a, false))
                {
                    Term t = Term.Parse(s);
                    Sequence<Term> vars = (t.Arguments[0].Arguments);
                    Map<Variable, Term> subst = ConstructSubst(a,vars);
                    System.Console.WriteLine(a.ToString() + sState + " enabled string " + t.Arguments[1].Substitute(subst));
                }
            /*
            for (int i = 0; i < c; i++)
            {
                System.Console.WriteLine("name: "+iestate.GetLocationName(i) + " value : "+
                    iestate.GetLocationValue(i) + " hash" +
                    iestate.GetLocationValue(i).GetHashCode());
                CompoundValue t  = (CompoundValue)iestate.GetLocationValue(i);
                foreach (CompoundValue t1 in t.FieldValues())
                {
                    System.Console.WriteLine(" field " + t1.ToString());
                }
            }
            */

            TransitionProperties tp;
            int sum = 0;
            Sequence<Pair<int, Action>> cumulActSum = Sequence<Pair<int,Action>>.EmptySequence;

            Set<int> coveredActs = findCoveredActs(sState,actions);
             if(!cov.ContainsKey(sState))
                 cov[sState] = 0.0;
            Set<Action> newStateActs = new Set<Action>();
            Set<Action> newActs = new Set<Action>();
            Set<Action> oldActs = new Set<Action>(actions.Head);
            foreach (Action a in actions)
            {
                tState = this.modelProgram.GetTargetState(iState, a, null, out tp).GetHashCode();
                if (!v.ContainsKey(tState))
                {
                    newStateActs = newStateActs.Add(a);
                }
                else if (!coveredActs.Contains(a.GetHashCode()))
                {
                    newActs = newActs.Add(a);
                }
                else
                {
                    // one greedy approach
                    /*
                    if (v.ContainsKey(tState) && v[tState] > maxv)
                    {
                        maxv = v[tState];
                        oldActs = new Set<Action>(a);
                    }
                    else if (v.ContainsKey(tState) && v[tState] == maxv)
                    {
                        oldActs = oldActs.Add(a);
                    }*/

                    // probabilistic greedy approach
                    if (v.ContainsKey(tState))
                    {
                        sum = sum + (int)(v[tState]* Math.Pow(10.0,9.0));
                        Pair<int, Action> np = new Pair<int, Action>(sum, a);
                        cumulActSum = cumulActSum.AddLast(np);
                    }
                }
            }
            if (!newStateActs.IsEmpty)
            {
                maxAct = newStateActs.Choose();
                System.Console.WriteLine("new action in new state " + maxAct.ToString());
            }
            else if (!newActs.IsEmpty)
            {
                maxAct = newActs.Choose();
                System.Console.WriteLine("new action in old state " + maxAct.ToString());
            }
            else
            {
                //maxAct = oldActs.Choose();
                Random rndNumbers = new Random();
                int rndNumber = rndNumbers.Next(sum);
                System.Console.WriteLine(sum + " " + rndNumber);
                foreach (Pair<int, Action> np in cumulActSum)
                {
                    System.Console.WriteLine(np.First + " " + np.Second.ToString());
                    if (rndNumber <= np.First)
                    {
                        maxAct = np.Second;
                        break;
                    }
                    maxAct = np.Second;
                }
//.........这里部分代码省略.........
开发者ID:juhan,项目名称:NModel,代码行数:101,代码来源:ValueIteration.cs


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