public SampleControllerTests()
        {
            var client    = _factory.CreateClient();
            var requester = new Requester(client)
            {
                RequestQueryParamSerializer = new ComplexTypeRequestQueryParamSerializer(),
            };

            _controller = RestClient.For <ISampleController>(requester);
        }
Пример #2
0
    private void PrepareSamples()
    {
        LoadComboBox(cmbSample, TypeHelper.GetDisplayNamesByInterface <ISampleController>());
        m_sampleController = TypeHelper.CreateInstanceByName <ISampleController>(cmbSample.ActiveText);

        // Sample context.
        var layout = new Pango.Layout(this.PangoContext);

        layout.Alignment       = Pango.Alignment.Center;
        layout.FontDescription = Pango.FontDescription.FromString("Arial 16");

        m_sampleContext = new SampleContext(drawingArea.GdkWindow, this)
        {
            Layout = layout
        };

        m_sampleContext.GC = m_sampleContext.CreateGC(new Gdk.Color(255, 50, 50));

        m_sampleController.Context       = m_sampleContext;
        m_sampleController.Reconfigured += delegate
        {
            ResetSample();
        };

        problemConfigWidgetContainer.Add(m_sampleController.CreateConfigWidget());
        problemConfigWidgetContainer.ShowAll();

        SetSampleOperatorsToComboxes();
        cmbSample.Changed += delegate
        {
            m_sampleController = TypeHelper.CreateInstanceByName <ISampleController>(cmbSample.ActiveText);
            SetSampleOperatorsToComboxes();

            m_sampleController.Context       = m_sampleContext;
            m_sampleController.Reconfigured += delegate
            {
                ResetSample();
            };

            if (problemConfigWidgetContainer.Children.Length > 0)
            {
                problemConfigWidgetContainer.Children[0].Destroy();
            }

            problemConfigWidgetContainer.Add(m_sampleController.CreateConfigWidget());
            problemConfigWidgetContainer.ShowAll();

            ResetBuffer();
            ResetSample();
        };
    }
        public SampleViewModel(INavigate <Regions.TabRegion> router, ISampleController controller)
        {
            if (router == null)
            {
                throw new ArgumentNullException("router", "router is null.");
            }
            if (controller == null)
            {
                throw new ArgumentNullException("controller", "controller is null.");
            }

            _router     = router;
            _controller = controller;
        }
Пример #4
0
 public SampleRouter(ILogger <SampleRouter> logger, ISampleController sampleController)
 {
     _logger           = logger;
     _sampleController = sampleController;
 }
Пример #5
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine("GeneticSharp - ConsoleApp");
            Console.ResetColor();
            Console.WriteLine("Select the sample:");
            Console.WriteLine("1) TSP (Travelling Salesman Problem)");
            Console.WriteLine("2) Ghostwriter");
            var sampleNumber = Console.ReadLine();
            ISampleController sampleController = null;

            switch (sampleNumber)
            {
            case "1":
                sampleController = new TspSampleController(20);
                break;

            case "2":
                sampleController = new GhostwriterSampleController();
                break;

            default:
                return;
            }

            var selection  = new EliteSelection();
            var crossover  = new UniformCrossover();
            var mutation   = new UniformMutation(true);
            var fitness    = sampleController.CreateFitness();
            var population = new Population(50, 70, sampleController.CreateChromosome());

            var ga = new GeneticAlgorithm(population, fitness, selection, crossover, mutation);

            ga.MutationProbability = 0.4f;
            ga.Termination         = new FitnessStagnationTermination(100);

            ga.TaskExecutor = new SmartThreadPoolTaskExecutor()
            {
                MinThreads = 25,
                MaxThreads = 50
            };

            ga.GenerationRan += delegate
            {
                Console.CursorLeft = 0;
                Console.CursorTop  = 5;

                var bestChromosome = ga.Population.BestChromosome;
                Console.WriteLine("Generations: {0}", ga.Population.GenerationsNumber);
                Console.WriteLine("Fitness: {0:n4}", bestChromosome.Fitness);
                Console.WriteLine("Time: {0}", ga.TimeEvolving);
                sampleController.Draw(bestChromosome);
            };

            try
            {
                ga.Start();
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.WriteLine();
                Console.WriteLine("Error: {0}", ex.Message);
                Console.ResetColor();
                Console.ReadKey();
                return;
            }

            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine();
            Console.WriteLine("Evolved.");
            Console.ResetColor();
            Console.ReadKey();
        }
Пример #6
0
 public SecondStepModel(ISampleController sampleController)
 {
     _sampleController = sampleController;
 }
Пример #7
0
 public IndexModel(IClientController clientController, ISampleController sampleController, IReportController reportController)
 {
     _clientController = clientController;
     _sampleController = sampleController;
     _reportController = reportController;
 }