private bool HandleAlgorithmObject(List <string> areaElementKeys, algorithm algorithm, string configPath, configurationArea area, Area areaObject) { if (CheckElementExists(areaElementKeys, algorithm.key, configPath, area)) { return(true); } var algorithmKeyList = new List <string>(algorithm.setting.Length); var algorithmObject = new Algorithm { Name = algorithm.name, Key = algorithm.key }; foreach (var algorithmSetting in algorithm.setting) { if (!algorithmKeyList.Contains(algorithmSetting.key)) { algorithmObject.Settings.Add( new Setting() { Key = algorithmSetting.key, Value = algorithmSetting.value }); } } areaObject.Elements.Add(algorithmObject); return(false); }
public frm_visualiser(int n) { InitializeComponent(); DoubleBuffered = true; SetStyle(ControlStyles.OptimizedDoubleBuffer, true); //timer refreshes the form at 60 frames per second timer_refresh.Interval = 1000 / 60; timer_refresh.Enabled = true; algos = new algorithm[4] { algorithm.bubblesort, algorithm.quicksort, algorithm.bogosort, algorithm.radixsort }; algo = algos[0]; num_elements = n; elements = new int[num_elements]; for (int i = 0; i < elements.Length; i++) { elements[i] = i; } Algorithms.scramble(elements, rng); }
select(algorithm: a, hardware: h);
private void predict_np_time_method(List <double[]> perwelldata, int math_predic_num, int datacol, List <double[]> resultlist, double fluid_type) { int i, datanum; datanum = perwelldata.Count; double[] GMData = new double[datanum]; algorithm alg = new algorithm(); int LoopCount = int.Parse(txtiters.Text); List <double> parameter_result = new List <double>(); if (model.SelectedIndex == 0) { //usher for (int k = 0; k < datacol; k++) { for (i = 0; i < datanum; i++) { GMData[i] = perwelldata[i][k]; } double[,] result = new double[datanum + math_predic_num, 2]; int Dimension = 5; double[,] PsoScope = new double[Dimension, 2]; PsoScope[0, 0] = double.Parse(textEdit0.Text); //'下界 PsoScope[0, 1] = double.Parse(textEdit1.Text); //'上界 PsoScope[1, 0] = double.Parse(textEdit2.Text); //'下界 PsoScope[1, 1] = double.Parse(textEdit3.Text); //'上界 PsoScope[2, 0] = double.Parse(textEdit4.Text); //'下界 PsoScope[2, 1] = double.Parse(textEdit5.Text); //'上界 PsoScope[3, 0] = double.Parse(textEdit6.Text); //'下界 PsoScope[3, 1] = double.Parse(textEdit7.Text); //'上界 PsoScope[4, 0] = GMData[GMData.GetLength(0) - 1] * 1.1; PsoScope[4, 1] = GMData[GMData.GetLength(0) - 1] * double.Parse(txtnp.Text); alg.Usher(math_predic_num, LoopCount, fluid_type, PsoScope, GMData, result, parameter_result); double[] resulty = new double[datanum + math_predic_num]; for (i = 0; i < math_predic_num; i++) { resulty[i] = result[i + datanum, 1]; } resultlist.Add(resulty); } } else if (model.SelectedIndex == 1) { //gomperz for (int k = 0; k < datacol; k++) { for (i = 0; i < datanum; i++) { GMData[i] = perwelldata[i][k]; } double[,] result = new double[datanum + math_predic_num, 2]; alg.Compertz(math_predic_num, GMData, result, parameter_result); double[] resulty = new double[datanum + math_predic_num]; for (i = 0; i < math_predic_num; i++) { resulty[i] = result[i + datanum, 1]; } resultlist.Add(resulty); } } else if (model.SelectedIndex == 2) { //GM11 for (int k = 0; k < datacol; k++) { for (i = 0; i < datanum; i++) { GMData[i] = perwelldata[i][k]; } double[,] result = new double[datanum + math_predic_num, 2]; alg.GM1_1_Predict(math_predic_num, GMData, result, parameter_result); double[] resulty = new double[datanum + math_predic_num]; for (i = 0; i < math_predic_num; i++) { resulty[i] = result[i + datanum, 1]; } resultlist.Add(resulty); } } }
internal static void ThrowNotSupportedException_SignatureAlgorithm(SignatureAlgorithm?algorithm, in EllipticalCurve curve) => throw CreateNotSupportedException_SignatureAlgorithm(algorithm, curve);
public Tuple<algorithm.interfaces.IIndividual, algorithm.interfaces.IIndividual> crossover(algorithm.interfaces.IIndividual partner) { QAPIndividual qapPartner = (QAPIndividual)partner; // ugly :/ //QAPIndividual firstChild = makeChild(this, qapPartner); //QAPIndividual secondChild = makeChild(this, qapPartner); //return new Tuple<algorithm.interfaces.IIndividual, algorithm.interfaces.IIndividual>(firstChild, secondChild); int n = this.problem.ProblemSize; int[] firstPermutation = this.permutation; int[] secondPermutation = qapPartner.permutation; int[][] permutations = new int[2][]; permutations[0] = firstPermutation; permutations[1] = secondPermutation; int[] offspring1 = new int[n]; int[] offspring2 = new int[n]; for (int i = 0; i < n; i++) { offspring1[i] = -1; offspring2[i] = -1; } //printArray(offspring1); for (int i = 0; i < n; i++) { //Console.WriteLine(i); if (offspring1[i] == -1) { //Console.WriteLine(i); int par = random.Next(2); int start1 = permutations[par][i]; int start2 = permutations[1 - par][i]; int el1 = start1; int el2 = start2; offspring1[i] = el1; offspring2[i] = el2; int pos1 = pos(permutations[1 - par], el1); int pos2 = pos(permutations[par], el2); //Console.WriteLine("" + pos1 + " " + pos2 + " " + el1 + " " + el2 + " " + par + " " + i); //printArray(offspring1); //printArray(offspring2); //Console.WriteLine("new pos1 = " + pos1 + " new pos2 = " + pos2); while (i != pos1) { el1 = permutations[par][pos1]; el2 = permutations[1 - par][pos2]; offspring1[pos1] = el1; offspring2[pos2] = el2; //Console.WriteLine("" + pos1 + " " + pos2 + " " + el1 + " " + el2); //printArray(offspring1); //printArray(offspring2); pos1 = pos(permutations[1 - par], el1); pos2 = pos(permutations[par], el2); //Console.ReadKey(); } } } return new Tuple<algorithm.interfaces.IIndividual, algorithm.interfaces.IIndividual>(new QAPIndividual(problem, offspring1), new QAPIndividual(problem, offspring2)); }
=> new PolygonAreaMock(drawFromCornersMethod, innerPointsCreationMethod, algorithm, r.MinExtent, (r.MaxExtentX, r.MinExtentY),
private void frm_visualiser_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (sort_thread != null) { sort_thread.Abort(); } if (algo == algorithm.bubblesort) { sort_thread = new Thread(() => Algorithms.bubblesort(elements)); sort_thread.Start(); } /* Gone for now * else if(algo == algorithm.mergesort) * { * sort_thread = new Thread(() => Algorithms.mergesort(elements)); * sort_thread.Start(); * } */ else if (algo == algorithm.quicksort) { sort_thread = new Thread(() => Algorithms.quicksort(elements, 0, elements.Length - 1)); sort_thread.Start(); } else if (algo == algorithm.bogosort) { sort_thread = new Thread(() => Algorithms.bogosort(elements)); sort_thread.Start(); } else if (algo == algorithm.radixsort) { sort_thread = new Thread(() => Algorithms.radixsort(elements)); sort_thread.Start(); } } if (e.KeyCode == Keys.Back) { if (sort_thread != null) { sort_thread.Abort(); } sort_thread = new Thread(() => Algorithms.scramble(elements, rng)); sort_thread.Start(); } if (e.KeyCode == Keys.Right) { if (algo == algos[algos.Length - 1]) { algo = algos[0]; } else { algo = algos[Array.IndexOf(algos, algo) + 1]; } } if (e.KeyCode == Keys.Left) { if (algo == algos[0]) { algo = algos[algos.Length - 1]; } else { algo = algos[Array.IndexOf(algos, algo) - 1]; } } }
public static double TEST(double a, double b, algorithm function) { return(function(a, b)); }
static int TEST(int a, int b, algorithm function) { //调用委托 return(function(a, b)); }