Esempio n. 1
0
 static void Main()
 {
     try
     {
         Thor g = new Thor();
         CultureInfo.DefaultThreadCurrentCulture   = new CultureInfo("en-US");
         CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("en-US");
         Thread.CurrentThread.CurrentCulture       = new CultureInfo("en-US");
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         Application.Run(new Mainframe(g));
     }
     catch (TypeInitializationException)
     {
         Application.Run(new ErrorFrame("You need to Install R first!"));
         Console.WriteLine(@"Please Install R");
     }
     catch (Exception e)
     {
         if (e.Message.StartsWith("Error in library("))
         {
             Application.Run(new ErrorFrame("Install R Package: " + e.Message.Substring(e.Message.IndexOf('\''))));
             return;
         }
         Application.Run(new ErrorFrame("Unknown Error: " + e.Message));
     }
 }
 public ContainerThing(SpiderMan spiderMan, IronMan ironMan, TheHulk hulk, Thor thor)
 {
     _spiderMan = spiderMan;
     _ironMan   = ironMan;
     _hulk      = hulk;
     _thor      = thor;
 }
        /*public Distribution FeatureTarget { get; set; }
         * public Distribution InteractionTarget { get; set; }
         * public double[,] FeatureMatrix { get; set; }
         * public double[,] InteractionMatrix { get; set; }
         * private int _counter = 0;
         * private InterGen Model { get; set; } */

        public FeatAndInteractionProblem(Thor model) : base(model)
        {
            Model       = model;
            ProblemName = "FeatAndInteractionProblem";

            NumberOfObjectives = 2;
        }
Esempio n. 4
0
    private void Start()
    {
        Sentences = new Queue <string>();
        BeginText = ContinueButtonText.text;

        ThorInput = GameObject.Find("Thor").GetComponent <Thor>();
    }
Esempio n. 5
0
        public static bool Init(Thor model)
        {
            try
            {
                _model           = model;
                Engine.AutoPrint = false;

                Engine.Evaluate(".libPaths('./RPackages')");

                Engine.Evaluate("if (!require('ks')) install.packages('ks', lib='./RPackages',repos='https://cran.uni-muenster.de')");
                Engine.Evaluate("if (!require('ggplot2')) install.packages('ggplot2', lib='./RPackages',repos='https://cran.uni-muenster.de')");
                Engine.Evaluate("if (!require('scales')) install.packages('scales', lib='./RPackages',repos='https://cran.uni-muenster.de')");
                Engine.Evaluate("if (!require('gridExtra')) install.packages('gridExtra', lib='./RPackages',repos='https://cran.uni-muenster.de')");
                Engine.Evaluate("if (!require('scatterplot3d')) install.packages('scatterplot3d', lib='./RPackages',repos='https://cran.uni-muenster.de')");

                Engine.Evaluate("suppressMessages(require('ks', quietly=TRUE))");
                Engine.Evaluate("suppressMessages(library(ks,lib.loc='./RPackages'))");
                Engine.Evaluate("require('ggplot2', quietly=TRUE)");
                Engine.Evaluate("suppressMessages(library(ggplot2,lib.loc='./RPackages'))");
                Engine.Evaluate("require('scales', quietly=TRUE)");
                Engine.Evaluate("suppressMessages(library(scales,lib.loc='./RPackages'))");
                Engine.Evaluate("require(gridExtra)");
                Engine.Evaluate("suppressMessages(library(gridExtra,lib.loc='./RPackages'))");
                Engine.Evaluate("require(scatterplot3d)");
                Engine.Evaluate("suppressMessages(library(scatterplot3d,lib.loc='./RPackages'))");
                Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
                return(true);
            }
            catch (EvaluationException)
            {
                return(false);
            }
        }
Esempio n. 6
0
        //Electricity
        public override void OnBeginThorInteraction(Thor thor)
        {
            base.OnBeginThorInteraction(thor);

            //Clear the actions to prevent spawning multiple thor shots
            OnExplodeAction += () => { OnExplodeAction = default; };
        }
