protected Histogram <double> Distribution(
            ISelector <DoubleGene, double> selector,
            Optimize opt,
            int populationCount,
            int loops
            )
        {
            Func <Genotype <DoubleGene>, double> ff = gt => gt.Gene.Allele;

            Factory <Phenotype <DoubleGene, double> > ptf = () =>
                                                            Phenotype.Of(Genotype.Of(DoubleChromosome.Of(Min, Max)), 1, ff);

            return(Enumerable.Range(0, loops).AsParallel().Select(j =>
            {
                var hist = Histogram.OfDouble(Min, Max, ClassCount);

                var population =
                    Enumerable.Range(0, populationCount)
                    .Select(i => ptf())
                    .ToPopulation();

                var selectionCount = (int)(populationCount / SelectionFraction);
                foreach (var pt in selector.Select(population, selectionCount, opt)
                         .Select(pt => pt.GetGenotype().Gene.Allele))
                {
                    hist.Accept(pt);
                }

                return hist;
            }).ToDoubleHistogram(Min, Max, ClassCount));
        }
        public void Select(int size, int count, Optimize opt)
        {
            Func <Genotype <DoubleGene>, double> ff = gt => gt.Gene.Allele;

            Func <Phenotype <DoubleGene, double> > F = delegate()
            {
                return(Phenotype.Of(Genotype.Of(DoubleChromosome.Of(0.0, 1000.0)), 1, ff));
            };

            var population = Enumerable.Range(0, size)
                             .Select(i => F())
                             .ToPopulation();

            var selection = Selector().Select(population, count, opt);

            if (size == 0)
            {
                Assert.Empty(selection);
            }
            else
            {
                Assert.Equal(count, selection.Count);
            }
            foreach (var pt in selection)
            {
                Assert.True(
                    population.Contains(pt),
                    $"Population doesn't contain {pt}."
                    );
            }
        }
