public IActionResult DeleteProgramType(int id)
        {
            ProgramTypes programType = _db.ProgramTypes.Find(id);

            _db.ProgramTypes.Remove(programType);
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #2
0
 public Configuration(string logfilepath, string solutionfilepath, int randomseed, int numberofruns, ProgramTypes programtype)
 {
     this.logfilepath = logfilepath;
       this.solutionfilepath = solutionfilepath;
       this.randomseed = randomseed;
       this.numberofruns = numberofruns;
       this.programtype = programtype;
       this.numberofevals = 1;
       this.sequencelength = 1;
       this.memorylength = 0;
       this.maxtreedepth = 1;
 }
Beispiel #3
0
 public Configuration()
 {
     this.logfilepath = "";
       this.solutionfilepath = "";
       this.randomseed = 0;
       this.numberofruns = 1;
       this.numberofevals = 1;
       this.programtype = ProgramTypes.RANDOM;
       this.sequencelength = 1;
       this.memorylength = 0;
       this.maxtreedepth = 1;
 }
        public IActionResult EditProgramType(ProgramTypes programType)
        {
            ProgramTypes updateProgramType = _db.ProgramTypes.SingleOrDefault(i => i.ProgramTypeId == programType.ProgramTypeId);

            if (updateProgramType != null)
            {
                updateProgramType.Name = programType.Name;
                _db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ProgramTypes = await _context.ProgramTypes.SingleOrDefaultAsync(m => m.Id == id);

            if (ProgramTypes == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ProgramTypes = await _context.ProgramTypes.FindAsync(id);

            if (ProgramTypes != null)
            {
                _context.ProgramTypes.Remove(ProgramTypes);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Beispiel #7
0
        public bool loadFromFile(string path)
        {
            StreamReader infile;
              try
              {
            infile = new StreamReader(path);
              }
              catch(Exception e)
              {
            Console.WriteLine("Load ConfigFile Exception: " + e.Message);
            return false;
              }

              string algortype = infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1];
              Console.WriteLine(algortype);
              if(algortype.ToUpper() == "RANDOM")
              {
            this.programtype = ProgramTypes.RANDOM;
            this.randomseed = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.numberofruns = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.numberofevals = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.sequencelength = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.memorylength = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.maxtreedepth = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.logfilepath = infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1];
            this.solutionfilepath = infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1];
              }
              else if(algortype.ToUpper() == "GP")
              {
            this.programtype = ProgramTypes.GP;
            this.randomseed = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.numberofruns = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.numberofevals = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.populationsize = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.childrensize = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.sequencelength = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.memorylength = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.maxtreedepth = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.usefitnessproportionalforparent = Convert.ToBoolean(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.useoverselectionforparent = Convert.ToBoolean(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.usetruncationforsurvival = Convert.ToBoolean(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.usektournamentforsurvival = Convert.ToBoolean(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.survivaltournamentsize = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.parsimonypressure = Convert.ToDouble(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.terminationconvergence = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.logfilepath = infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1];
            this.solutionfilepath = infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1];
            if(this.sequencelength < 3 * this.memorylength)
              throw new Exception("Can't run GP algorithm when sequencelength is less than 3 * memorylength.");
              }
              else
              {
            throw new Exception("Invalid program type: " + algortype);
              }

              return true;
        }
Beispiel #8
0
 public ProgramAttribute(ProgramTypes programtype)
 {
     ProgramType = programtype;
 }
Beispiel #9
0
        public bool loadFromFile(string path)
        {
            StreamReader infile;
              try
              {
            infile = new StreamReader(path);
              }
              catch(Exception e)
              {
            Console.WriteLine("Load ConfigFile Exception: " + e.Message);
            return false;
              }

              string algortype = infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1];
              Console.WriteLine(algortype);
              if(algortype.ToUpper() == "RANDOM")
              {
            this.programtype = ProgramTypes.RANDOM;
            this.randomseed = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.numberofruns = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.numberofevals = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.sequencelength = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.memorylength = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.maxtreedepth = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]);
            this.logfilepath = infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1];
            this.solutionfilepath = infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1];
              }
              else
              {
            throw new Exception("Invalid program type: " + algortype);
              }

              return true;
        }
        public IActionResult EditProgramTypeView(int id)
        {
            ProgramTypes programType = _db.ProgramTypes.Find(id);

            return(View(programType));
        }
 public IActionResult AddProgramType(ProgramTypes programType)
 {
     _db.ProgramTypes.Add(programType);
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }