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


C# Problem类代码示例

本文整理汇总了C#中Problem的典型用法代码示例。如果您正苦于以下问题:C# Problem类的具体用法?C# Problem怎么用?C# Problem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testGreedyBestFirstSearch

	public void testGreedyBestFirstSearch() {
		try {
			// EightPuzzleBoard extreme = new EightPuzzleBoard(new int[]
			// {2,0,5,6,4,8,3,7,1});
			// EightPuzzleBoard extreme = new EightPuzzleBoard(new int[]
			// {0,8,7,6,5,4,3,2,1});
			EightPuzzleBoard board = new EightPuzzleBoard(new int[] { 7, 1, 8,
					0, 4, 6, 2, 3, 5 });

			Problem problem = new Problem(board, EightPuzzleFunctionFactory
					.getActionsFunction(), EightPuzzleFunctionFactory
					.getResultFunction(), new EightPuzzleGoalTest());
			Search search = new GreedyBestFirstSearch(new GraphSearch(),
					new ManhattanHeuristicFunction());
			SearchAgent agent = new SearchAgent(problem, search);
			Assert.assertEquals(49, agent.getActions().size());
			Assert.assertEquals("197", agent.getInstrumentation().getProperty(
					"nodesExpanded"));
			Assert.assertEquals("140", agent.getInstrumentation().getProperty(
					"queueSize"));
			Assert.assertEquals("141", agent.getInstrumentation().getProperty(
					"maxQueueSize"));
		} catch (Exception e) {
			e.printStackTrace();
			Assert.fail("Exception thrown.");
		}
	}
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:27,代码来源:GreedyBestFirstSearchTest.cs

示例2: Check

        public override ProblemCollection Check(TypeNode type)
        {
            Type runtimeType = type.GetRuntimeType();

            if ( IsTestFixture( runtimeType ) )
            {
                string ignoreReason = Reflect.GetIgnoreReason( runtimeType );
                if ( ignoreReason.Trim().Length == 0 )
                {
                    Resolution resolution = GetNamedResolution( "TestFixture", type.Name.Name );
                    Problem problem = new Problem( resolution );
                    base.Problems.Add( problem );
                }

                System.Reflection.MethodInfo[] methods = runtimeType.GetMethods( BindingFlags.Instance | BindingFlags.Public );
                foreach( MethodInfo method in methods )
                {
                    string methodIgnoreReason = Reflect.GetIgnoreReason( method );
                    if ( methodIgnoreReason.Trim().Length == 0 )
                    {
                        string[] parameters = new string[] { type.Name.Name, method.Name };
                        Resolution resolution = GetNamedResolution( "TestCase", parameters );
                        Problem problem = new Problem( resolution );
                        base.Problems.Add( problem );
                    }
                }

                if ( base.Problems.Count > 0 )
                    return base.Problems;
            }

            return base.Check (type);
        }
开发者ID:vboctor,项目名称:FxCop4NUnit,代码行数:33,代码来源:IgnoreReasonShouldNotBeEmptyRule.cs

示例3: Validate

        public override IEnumerable<Problem> Validate(Dictionary<Guid, SitecoreDeployInfo> projectItems, XDocument scprojDocument)
        {
            //loop through each item in the TDS project
            foreach (var item in projectItems)
            {
                //check that the item path starts with a value specified in the Additional Properties list
                //otherwise we just ignore the item
                if (Settings.Properties.Any(
                        x => item.Value.Item.SitecoreItemPath.StartsWith(x, StringComparison.InvariantCultureIgnoreCase)))
                {

                    var fld = item.Value.ParsedItem.Fields["Initial State"];

                    if (fld != null && fld == String.Empty)
                    {
                        //when a problem is found get the position of it in the TDS project file
                        ProblemLocation position = GetItemPosition(scprojDocument, item.Value.Item);

                        //create a report which will be displayed in the Visual Studio Error List
                        Problem report = new Problem(this, position)
                        {
                            Message = string.Format("This workflow is missing an intial state: {0}", item.Value.ParsedItem.Path)
                        };

                        yield return report;
                    }

                }
            }
        }
开发者ID:fasterwithkeystone,项目名称:Keystone4SitecoreTDSValidators,代码行数:30,代码来源:InitialState.cs