Example #3
0
        //Change delivery frequency in function of battery
        private void OptimizeTracker(Optimize level)
        {
            switch (level)
            {
            case Optimize.FULL:
                _deliveryTime = 90.0f * _mode;
                break;

            case Optimize.HIGH:
                _deliveryTime = 60.0f * _mode;
                break;

            case Optimize.MODERATE:
                _deliveryTime = 30.0f * _mode;
                break;

            case Optimize.LOW:
                _deliveryTime = 15.0f * _mode;
                break;

            case Optimize.NONE:
                _deliveryTime = 7.0f * _mode;
                break;
            }
        }
        public async Task <XDocument> WriteSpriteRecipe()
        {
            string            root     = ProjectHelpers.GetRootFolder();
            XmlWriterSettings settings = new XmlWriterSettings()
            {
                Indent = true
            };
            XNamespace xsi = "http://www.w3.org/2001/XMLSchema-instance";

            if (string.IsNullOrEmpty(root))
            {
                root = ProjectHelpers.GetProjectFolder(FileName);
            }

            ProjectHelpers.CheckOutFileFromSourceControl(FileName);

            using (XmlWriter writer = await Task.Run(() => XmlWriter.Create(FileName, settings)))
            {
                XDocument doc =
                    new XDocument(
                        new XElement("sprite",
                                     new XAttribute(XNamespace.Xmlns + "xsi", xsi),
                                     new XAttribute(xsi + "noNamespaceSchemaLocation", "http://vswebessentials.com/schemas/v1/sprite.xsd"),
                                     new XElement("settings",
                                                  new XComment("Determines if the sprite image should be automatically optimized after creation/update."),
                                                  new XElement("optimize", Optimize.ToString().ToLowerInvariant()),
                                                  new XComment("Determines the orientation of images to form this sprite. The value must be vertical or horizontal."),
                                                  new XElement("orientation", IsVertical ? "vertical" : "horizontal"),
                                                  new XComment("The margin (in pixel) around and between the constituent images."),
                                                  new XElement("margin", Margin),
                                                  new XComment("File extension of sprite image."),
                                                  new XElement("outputType", FileExtension.ToString().ToLowerInvariant()),
                                                  new XComment("Determine whether to generate/re-generate this sprite on building the solution."),
                                                  new XElement("runOnBuild", RunOnBuild.ToString().ToLowerInvariant()),
                                                  new XComment("Use full path to generate unique class or mixin name in CSS, LESS and SASS files. Consider disabling this if you want class names to be filename only."),
                                                  new XElement("fullPathForIdentifierName", UseFullPathForIdentifierName.ToString().ToLowerInvariant()),
                                                  new XComment("Use absolute path in the generated CSS-like files. By default, the URLs are relative to sprite image file (and the location of CSS, LESS and SCSS)."),
                                                  new XElement("useAbsoluteUrl", UseAbsoluteUrl.ToString().ToLowerInvariant()),
                                                  new XComment("Specifies a custom subfolder to save files to. By default, compiled output will be placed in the same folder and nested under the original file."),
                                                  new XElement("outputDirectory", OutputDirectory),
                                                  new XComment("Specifies a custom subfolder to save CSS files to. By default, compiled output will be placed in the same folder and nested under the original file."),
                                                  new XElement("outputDirectoryForCss", CssOutputDirectory),
                                                  new XComment("Specifies a custom subfolder to save LESS files to. By default, compiled output will be placed in the same folder and nested under the original file."),
                                                  new XElement("outputDirectoryForLess", LessOutputDirectory),
                                                  new XComment("Specifies a custom subfolder to save SCSS files to. By default, compiled output will be placed in the same folder and nested under the original file."),
                                                  new XElement("outputDirectoryForScss", ScssOutputDirectory)
                                                  ),
                                     new XComment("The order of the <file> elements determines the order of the images in the sprite."),
                                     new XElement("files", BundleAssets.Select(file => new XElement("file", "/" + FileHelpers.RelativePath(root, file))))
                                     )
                        );

                doc.Save(writer);

                return(doc);
            }
        }
        /// <summary>
        /// The method aims at finding a configuration which is similar to the given configuration, but does not contain the optionToBeRemoved. If further options need to be removed from the given configuration, they are outputed in removedElements.
        /// </summary>
        /// <param name="optionToBeRemoved">The binary configuration option that must not be part of the new configuration.</param>
        /// <param name="originalConfig">The configuration for which we want to find a similar one.</param>
        /// <param name="removedElements">If further options need to be removed from the given configuration to build a valid configuration, they are outputed in this list.</param>
        /// <param name="vm">The variability model containing all options and their constraints.</param>
        /// <returns>A configuration that is valid, similar to the original configuration and does not contain the optionToBeRemoved.</returns>
        public List <BinaryOption> GenerateConfigWithoutOption(BinaryOption optionToBeRemoved, List <BinaryOption> originalConfig, out List <BinaryOption> removedElements, VariabilityModel vm)
        {
            removedElements = new List <BinaryOption>();
            var originalConfigWithoutRemoved = originalConfig.Where(x => !x.Equals(optionToBeRemoved));

            List <BoolExpr> variables;
            Dictionary <BoolExpr, BinaryOption> termToOption;
            Dictionary <BinaryOption, BoolExpr> optionToTerm;
            Tuple <Context, BoolExpr>           z3Tuple = Z3Solver.GetInitializedBooleanSolverSystem(out variables, out optionToTerm, out termToOption, vm, this.henard);
            Context         z3Context     = z3Tuple.Item1;
            BoolExpr        z3Constraints = z3Tuple.Item2;
            List <BoolExpr> constraints   = new List <BoolExpr>();

            constraints.Add(z3Constraints);

            constraints.Add(z3Context.MkNot(optionToTerm[optionToBeRemoved]));

            ArithExpr[] minGoals = new ArithExpr[variables.Count];


            for (int r = 0; r < variables.Count; r++)
            {
                BinaryOption currOption      = termToOption[variables[r]];
                ArithExpr    numericVariable = z3Context.MkIntConst(currOption.Name);

                int weight = -1000;

                if (!originalConfigWithoutRemoved.Contains(currOption))
                {
                    weight = 1000;
                }
                else if (currOption.Equals(optionToBeRemoved))
                {
                    weight = 100000;
                }

                constraints.Add(z3Context.MkEq(numericVariable, z3Context.MkITE(variables[r], z3Context.MkInt(weight), z3Context.MkInt(0))));
                minGoals[r] = numericVariable;
            }

            Optimize optimizer = z3Context.MkOptimize();

            optimizer.Assert(constraints.ToArray());
            optimizer.MkMinimize(z3Context.MkAdd(minGoals));

            if (optimizer.Check() != Status.SATISFIABLE)
            {
                return(null);
            }
            else
            {
                Model model = optimizer.Model;
                List <BinaryOption> similarConfig = RetrieveConfiguration(variables, model, termToOption);
                removedElements = originalConfigWithoutRemoved.Except(similarConfig).ToList();
                return(similarConfig);
            }
        }
