コード例 #1
0
        // GET: Training/Delete/5
        public ActionResult Delete(int id)
        {
            training tr = trs.getOneTraining(id);

            trs.DeleteTraining(id);
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            training t = trainingService.GetById(id);

            trainingService.Delete(t);
            trainingService.Commit();
            return(RedirectToAction("Index"));
        }
コード例 #3
0
    // Start is called before the first frame update
    public void trainingStart()
    {
        // Crée des gènes randoms
        int size = batches * carsPerBatch;

        genes = new training[size];
        for (int i = 0; i < size; i++)
        {
            genes[i] = new training(layers);
        }
        newBatch();
    }
コード例 #4
0
 public ActionResult Create(training t)
 {
     if (ModelState.IsValid)
     {
         trs.addTraining(t);
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View());
     }
 }
コード例 #5
0
        public ActionResult Edit(int id, training train)
        {
            training tr = trs.getOneTraining(id);

            tr.lieu          = train.lieu;
            tr.dateDebut     = train.dateDebut;
            tr.dateFin       = train.dateFin;
            tr.nombreInscrit = train.nombreInscrit;
            tr.theme         = train.theme;
            trs.UpdateTraining(tr);
            return(RedirectToAction("Index"));
        }
コード例 #6
0
        public bool AddTrainings(string userId, string trainings, int TPID)
        {
            trainer         trainer         = db.trainer.FirstOrDefault(x => x.ID == userId);
            trainingProgram trainingProgram = db.trainingProgram.FirstOrDefault(x => x.TPID == TPID);

            if (trainer.TRID != trainingProgram.trainer_TRID)
            {
                return(false);
            }
            else
            {
                try
                {
                    List <int> TIDList       = new List <int>();
                    var        trainingArray = JsonConvert.DeserializeObject <List <TrainingDTO> >(trainings);
                    foreach (TrainingDTO x in trainingArray)
                    {
                        var t = new training
                        {
                            exercise_EID   = x.exercise_EID,
                            numberOfSets   = x.numberOfSets == null ? null : x.numberOfSets,
                            numberOfReps   = x.numberOfReps == null ? null : x.numberOfReps,
                            durationMin    = x.durationMin == null ? null : x.durationMin,
                            restBetweenMin = x.restBetweenMin == null ? null : x.restBetweenMin,
                            sunday         = x.sunday,
                            monday         = x.monday,
                            tuesday        = x.tuesday,
                            wednesday      = x.wednesday,
                            thursday       = x.thursday,
                            friday         = x.friday,
                            saturday       = x.saturday,
                            className      = x.className,
                            timeOfDay      = x.timeOfDay
                        };
                        db.training.Add(t);
                        db.SaveChanges();
                        TIDList.Add(t.TID);
                    }
                    foreach (int x in TIDList)
                    {
                        db.trainingProgramTraining.Add(new trainingProgramTraining {
                            trainingProgram_TPID = TPID, training_TID = x
                        });
                    }
                    db.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
コード例 #7
0
        public ActionResult Edit(int id, Training model)
        {
            training t = trainingService.GetById(id);

            t.Former     = model.Former;
            t.Start_date = model.Start_date;
            t.End_date   = model.End_date;
            t.Place      = model.Place;
            t.Price      = model.Price;
            trainingService.Update(t);
            trainingService.Commit();
            return(RedirectToAction("Index"));
        }
コード例 #8
0
        // GET: Training/Edit/5
        public ActionResult Edit(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            training train = trs.getOneTraining(id);

            if (train == null)
            {
                return(HttpNotFound());
            }
            return(View(train));
        }
コード例 #9
0
        // GET: Training/Edit/5
        public ActionResult Edit(int id)
        {
            training t     = trainingService.GetById(id);
            Training model = new Training
            {
                Former     = t.Former,
                Start_date = t.Start_date,
                End_date   = t.End_date,
                Place      = t.Place,
                Price      = t.Price
            };

            return(View(model));
        }
コード例 #10
0
        public ActionResult Create(Training model)
        {
            training t = new training
            {
                Former     = model.Former,
                Start_date = model.Start_date,
                End_date   = model.End_date,
                Place      = model.Place,
                Price      = model.Price
            };

            trainingService.Add(t);
            trainingService.Commit();

            return(RedirectToAction("Index"));
        }
コード例 #11
0
        // GET: Project/Delete/5
        public ActionResult Delete(int id)
        {
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("http://localhost:9080");
            client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
            HttpResponseMessage response = client.GetAsync("Advyteam-web/api/training" + id).Result;
            training            training = new training();

            if (response.IsSuccessStatusCode)
            {
                training = response.Content.ReadAsAsync <training>().Result;
            }
            else
            {
                ViewBag.training = "erreur";
            }

            return(View(training));
        }
コード例 #12
0
 private void button3_Click(object sender, EventArgs e)
 {
     this.Close();
     training t = new training();
     t.Show();
 }
コード例 #13
0
 public void UpdateTraining(training tr)
 {
     utwk.TrainingRepository.Update(tr);
 }
コード例 #14
0
 public void addTraining(training t)
 {
     utwk.TrainingRepository.Add(t);
     utwk.Commit();
 }
コード例 #15
0
 public int Change(training t)
 {
     return(dao.Change(t));
 }
コード例 #16
0
 public int Add(training t)
 {
     return(dao.Add(t));
 }
コード例 #17
0
 public int Del(training t)
 {
     return(dao.Del(t));
 }
コード例 #18
0
    public void sendDeath(int id, float score)       // Nous informe qu'une voiture est morte
    {
        this.aliveCars--;
        updateTextInfo();
        genes[id].score = score;
        if (this.aliveCars == 0)           // Toutes les voitures sont mortes
        {
            if (currentBatch < batches)
            {
                newBatch();
                return;
            }
        }
        else
        {
            return;             // On attend que tout le monde meurt
        }
        // On repère les 3 meilleurs
        int size = batches * carsPerBatch;

        int[]   bestIds    = { 0, 0, 0 };
        float[] bestScores = { 0f, 0f, 0f };


        for (int i = 0; i < size; i++)
        {
            bool done = false;
            for (int iBest = 0; iBest < 3; iBest++)
            {
                if (!done && (genes[i].score > bestScores[iBest]))
                {
                    shiftIntArray(bestIds, iBest);
                    bestIds[iBest] = i;
                    shiftFloatArray(bestScores, iBest);
                    bestScores[iBest] = genes[i].score;
                    done = true;
                }
            }
        }



        // Premiers candidats: les 3 meilleurs de la dernière génération
        training[] nextGen = new training[size];

        for (int i = 0; i < 3; i++)
        {
            nextGen[i] = new training(genes[bestIds[i]].brain);
        }

        // Quetrième: gènes avec la moyenne de toutes les voitures, pondérée avec leur score.

        // On est obligé de séparer en 2 tableaux
        gene[] genesOnly = new gene[size];
        for (int i = 0; i < size; i++)
        {
            genesOnly[i] = genes[i].brain;
        }
        float[] scoresOnly = new float[size];
        for (int i = 0; i < size; i++)
        {
            scoresOnly[i] = genes[i].score;
        }


        nextGen[3] = new training(gene.weightedAverage(genesOnly, scoresOnly));

        // Cinquième: gènes avec la moyenne non pondérée de toutes les coitures
        float[] one = new float[size];
        for (int i = 0; i < size; i++)
        {
            one[i] = 1f;
        }

        nextGen[4] = new training(gene.weightedAverage(genesOnly, one));

        // Six et septième: idem mais avec les 3 premiers seulement
        gene[]  bo3Genes = new gene[3];
        float[] bo3one   = { 1f, 1f, 1f };
        for (int i = 0; i < 3; i++)
        {
            bo3Genes[i] = genes[bestIds[i]].brain;
        }

        nextGen[5] = new training(gene.weightedAverage(bo3Genes, bestScores));
        nextGen[6] = new training(gene.weightedAverage(bo3Genes, bo3one));

        // Pour les autres, soit on:
        // - Met un nouveau gène aléatoire
        // - Fait une moyenne sur tous les gènes pondérée aléatoirement

        for (int i = 7; i < size; i++)
        {
            // Pour les 2 cas, on regarde la parité de i
            if ((i % 2) == 1)
            {
                // Nouveau gène aléatoire
                nextGen[i] = new training(layers);
            }
            else
            {
                // Moyenne pondérée aléatoire
                float[] randomWeights = new float[size];
                for (int iWeight = 0; iWeight < size; iWeight++)
                {
                    randomWeights[iWeight] = Random.Range(0f, 100f);
                }
                nextGen[i] = new training(gene.weightedAverage(genesOnly, randomWeights));
            }
        }

        generation++;
        genes        = nextGen;
        currentBatch = 0;

        // On scale le cooldown checkpoint
        cpCooldown *= generationCooldownScale;
        if (cpCooldown < finalCpCooldown)
        {
            cpCooldown = finalCpCooldown;
        }
        newBatch();
    }
コード例 #19
0
 public training SelectOne(training us)
 {
     return(ist.SelectBy(e => e.tra_id == us.tra_id)[0]);
 }
コード例 #20
0
 public bool Upd(training us)
 {
     return(ist.Upd(us));
 }
コード例 #21
0
 public bool Add(training us)
 {
     return(ist.Add(us));
 }
コード例 #22
0
 public bool Del(training us)
 {
     return(ist.Del(us));
 }
コード例 #23
0
 void Start()
 {
     training = GameObject.Find("Training Canvas").GetComponent <training>();
 }