示例4: Solve

        public override Solution Solve(Problem problem)
        {
            var specimens = GenerateRandomPopulation(problem);
            var bestSpecimen = FindBestSpecimen(specimens).Clone();

            for (var i = 0; i < config.numberOfIterations; i++)
            {
                specimens = specimens.OrderBy(o => o.Value).ToList();
                var nextPopulation = specimens.Take(config.specimenPoolSize / 4).ToList();
                for (var j = 0; j < config.specimenPoolSize / 4; j++)
                {
                    nextPopulation.Add(new Specimen(problem, random));
                }

                nextPopulation.AddRange(
                    specimens.Shuffle(random)
                             .Take(specimens.Count / 2)
                             .AsQueryable()
                             .Zip(specimens,
                                  (a, b) => mutation.Execute(crossover.Execute(a, b))));
                //                    nextPopulation.Add(Mutation.Execute(Crossover.Execute(_specimens[j], _specimens[j + 1])));
                //                }
                specimens = nextPopulation;
                bestSpecimen = FindBestSpecimen(specimens).Clone();

                //Console.Error.WriteLine(string.Format("  {0}", bestSpecimen.Value));
            }

            return bestSpecimen;
        }
开发者ID:althardaine,项目名称:trains,代码行数:30,代码来源:DefaultSolver.cs

示例5: VisitCall

        /// <summary>
        /// Visits the call.
        /// </summary>
        /// <param name="destination">The destination.</param>
        /// <param name="receiver">The receiver.</param>
        /// <param name="callee">The callee.</param>
        /// <param name="arguments">The arguments.</param>
        /// <param name="isVirtualCall">if set to <c>true</c> [is virtual call].</param>
        /// <param name="programContext">The program context.</param>
        /// <param name="stateBeforeInstruction">The state before instruction.</param>
        /// <param name="stateAfterInstruction">The state after instruction.</param>
        public override void VisitCall(
            Variable destination, 
            Variable receiver, 
            Method callee, 
            ExpressionList arguments, 
            bool isVirtualCall, 
            Microsoft.Fugue.IProgramContext programContext, 
            Microsoft.Fugue.IExecutionState stateBeforeInstruction, 
            Microsoft.Fugue.IExecutionState stateAfterInstruction)
        {
            if ((callee.DeclaringType.GetRuntimeType() == typeof(X509ServiceCertificateAuthentication) ||
                 callee.DeclaringType.GetRuntimeType() == typeof(X509ClientCertificateAuthentication)) &&
                 (callee.Name.Name.Equals("set_CertificateValidationMode", StringComparison.InvariantCultureIgnoreCase)))
            {
                IAbstractValue value = stateBeforeInstruction.Lookup((Variable)arguments[0]);
                IIntValue intValue = value.IntValue(stateBeforeInstruction);

                if (intValue != null)
                {
                    X509CertificateValidationMode mode = (X509CertificateValidationMode)intValue.Value;
                    if (mode != X509CertificateValidationMode.ChainTrust)
                    {
                        Resolution resolution = base.GetResolution(mode.ToString(), 
                            X509CertificateValidationMode.ChainTrust.ToString());
                        Problem problem = new Problem(resolution, programContext);
                        base.Problems.Add(problem);
                    }
                }
            }

            base.VisitCall(destination, receiver, callee, arguments, isVirtualCall, programContext, stateBeforeInstruction, stateAfterInstruction);
        }
开发者ID:Phidiax,项目名称:open-wssf-2015,代码行数:43,代码来源:CertificateValidationMode.cs

示例6: Check

        public override ProblemCollection Check(TypeNode type)
        {
            Type runtimeType = type.GetRuntimeType();
            if ( IsTestFixture( runtimeType ) )
            {
                System.Reflection.MethodInfo[] methods = runtimeType.GetMethods( BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly );

                // Note that if an method with an invalid signature is marked as a setup method, then
                // it will be considered as not marked and hence setupMethod will be null.
                // Same applies for tearDownMethod.
                System.Reflection.MethodInfo setupMethod = Reflect.GetSetUpMethod( runtimeType );
                System.Reflection.MethodInfo tearDownMethod = Reflect.GetTearDownMethod( runtimeType );
                System.Reflection.MethodInfo fixtureSetupMethod = Reflect.GetFixtureSetUpMethod( runtimeType );
                System.Reflection.MethodInfo fixtureTearDownMethod = Reflect.GetFixtureTearDownMethod( runtimeType );

                foreach( System.Reflection.MethodInfo methodInfo in methods )
                {
                    if ( !IsTestCaseMethod( methodInfo ) &&
                         ( methodInfo != setupMethod ) &&
                         ( methodInfo != tearDownMethod ) &&
                         ( methodInfo != fixtureSetupMethod ) &&
                         ( methodInfo != fixtureTearDownMethod ) )
                    {
                        Resolution resolution = GetResolution( methodInfo.Name );
                        Problem problem = new Problem( resolution );
                        base.Problems.Add( problem );
                    }
                }

                if ( base.Problems.Count > 0 )
                    return base.Problems;
            }

            return base.Check (type);
        }
