/*public static void PlotValues(Solution currentBestSolution) { * // Console.WriteLine(CurrentBestSolution.Variable); * var wrap = new XReal(currentBestSolution); * var values = new double[wrap.Size()]; * * for (var i = 0; i < wrap.Size(); i++) * { * values[i] = wrap.GetValue(i); * } * PlotValues(values, "CurrentBest"); * * }*/ public static void PlotValues(string name, string imagepath, double adjust, Distribution.DistributionType type) { try { if (!StoredValues.Contains(name)) { //throw new ArgumentNullException("Values not found: " + name); } var color = "red"; if (type == Distribution.DistributionType.Variant) { color = "blue"; } if (type == Distribution.DistributionType.Feature) { color = "green"; } Engine.Evaluate($"featureDist <- data.frame({name})"); Engine.Evaluate($"plot <- ggplot(data=featureDist, aes({name})) + geom_density(fill='{color}', alpha=0.3, adjust=0.5)" + LegendNoFill + PanelGrid + DensityPercent); Engine.Evaluate($"ggsave(plot=plot, file='{imagepath.Replace('\\','/')}', width=7, height=5)"); } catch (Exception e) { Console.WriteLine(e); } }
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(); } }
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(); } }
/// <summary> /// Checks if a probability function was selected /// </summary> /// <param name="selected"></param> /// <param name="type"></param> /// <returns></returns> private bool CheckForRandomFunction(object selected, Distribution.DistributionType type) { switch (((Distribution)selected).DisplayName) { case "Normal": var normal = new NormalDistGen(_model, type); normal.ShowDialog(); return(true); case "Uniform": var unif = new UniformDistGen(_model, type); unif.ShowDialog(); return(true); default: return(false); } }
public void WriteDistributionToFile(Distribution.DistributionType type) { string fileName = ""; Distribution toWrite = null; if (type == Distribution.DistributionType.Feature) { fileName = "scaledFeatures.txt"; toWrite = SelectedFeatureDistribution; } if (type == Distribution.DistributionType.Interaction) { fileName = "scaledInteractions.txt"; toWrite = SelectedInteractionDistribution; } if (type == Distribution.DistributionType.Variant) { fileName = "scaledVariants.txt"; toWrite = SelectedTargetDistribution; } if (toWrite == null) { return; } File.WriteAllText(fileName, string.Empty); using (var sw = File.AppendText(fileName)) { sw.WriteLine(toWrite.DisplayName); sw.WriteLine(toWrite.Name); sw.WriteLine(toWrite.DistType); for (var i = 0; i < toWrite.Values.Length - 1; i++) { sw.Write(toWrite.Values[i] + ", "); } sw.WriteLine(toWrite.Values[toWrite.Values.Length - 1]); } }