Esempio n. 7
0
 static void Main(string[] args)
 {
     try
     {
         string path;
         CultureInfo.DefaultThreadCurrentCulture   = new CultureInfo("en-US");
         CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("en-US");
         Thread.CurrentThread.CurrentCulture       = new CultureInfo("en-US");
         Console.WriteLine(" _____  _   _  _____ ______");
         Console.WriteLine("|_   _|| | | ||  _  || ___ \\ ");
         Console.WriteLine("  | |  | |_| || | | || |_/ /");
         Console.WriteLine("  | |  |  _  || | | ||    / ");
         Console.WriteLine("  | |  | | | |\\ \\_/ /| |\\ \\ ");
         Console.WriteLine("  \\_/  \\_| |_/ \\___/ \\_| \\_|");
         Thor      model     = new Thor();
         Commander commander = new Commander(model);
         if (args.Length == 0)
         {
             Console.WriteLine("Please Enter a valid path: ");
             path = Console.ReadLine();
             commander.ReadFile(path);
             commander.StartEvolution();
         }
         else
         {
             commander.ReadFile(args[0]);
             commander.StartEvolution();
         }
     }
     catch (TypeInitializationException)
     {
         Console.WriteLine(@"Please Install R");
     }
 }
Esempio n. 8
0
        public Mainframe(Thor model)
        {
            InitializeComponent();

            _model   = model;
            _current = State.Start;
            Next     = button2;
        }
Esempio n. 9
0
 static void Main(string[] args)
 {
     SuperMan       superman       = new SuperMan();
     IronMan        ironman        = new IronMan();
     SuperWoman     superwoman     = new SuperWoman();
     Thor           thor           = new Thor();
     AmericaCaptain americacaptain = new AmericaCaptain();
     BatMan         batman         = new BatMan();
     Vision         vision         = new Vision();
 }
        public void build_by_explicit_arguments()
        {
            var hulk = new TheHulk();
            var thor = new Thor();

            var args  = new ServiceArguments().With(hulk).With(thor);
            var thing = facility.Build <ContainerThing>(args);

            thing.Hulk.ShouldBeTheSameAs(hulk);
            thing.Thor.ShouldBeTheSameAs(thor);
        }
Esempio n. 11
0
 public TargetVariant(Thor model, Button nextButton)
 {
     InitializeComponent();
     _model              = model;
     _nextButton         = nextButton;
     _nextButton.Enabled = false;
     TargetPropertyBox.Items.Add("binarySize");
     TargetPropertyBox.Items.Add("performance");
     TargetPropertyBox.Items.Add("mainmemory");
     TargetPropertyBox.Items.Add("Random functions");
     TargetPropertyBox.SelectedIndex = 0;
 }
Esempio n. 12
0
    private static void Main(string[] args)
    {
        int[] inputs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var   light  = new Light(inputs[0], inputs[1]);
        var   thor   = new Thor(inputs[2], inputs[3]);

        while (true)
        {
            thor.Move(light);
            thor.TellDirection();
        }
    }
Esempio n. 13
0
    private static void Main(string[] args)
    {
        int[] inputs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var light = new Light(inputs[0], inputs[1]);
        var thor = new Thor(inputs[2], inputs[3]);

        while (true)
        {
            thor.Move(light);
            thor.TellDirection();
        }
    }
Esempio n. 14
0
 public static void Init(Thor model)
 {
     Model          = model;
     _fitnessValues = new List <Fitness>();
     FeatMax        = new List <double>();
     FeatMin        = new List <double>();
     InteracMax     = new List <double>();
     InteracMin     = new List <double>();
     VarMin         = new List <double>();
     VarMax         = new List <double>();
     _locker        = new object();
 }
Esempio n. 15
0
 public EvolutionSettings(Thor model, Button nextButton)
 {
     InitializeComponent();
     _model                       = model;
     _nextButton                  = nextButton;
     _nextButton.Enabled          = false;
     _model.Setting.Parallel      = true;
     textBox1.Text                = @"5000";
     _model.Setting.LogFolder     = Environment.CurrentDirectory;
     label52.Text                 = Environment.CurrentDirectory;
     textBox2.Text                = @"50";
     model.Setting.StopEarlyLevel = 1;
 }
Esempio n. 16
0
 public UniformDistGen(Thor model, Distribution.DistributionType Type)
 {
     this.model = model;
     this.Type  = Type;
     InitializeComponent();
     if (!double.IsNaN(model.Setting.UnifMin))
     {
         textBox1.Text = model.Setting.UnifMin.ToString();
     }
     if (!double.IsNaN(model.Setting.UnifMax))
     {
         textBox2.Text = model.Setting.UnifMax.ToString();
     }
 }
Esempio n. 17
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("以下為尚未符合 開放封閉原則 的程式");
            Console.WriteLine("雷神索爾的攻擊武器有兩種,一種是使用雷神之槌作攻擊,如下範例。\n");
            Console.ForegroundColor = ConsoleColor.White;

            var thorWithMjolnir = new Thor();

            thorWithMjolnir.Attack();

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("但如果要讓他更換武器作攻擊,就必須改寫類別的攻擊方法如下範例。\n");
            Console.ForegroundColor = ConsoleColor.White;

            var thorWithStormbreaker = new Thor();

            thorWithStormbreaker.Attack();

            Console.WriteLine("\n==========================我是分隔線==========================\n");
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("可以看到因為更動原本的方法,導致索爾的武器被限制住了,");
            Console.WriteLine("這樣違反了開放封閉原則,新功能不應該是由修改舊方法而產生的,");
            Console.WriteLine("因此新增一個類別,去複寫原本的攻擊方法來做新功能的開發,");
            Console.WriteLine("從而讓程式符合開放封閉原則。\n");
            Console.WriteLine("擴充方法後,使用這就可以任意指定要使用的武器了。\n");
            Console.ForegroundColor = ConsoleColor.White;

            // 使用者輸入武器選項,顯示結果
            string opt = string.Empty;

            while (true)
            {
                opt = Choice();
                if (opt == "1" || opt == "2")
                {
                    var thor = GetThor(opt);
                    Console.Write("訊息:\n");
                    thor.Attack();
                    Console.WriteLine("========================執行成功========================\n");
                }
                else
                {
                    Console.WriteLine("========================範例結束請按任意鍵========================\n");
                    Console.Read();
                    return;
                }
            }
        }
Esempio n. 18
0
        //Interac to Strap Feature to Strap
        public Commander(Thor model)
        {
            _model = model;

            //Initialize default values
            //Feature Model
            _model.Setting.NumberOfInteractions = 0;
            _model.Setting.NoVariantCalculation = false;
            _model.Setting.FeatureFitness       = true;
            _model.Setting.UseInitialFv         = true;
            _model.Setting.SelectedFeature      = 0;
            _model.Setting.SelectedInteraction  = 0;

            //Variant
            _model.Setting.PseudoRndSize = 50;
            _model.Setting.UsePseudoRnd  = true;
            _model.Setting.SolverTimeout = 3;

            //Evolution
            _model.Setting.Parallel       = true;
            _model.Setting.Logging        = true;
            _model.Setting.LogFolder      = Environment.CurrentDirectory;
            _model.Setting.StopEarlyLevel = 1;
            //_model.Setting.DrawDensity = true;
            _model.Setting.PlotStepSize   = 500;
            _model.Setting.MaxEvaluations = 5000;
            _model.Setting.PopulationSize = 50;

            //Solution
            _model.Setting.DrawAngle = 55;

            // backgroundWorker1
            //
            this.backgroundWorker1.DoWork             += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker1_DoWork);
            this.backgroundWorker1.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker1_RunWorkerCompleted);
            //
            // backgroundWorker2
            //
            this.backgroundWorker2.DoWork             += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker2_DoWork);
            this.backgroundWorker2.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker2_RunWorkerCompleted);
            //
            // backgroundWorker3
            //
            this.backgroundWorker3.DoWork             += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker3_DoWork);
            this.backgroundWorker3.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker3_RunWorkerCompleted);
            backgroundWorker1.WorkerReportsProgress    = true;
            backgroundWorker2.WorkerReportsProgress    = true;
            backgroundWorker3.WorkerReportsProgress    = true;
        }
