private static void RunApplication(MainAlgorithm <int> a) { BackpackDemo.GenerateRandomItems(); Genome <int> Result = a.Evolve(BackpackDemo.GenerateRandomSolutions(PopulationSize)); Console.WriteLine("Picked Items:"); Console.WriteLine(); foreach (Item t in Result.ItemsPicked) { Console.WriteLine(t.Name + " " + "\t" + " (Worth:" + t.Worth + ") " + "\t" + "(Weight:" + t.Weight + ")"); } Console.WriteLine(); Console.WriteLine("MaxWeight: " + FitnessFunction.MaxValue); Console.WriteLine("Current Weight: " + Result.ItemsPicked.Sum(t => t.Weight)); Console.WriteLine("Current Worth: " + Result.ItemsPicked.Sum(t => t.Worth)); Console.WriteLine(); Console.WriteLine("Weight of all Items: " + ExtractItemsFromInt32Value.Selection.Sum(t => t.Weight)); Console.WriteLine("Worth of all Items: " + ExtractItemsFromInt32Value.Selection.Sum(t => t.Worth)); Console.ReadKey(); ClearLists(Result); Console.Clear(); RunApplication(new MainAlgorithm <int>(CrossoverProbability, MutationProbability, PopulationSize, GenerationCount, ExtractItemsFromInt32Value.Sort, FitnessFunction.CalculateFitness, Breeding.Crossover, Breeding.Mutation)); }
public JsonResult GetNextStepPassengers(Passenger[][] passengers) { PassengersHelper.SetNeighborsPassengers(passengers, passengerBehaviour); MainAlgorithm.Run(passengers); PassengersHelper.ClearNeighborsPassengers(passengers); return(new JsonResult(new { passengers })); }
public List <string> GetRandomVerteciesFromVertex3(string source, string categoryName) { try { MainAlgorithm mainAlgorithm = new MainAlgorithm(); List <string> moreVertecies = new List <string>(); moreVertecies = mainAlgorithm.getFourMoreRandom(source, categoryName); return(moreVertecies); } catch (Exception ex) { throw new Exception("problem with networkGetRandomVerteciesFromVertex3, the error: " + ex); } }
public IEnumerable <List <string> > StartAGame(string categoryName) { try { MainAlgorithm mainAlgorithm = new MainAlgorithm(); List <List <string> > StartPaths = new List <List <string> >(); StartPaths = mainAlgorithm.StartAGame(categoryName); return(StartPaths); } catch (Exception ex) { throw new Exception("problem with StartAGame, the error: " + ex); } }
public IEnumerable <List <string> > GetPaths(string source, string target, string categoryName) { try { MainAlgorithm mainAlgorithm = new MainAlgorithm(); List <List <string> > TwoPaths = new List <List <string> >(); //TwoPaths = mainAlgorithm.GetPath(source, target, categoryName); TwoPaths = mainAlgorithm.GetPath(source, target, categoryName); return(TwoPaths); } catch (Exception ex) { throw new Exception("problem with GetTwoPaths, the error: " + ex); } }
//random vertecies from the same category public string[] GetRandomVertecies(string categoryName) { try { MainAlgorithm mainAlgorithm = new MainAlgorithm(); string[] randomVertecies = new string[6]; randomVertecies = mainAlgorithm.GetRandomVertecies(categoryName); return(randomVertecies); } catch (Exception ex) { throw new Exception("problem with GetRandomVertecies, the error: " + ex); } }
// GET: api/Network public IEnumerable <List <string> > Get100Paths() { try { MainAlgorithm mainAlgorithm = new MainAlgorithm(); List <List <string> > literalPaths = new List <List <string> >(); List <int> pathsCount = new List <int>(); pathsCount = mainAlgorithm.GetPathsSimple(ref literalPaths); return(literalPaths); } catch (Exception ex) { throw new Exception("problem with get100paths, the error: " + ex); } }
// GET: api/Network public IEnumerable <List <string> > Get100Paths() { try { MainAlgorithm mainAlgorithm = new MainAlgorithm(); List <List <string> > literalPaths = new List <List <string> >(); List <int> pathsCount = new List <int>(); //pathsCount = mainAlgorithm.GetPathsSimple(ref literalPaths); // האם הפונקציה גט פאס סימפל רלוונטית?? // לפי איך שהיא נראית במיין אלגוריתם היא עובדת עם טבלה ספציפית של פוליטיקאים return(literalPaths); } catch (Exception ex) { throw new Exception("problem with get100paths, the error: " + ex); } }