开发者ID:vboctor,项目名称:FxCop4NUnit,代码行数:35,代码来源:TestFixturesPublicMethodsShouldBeMarkedRule.cs

示例7: Check

        public override ProblemCollection Check(TypeNode type)
        {
            Type runtimeType = type.GetRuntimeType();
            if ( IsTestFixture( runtimeType ) )
            {
                System.Reflection.MethodInfo[] methods = runtimeType.GetMethods();

                foreach( System.Reflection.MethodInfo methodInfo in methods )
                {
                    // if method starts with "test" and is not marked as [Test],
                    // then an explicit [Test] should be added since NUnit will
                    // treat it as a test case.
                    if ( IsTestCaseMethod( methodInfo ) && !Reflect.HasTestAttribute( methodInfo ) )
                    {
                        Resolution resolution = GetResolution( methodInfo.Name );
                        Problem problem = new Problem( resolution );
                        base.Problems.Add( problem );
                    }
                }

                if ( base.Problems.Count > 0 )
                    return base.Problems;
            }

            return base.Check (type);
        }
开发者ID:vboctor,项目名称:FxCop4NUnit,代码行数:26,代码来源:TestCasesShouldBeMarkedWithTestCaseAttributeRule.cs

示例8: Check

        public override ProblemCollection Check(TypeNode type)
        {
            Type runtimeType = type.GetRuntimeType();
            if ( IsTestFixture( runtimeType ) && !runtimeType.IsAbstract && type.IsVisibleOutsideAssembly )
            {
                MemberList constructors = type.GetConstructors();

                for ( int i = 0; i < constructors.Length; ++i )
                {
                    Member constructor = constructors[i];

                    // only examine non-static constructors
                    Microsoft.Cci.InstanceInitializer instanceConstructor =
                        constructor as Microsoft.Cci.InstanceInitializer;

                    if ( instanceConstructor == null )
                        continue;

                    // trigger errors for non-default constructors.
                    if ( ( instanceConstructor.Parameters.Length != 0 ) &&
                         ( !instanceConstructor.IsPrivate ) )
                    {
                        Resolution resolution = GetResolution( runtimeType.Name );
                        Problem problem = new Problem( resolution );
                        base.Problems.Add( problem );
                    }
                }

                if ( base.Problems.Count > 0 )
                    return base.Problems;
            }

            return base.Check (type);
        }
开发者ID:vboctor,项目名称:FxCop4NUnit,代码行数:34,代码来源:TestFixturesShouldOnlyContainDefaultConstructorsRule.cs

示例9: btnSubmit_Click

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        Problem pro = new Problem();
        pro.Description = txtProblemDesc.Text;
        pro.Date = DateTime.Now;
        pro.Location = txtLocation.Text;

        //string filePath = fileUploadImage.PostedFile.FileName;
        //string filename = Path.GetFileName(filePath);
        //string ext = Path.GetExtension(filename);
        //string contenttype = String.Empty;

        //if (contenttype != String.Empty)
        //{
            string fileName = Path.GetFileName(fileUploadImage.PostedFile.FileName);
            Stream fs = fileUploadImage.PostedFile.InputStream;
            BinaryReader br = new BinaryReader(fs);
            Byte[] bytes = br.ReadBytes((Int32)fs.Length);

            pro.Photo = bytes;
        //}

        if(p.InsertProblem(pro) == true)
        {
            Response.Write("Added");
            txtProblemDesc.Text = "";
            txtLocation.Text = "";

        }
    }
开发者ID:Afikile,项目名称:Batsamayi,代码行数:30,代码来源:Default.aspx.cs

示例10: MESH

        /// <summary>
        /// Construct the object.
        /// </summary>
        /// <param name="mask">Fix certain parameters or leave null.</param>
        /// <param name="problem">Problem to optimize.</param>
        public MESH(double?[] mask, Problem problem)
            : base(problem)
        {
            Debug.Assert(mask == null || mask.Length == problem.Dimensionality);

            Mask = mask;
        }