Example #6
0
        /// <summary>
        /// 产生中间代码(可以选择优化等级)
        /// </summary>
        /// <param name="Text">优化代码</param>
        /// <param name="Level">优化等级为0 ~ 3</param>
        public void GenerateCode(string Text, int Level)
        {
            Parse(Text);
            Done = true;
            OptimizationLevel = Level;
            if (NumOfError != 0)
            {
                return;
            }
            Clear();
            GetQuadruples(Root, 0);
            LocateJumpNodeAndDetermineNodeOffset();//获取四元式后,回填跳转地址并且对每个节点赋于地址值
            Optimize optimize = new Optimize(CodeSeg, VarSeg, CodeEntrance);

            if (Level > 0)
            {
                optimize.LocalOptimization();
            }
            if (Level > 1)
            {
                optimize.LoopOptimization();
            }
            if (Level > 2)
            {
                optimize.GlobalOptimization();//O(n^4警告)
            }
            if (Level > 3)
            {
                Console.WriteLine("4级别优化请给Jeff Dean发邮件");
            }
            if (Level > 0)
            {
                CodeSeg = optimize.GenerateCode();
            }
            else
            {
                //添加程序入口
                List <QuadrupleNode> Code = new List <QuadrupleNode>();
                Code.Add(new QuadrupleNode(QuadrupleType.JMP)
                {
                    Result = CodeEntrance + 1
                });
                int JumpValue = Convert.ToInt32(QuadrupleType.JMP);
                foreach (var i in CodeSeg)
                {
                    QuadrupleType type = i.Type;
                    int           v    = Convert.ToInt32(type);
                    if (v <= JumpValue || type == QuadrupleType.Call)
                    {
                        i.Result++;
                    }
                    Code.Add(i);
                }
                CodeSeg = Code;
            }
        }
    public double FindBestWord(vector_vector_LetterMatch wmTab, vector_int bestWord, Optimize opt)
    {
        double ret = VisionLabPINVOKE.ClassLexicon_FindBestWord__SWIG_1(swigCPtr, vector_vector_LetterMatch.getCPtr(wmTab), vector_int.getCPtr(bestWord), (int)opt);

        if (VisionLabPINVOKE.SWIGPendingException.Pending)
        {
            throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
        }
        return(ret);
    }
Example #8
0
        //log de debug
        //private Log debug = null;

        public PainterRealTime(ClientTcp client)
        {
            InitializeComponent();
            this.g         = this.pPainter.CreateGraphics();
            this.tabpointF = new List <PointF>();
            this.myOrder   = new Orders();
            this.myClient  = client;
            this.optimize  = new Optimize();
            //debug
            //this.debug = new Log(Constants.logPainterRealTime);
        }
Example #9
0
 private void switch_univ_Office2016_Click(object sender, EventArgs e)
 {
     if (!switch_univ_DisableOff2016Telemetry.Checked)
     {
         Optimize.DisableOffice2016Telemetry();
     }
     else
     {
         Optimize.EnableOffice2016Telemetry();
     }
     Options.CurrentOptions.DisableOffice2016Telemetry = !switch_univ_DisableOff2016Telemetry.Checked;
 }
Example #10
0
 private void switch_univ_TelemetryTasks_Click(object sender, EventArgs e)
 {
     if (!switch_univ_DisableTelemetryTasks.Checked)
     {
         Optimize.DisableTelemetryTasks();
     }
     else
     {
         Optimize.EnableTelemetryTasks();
     }
     Options.CurrentOptions.DisableTelemetryTasks = !switch_univ_DisableTelemetryTasks.Checked;
 }
Example #11
0
 private void switch_univ_HomeGroup_Click(object sender, EventArgs e)
 {
     if (!switch_univ_HomeGroup.Checked)
     {
         Optimize.DisableHomeGroup();
     }
     else
     {
         Optimize.EnableHomeGroup();
     }
     Options.CurrentOptions.DisableHomeGroup = !switch_univ_HomeGroup.Checked;
 }