Esempio n. 19
0
 public DynamicBins(DynamicHist dynamicHist, Thor model)
 {
     InitializeComponent();
     _dynHist          = dynamicHist;
     _model            = model;
     checkBox1.Checked = true;
     if (UsesStatic(_dynHist))
     {
         tableLayoutPanel3.Enabled = false;
     }
     else
     {
         tableLayoutPanel2.Enabled = false;
     }
 }
Esempio n. 20
0
        /// <summary>
        /// 運用工廠模式,根據傳入值回傳對應的索爾類別
        /// </summary>
        /// <param name="weaponType">傳入選項的值</param>
        /// <returns></returns>
        public static IAvengers GetThor(string weaponType)
        {
            IAvengers avenger;

            if (weaponType == "1")
            {
                return(avenger = new Thor());
            }
            if (weaponType == "2")
            {
                return(avenger = new ThorWithStormbreaker());
            }

            return(null);
        }
Esempio n. 21
0
        public SolutionVis(Thor model)
        {
            InitializeComponent();
            _model      = model;
            label9.Text = _model.Setting.LogFolder + Path.DirectorySeparatorChar + @"{feat, interac, variant}Solution.txt";
            _model.Setting.DrawAngle = 55;
            //comboBox1.DisplayMember = "DisplayName";

            //var parp = new ParetoPic(_model.BestSolutions);
            //parp.Dock = DockStyle.Fill;
            //tableLayoutPanel2.Controls.Add(parp, 0, 2);
            //tableLayoutPanel2.SetColumnSpan(parp, 2);

            //textBox1.DataBindings.Add("Text", this, "_w1");
        }
Esempio n. 22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <param name="nextButton"></param>
        public Evolution(Thor model, Button nextButton)
        {
            InitializeComponent();


            _nextButton                = nextButton;
            _model                     = model;
            checkBox1.Checked          = true;
            model.Setting.DrawDensity  = true;
            model.Setting.PlotStepSize = 500;
            numericUpDown2.Increment   = _model.Setting.PopulationSize;
            backgroundWorker1.WorkerReportsProgress = true;
            backgroundWorker2.WorkerReportsProgress = true;
            backgroundWorker3.WorkerReportsProgress = true;
        }
Esempio n. 23
0
        public NormalDistGen(Thor Model, Distribution.DistributionType type)
        {
            InitializeComponent();
            this.Model = Model;
            this.Type  = type;

            if (!double.IsNaN(Model.Setting.Mean))
            {
                textBox1.Text = Model.Setting.Mean.ToString();
            }
            if (!double.IsNaN(Model.Setting.StandardDeviation))
            {
                textBox2.Text = Model.Setting.StandardDeviation.ToString();
            }
        }
Esempio n. 24
0
        public SolutionPic(SolutionContainer solutionContainer, Thor model, int index)
        {
            InitializeComponent();
            _solCon = solutionContainer;
            _model  = model;
            _index  = index;

            //pictureBox1.ImageLocation
            //picArray = _model.DrawSolution(solutionContainer, index);



            label1.Text    = solutionContainer.DisplayName;
            featLabel.Text = $"Test: {solutionContainer.FeatureTVal}";
            varLabel.Text  = $"Test: {solutionContainer.VariantTVal}";
        }
Esempio n. 25
0
    static void Main(string[] args)
    {
        string[] inputs = Console.ReadLine().Split(' ');
        int lightX = int.Parse(inputs[0]); // the X position of the light of power
        int lightY = int.Parse(inputs[1]); // the Y position of the light of power
        
        var thor = new Thor( x: inputs[2], y: inputs[3] );

        // game loop
        while (true)
        {
            int remainingTurns = int.Parse(Console.ReadLine());

            thor.Move( x: lightX, y: lightY );
        }
    }
Esempio n. 26
0
    void Start()
    {
        HealthBar.maxValue = MaxHealth;
        HealthBar.value    = Health;

        Player     = GetComponent <Thor>();
        MyAnimator = GetComponent <Animator>();
        MyRenderer = GetComponent <SpriteRenderer>();

        MagicBar.maxValue = MaxMagic;
        MagicBar.value    = MinMagic;

        KeysText.text   = Keys.ToString();
        JewelsText.text = Jewels.ToString();
        ScoreText.text  = Score.ToString();
    }
Esempio n. 27
0
        public FeatureModel(Thor model, Button nextButton)
        {
            InitializeComponent();
            _model = model;

            NumberOfFeatures.DataBindings.Add("Text", _model.Setting, "NumberOfFeatures");
            NumberOfFeatures.ReadOnly          = true;
            model.Setting.NumberOfInteractions = 0;
            interactionBoxes      = new List <TextBox>();
            interactionErrorLabel = new List <Label>();

            orderValues              = new List <double>();
            _nextButton              = nextButton;
            _nextButton.Enabled      = false;
            flowLayoutPanel2.Enabled = false;
        }
Esempio n. 28
0
    private static void Main(string[] args)
    {
        int[] thorPosition = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        int[] inputs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var   thor   = new Thor(thorPosition[0], thorPosition[1], inputs[0]);
        var   map    = new Map();

        do
        {
            int numberOfGiants = inputs[1];
            map.RefreshMap(numberOfGiants);
            thor.TakeAction(map);

            inputs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        } while (true);
    }
Esempio n. 29
0
        public IntergenProblem(Thor model)
        {
            Model = model;

            NumberOfVariables = model.Setting.NumberOfFeatures + model.Setting.NumberOfInteractions;
            //ProblemName = "InteractionProblem";
            SolutionType = new RealSolutionType(this);

            UpperLimit = new double[NumberOfVariables];
            LowerLimit = new double[NumberOfVariables];

            var featMin = Model.DStore.SelectedFeatureDistribution.Values.Min();
            var featMax = Model.DStore.SelectedFeatureDistribution.Values.Max();


            const double featMargin  = 0.05;
            double       lowInterac  = 0;
            double       highInterac = 0;

            var lowFeat  = featMin < 0 ? featMin * (1 + featMargin) : featMin * (1 - featMargin);
            var highFeat = featMax < 0 ? featMax * (1 - featMargin) : featMax * (1 + featMargin);

            if (model.Setting.NumberOfInteractions > 0)
            {
                const double interacMargin = 0.05;
                var          interacMin    = Model.DStore.SelectedInteractionDistribution.Values.Min();
                var          interacMax    = Model.DStore.SelectedInteractionDistribution.Values.Max();
                lowInterac  = interacMin < 0 ? interacMin * (1 + interacMargin) : interacMin * (1 - interacMargin);
                highInterac = interacMax < 0 ? interacMax * (1 - interacMargin) : interacMax * (1 + interacMargin);
            }

            for (var index = 0; index < NumberOfVariables; index++)
            {
                if (index < model.Setting.NumberOfFeatures)
                {
                    LowerLimit[index] = lowFeat;
                    UpperLimit[index] = highFeat;
                }
                else
                {
                    LowerLimit[index] = lowInterac;
                    UpperLimit[index] = highInterac;
                }
            }
        }
Esempio n. 30
0
        /// <summary>
        /// Fills the available NFP-properties, and adds Bindings to Labels
        /// </summary>
        /// <param name="model"></param>
        /// <param name="nextButton"></param>
        public Features(Thor model, Button nextButton)
        {
            _model      = model;
            _nextButton = nextButton;
            InitializeComponent();

            BootstrapClick.Enabled = false;

            //Add selectable non-functional properties
            FeatureNFPBox.Items.Add("binarySize");
            FeatureNFPBox.Items.Add("performance");
            FeatureNFPBox.Items.Add("mainmemory");
            FeatureNFPBox.Items.Add("Random functions");
            FeatureNFPBox.SelectedIndex = 0;

            //NumberOfFeatureLabel is binded to model.NumberOfFeatures
            var feature = new Binding("Text", _model.Setting, "NumberOfFeatures");

            feature.Format += NumberFeaturesFormat;
            NumberOfFeaturesLabel.DataBindings.Add(feature);
            _model.Setting.FeatureAdjust = 0.5;
            //Data Binding for the P-Values of the selected Tests
            var pVal1 = new Binding("Text", _model, "FPVal1");

            pVal1.Format += (sender, e) => {
                var val = e.Value;
                e.Value = @"Test-Value - " + _model.FeatureTestMethod + ": " + val;
            };

            //Data Binding for the second p-Value
            var pVal2 = new Binding("Text", _model, "FPVal2");

            pVal2.Format += (sender, e) => {
                var val = e.Value;
                e.Value = @"Test-Value - " + _model.FeatureTestMethod + ": " + val;
            };

            FirstPLabel.DataBindings.Add(pVal1);
            SecondPLabel.DataBindings.Add(pVal2);
            nextButton.Enabled = false;
            button1.Enabled    = false;
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="model"></param>
 /// <param name="nextButton"></param>
 public VariantGenerationControl(Thor model, Button nextButton)
 {
     InitializeComponent();
     _nextButton                  = nextButton;
     _model                       = model;
     checkBox1.Checked            = false;
     checkBox2.Checked            = false;
     checkBox3.Checked            = false;
     checkBox4.Checked            = false;
     checkBox5.Checked            = true;
     _model.Setting.PseudoRndSize = 50;
     _model.Setting.UsePseudoRnd  = true;
     RandomModulo.Enabled         = false;
     RandomSeconds.Enabled        = false;
     RandomTreshold.Enabled       = false;
     FWSeconds.Enabled            = false;
     PWSeconds.Enabled            = false;
     NFWSeconds.Enabled           = false;
     textBox1.Enabled             = false;
     textBox2.Enabled             = false;
 }
Esempio n. 32
0
        public InteractionControl(Thor model, Button nextButton)
        {
            InitializeComponent();
            _nextButton = nextButton;
            _model      = model;

            SelectedInteractionProperty.Items.Add("binarySize");
            SelectedInteractionProperty.Items.Add("performance");
            SelectedInteractionProperty.Items.Add("mainmemory");
            SelectedInteractionProperty.Items.Add("Random functions");
            SelectedInteractionProperty.SelectedIndex = 0;
            BootstrapInteractions.Enabled             = false;
            _nextButton.Enabled = false;
            button2.Enabled     = false;
            var interac = new Binding("Text", _model.Setting, "NumberOfInteractions");

            interac.Format += (sender, args) => {
                args.Value = "Number of Interactions: " + args.Value;
            };
            NumberOfInteractions.DataBindings.Add(interac);

            //pvalue 1 binding
            var pVal1 = new Binding("Text", _model, "IPVal1");

            pVal1.Format += (sender, e) => {
                e.Value = @"Test-Value - " + _model.FeatureTestMethod + ": " + e.Value;
            };
            pValue1Label.DataBindings.Add(pVal1);

            //Data Binding for the second p-Value
            var pVal2 = new Binding("Text", _model, "IPVal2");

            pVal2.Format += (sender, e) => {
                e.Value = @"Test-Value - " + _model.FeatureTestMethod + ": " + e.Value;
            };
            pValue2Label.DataBindings.Add(pVal2);

            SelectFirst.Enabled  = false;
            SelectSecond.Enabled = false;
        }