开发者ID:DanWBR,项目名称:dwsim3,代码行数:12,代码来源:MESH.cs

示例11: testAStarSearch

	public void testAStarSearch() {
		// added to narrow down bug report filed by L.N.Sudarshan of
		// Thoughtworks and Xin Lu of UCI
		try {
			// EightPuzzleBoard extreme = new EightPuzzleBoard(new int[]
			// {2,0,5,6,4,8,3,7,1});
			// EightPuzzleBoard extreme = new EightPuzzleBoard(new int[]
			// {0,8,7,6,5,4,3,2,1});
			EightPuzzleBoard board = new EightPuzzleBoard(new int[] { 7, 1, 8,
					0, 4, 6, 2, 3, 5 });

			Problem problem = new Problem(board, EightPuzzleFunctionFactory
					.getActionsFunction(), EightPuzzleFunctionFactory
					.getResultFunction(), new EightPuzzleGoalTest());
			Search search = new AStarSearch(new GraphSearch(),
					new ManhattanHeuristicFunction());
			SearchAgent agent = new SearchAgent(problem, search);
			Assert.assertEquals(23, agent.getActions().size());
			Assert.assertEquals("926", agent.getInstrumentation().getProperty(
					"nodesExpanded"));
			Assert.assertEquals("534", agent.getInstrumentation().getProperty(
					"queueSize"));
			Assert.assertEquals("535", agent.getInstrumentation().getProperty(
					"maxQueueSize"));
		} catch (Exception e) {
			e.printStackTrace();
			Assert.fail("Exception thrown");
		}
	}
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:29,代码来源:AStarSearchTest.cs

示例12: Validate

        public override IEnumerable<Problem> Validate(Dictionary<Guid, SitecoreDeployInfo> projectItems, XDocument scprojDocument)
        {
            //loop through each item in the TDS project
            foreach (var item in projectItems)
            {
                //check that the item path starts with a value specified in the Additional Properties list
                //otherwise we just ignore the item
                if (Settings.Properties.Any(
                        x => item.Value.Item.SitecoreItemPath.StartsWith(x, StringComparison.InvariantCultureIgnoreCase)))
                {

                    var editable = item.Value.ParsedItem.Fields["Editable"];
                    var datasourcelocation = item.Value.ParsedItem.Fields["Datasource Location"];

                    if (!string.IsNullOrEmpty(datasourcelocation) && editable != null && editable == String.Empty)
                    {

                        //when a problem is found get the position of it in the TDS project file
                        ProblemLocation position = GetItemPosition(scprojDocument, item.Value.Item);

                        //create a report which will be displayed in the Visual Studio Error List
                        Problem report = new Problem(this, position)
                        {
                            Message =
                                string.Format("A datasource driven sublayout must have it's 'Editable' setting checked: {0}",
                                    item.Value.ParsedItem.Path)
                        };

                        yield return report;

                    }

                }
            }
        }
开发者ID:fasterwithkeystone,项目名称:Keystone4SitecoreTDSValidators,代码行数:35,代码来源:EditableWithDatasourceRequired.cs

示例13: AddReasoningActions

 //problem - we have to be over restrictive:
 //(xor a b c) + know(a) + know(b) = know(c)
 private void AddReasoningActions(Problem p)
 {
     foreach (CompoundFormula cf in p.Hidden)
     {
         Actions.AddRange(CreateReasoningActions(cf));
     }
 }
开发者ID:dorin16s,项目名称:Planning--Network-Attack,代码行数:9,代码来源:KnowledgeDomain.cs

示例14: SolveReturnsAllSolutions

        public void SolveReturnsAllSolutions()
        {
            var problem = new Problem();
            var algorithm = new DepthFirstSearchAlgorithm();

            var solutions = algorithm.Solve(problem);
        }
开发者ID:JonHaywood,项目名称:PegBoard,代码行数:7,代码来源:DepthFirstSearchTests.cs

示例15: CollectEntityByID

 void CollectEntityByID(MooDB db, int id)
 {
     problem = (from p in db.Problems
                where p.ID == id
                select p).SingleOrDefault<Problem>();
     revision = problem == null ? null : problem.LatestSolution;
 }
开发者ID:MooDevTeam,项目名称:MooOJ,代码行数:7,代码来源:Default.aspx.cs


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