Example #12
0
 private void switch_w10_DisableXBoxLive_Click(object sender, EventArgs e)
 {
     if (!switch_w10_DisableXBoxLive.Checked)
     {
         Optimize.DisableXboxLive();
     }
     else
     {
         Optimize.EnableXboxLive();
     }
     Options.CurrentOptions.DisableXboxLive = !switch_w10_DisableXBoxLive.Checked;
 }
Example #13
0
 private void switch_w10_ExcludeDriverUpdate_Click(object sender, EventArgs e)
 {
     if (!switch_w10_ExcludeDriverUpdate.Checked)
     {
         Optimize.ExcludeDrivers();
     }
     else
     {
         Optimize.IncludeDrivers();
     }
     Options.CurrentOptions.ExcludeDrivers = !switch_w10_ExcludeDriverUpdate.Checked;
 }
Example #14
0
 private void switch_univ_WindowsDefender_Click(object sender, EventArgs e)
 {
     if (!switch_univ_DisableWindowsDefender.Checked)
     {
         Optimize.DisableDefender();
     }
     else
     {
         Optimize.EnableDefender();
     }
     Options.CurrentOptions.DisableWindowsDefender = !switch_univ_DisableWindowsDefender.Checked;
 }
Example #15
0
 private void switch_univ_PerformanceTweaks_Click(object sender, EventArgs e)
 {
     if (!switch_univ_EnablePerformanceTweaks.Checked)
     {
         Optimize.EnablePerformanceTweaks();
     }
     else
     {
         Optimize.DisablePerformanceTweaks();
     }
     Options.CurrentOptions.EnablePerformanceTweaks = !switch_univ_EnablePerformanceTweaks.Checked;
 }
Example #16
0
 private void switch_w10_DisableGamebar_Click(object sender, EventArgs e)
 {
     if (!switch_w10_DisableGamebar.Checked)
     {
         Optimize.DisableGameBar();
     }
     else
     {
         Optimize.EnableGameBar();
     }
     Options.CurrentOptions.DisableGameBar = !switch_w10_DisableGamebar.Checked;
 }
Example #17
0
 private void switch_w10_DisableSilentAppInstall_Click(object sender, EventArgs e)
 {
     if (!switch_w10_DisableSilentAppInstall.Checked)
     {
         Optimize.DisableSilentAppInstall();
     }
     else
     {
         Optimize.EnableSilentAppInstall();
     }
     Options.CurrentOptions.DisableSilentAppInstall = !switch_w10_DisableSilentAppInstall.Checked;
 }
Example #18
0
 private void switch_w10_DisableFeatureUpdates_Click(object sender, EventArgs e)
 {
     if (!switch_w10_DisableFeatureUpdates.Checked)
     {
         Optimize.DisableForcedFeatureUpdates();
     }
     else
     {
         Optimize.EnableForcedFeatureUpdates();
     }
     Options.CurrentOptions.DisableFeatureUpdates = !switch_w10_DisableFeatureUpdates.Checked;
 }
Example #19
0
 private void switch_w10_DisableStartMenuAds_Click(object sender, EventArgs e)
 {
     if (!switch_w10_DisableStartMenuAds.Checked)
     {
         Optimize.DisableStartMenuAds();
     }
     else
     {
         Optimize.EnableStartMenuAds();
     }
     Options.CurrentOptions.DisableStartMenuAds = !switch_w10_DisableStartMenuAds.Checked;
 }
Example #20
0
 private void switch_univ_SmartScreen_Click(object sender, EventArgs e)
 {
     if (!switch_univ_DisableSmartScreen.Checked)
     {
         Optimize.DisableSmartScreen();
     }
     else
     {
         Optimize.EnableSmartScreen();
     }
     Options.CurrentOptions.DisableSmartScreen = !switch_univ_DisableSmartScreen.Checked;
 }
Example #21
0
 private void switch_univ_PrintService_Click(object sender, EventArgs e)
 {
     if (!switch_univ_DisablePrintService.Checked)
     {
         Optimize.DisablePrintService();
     }
     else
     {
         Optimize.EnablePrintService();
     }
     Options.CurrentOptions.DisablePrintService = !switch_univ_DisablePrintService.Checked;
 }
Example #22
0
 private void switch_univ_SystemRestore_Click(object sender, EventArgs e)
 {
     if (!switch_univ_SystemRestore.Checked)
     {
         Optimize.DisableSystemRestore();
     }
     else
     {
         Optimize.EnableSystemRestore();
     }
     Options.CurrentOptions.DisableSystemRestore = !switch_univ_SystemRestore.Checked;
 }
Example #23
0
 private void switch_univ_SkypeAds_Click(object sender, EventArgs e)
 {
     if (!switch_univ_BlockSkypeAds.Checked)
     {
         Optimize.DisableSkypeAds();
     }
     else
     {
         Optimize.EnableSkypeAds();
     }
     Options.CurrentOptions.BlockSkypeAds = !switch_univ_BlockSkypeAds.Checked;
 }
Example #24
0
        public Usage Clone()
        {
            Usage clone = new Usage();

            clone.Optimize = Optimize != null?Optimize.Clone() : null;

            clone.DebugConstants = DebugConstants != null?DebugConstants.Clone() : null;

            clone.DebugInfo = DebugInfo != null?DebugInfo.Clone() : null;

            return(clone);
        }
Example #25
0
 private void switch_univ_CompatibilityAssistant_Click(object sender, EventArgs e)
 {
     if (!switch_univ_CompatibilityAssistant.Checked)
     {
         Optimize.DisableCompatibilityAssistant();
     }
     else
     {
         Optimize.EnableCompatibilityAssistant();
     }
     Options.CurrentOptions.DisableCompatibilityAssistant = !switch_univ_CompatibilityAssistant.Checked;
 }
Example #26
0
 private void switch_w10_CloudClipboard_Click(object sender, EventArgs e)
 {
     if (!switch_w10_CloudClipboard.Checked)
     {
         Optimize.DisableCloudClipboard();
     }
     else
     {
         Optimize.EnableCloudClipboard();
     }
     Options.CurrentOptions.DisableCloudClipboard = !switch_w10_CloudClipboard.Checked;
 }
Example #27
0
 private void switch_univ_NetworkThrottling_Click(object sender, EventArgs e)
 {
     if (!switch_univ_DisableNetworkThrottling.Checked)
     {
         Optimize.DisableNetworkThrottling();
     }
     else
     {
         Optimize.EnableNetworkThrottling();
     }
     Options.CurrentOptions.DisableNetworkThrottling = !switch_univ_DisableNetworkThrottling.Checked;
 }
Example #28
0
 private void switch_univ_MediaSharing_Click(object sender, EventArgs e)
 {
     if (!switch_univ_DisableMediaPlayerSharing.Checked)
     {
         Optimize.DisableMediaPlayerSharing();
     }
     else
     {
         Optimize.EnableMediaPlayerSharing();
     }
     Options.CurrentOptions.DisableMediaPlayerSharing = !switch_univ_DisableMediaPlayerSharing.Checked;
 }
Example #29
0
 private void switch_univ_Superfetch_Click(object sender, EventArgs e)
 {
     if (!switch_univ_DisableSuperfetch.Checked)
     {
         Optimize.DisableSuperfetch();
     }
     else
     {
         Optimize.EnableSuperfetch();
     }
     Options.CurrentOptions.DisableSuperfetch = !switch_univ_DisableSuperfetch.Checked;
 }
Example #30
0
 private void switch_univ_ErrorReport_Click(object sender, EventArgs e)
 {
     if (!switch_univ_DisableErrReport.Checked)
     {
         Optimize.DisableErrorReporting();
     }
     else
     {
         Optimize.EnableErrorReporting();
     }
     Options.CurrentOptions.DisableErrorReporting = !switch_univ_DisableErrReport.Checked;
 }
 public static string OptimizeToStr(Optimize opt) {
   string ret = VisionLabPINVOKE.OptimizeToStr((int)opt);
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
 public double FindBestWord(vector_vector_LetterMatch wmTab, SWIGTYPE_p_std__string bestWord, Optimize opt) {
   double ret = VisionLabPINVOKE.ClassLexicon_FindBestWord__SWIG_0(swigCPtr, vector_vector_LetterMatch.getCPtr(wmTab), SWIGTYPE_p_std__string.getCPtr(bestWord), (int)opt);
   if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }