Example #1
0
        private Matrice Simulation(Matrice Er, Matrice Vol, Decomposition decompo, int observ)
        {
            int     n          = decompo.L.Colonnes; // nombre de titres
            Matrice Historique = new Matrice(observ, n);

            Random rand = new Random();

            for (int i = 0; i < observ; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    double p = (double)rand.Next(1, int.MaxValue) / int.MaxValue;
                    Historique[i, j] = Statistique.NormInv(0, 1, p);
                }
            }

            Historique = Historique.Mult(decompo.U);

            for (int i = 0; i < observ; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    Historique[i, j] = Er[j, 0] + Historique[i, j] * Vol[j, 0];
                }
            }

            return(Historique);
        }
Example #2
0
        // Méthode calculant la VaR historique
        public override Tuple <double, double> Calcul()
        {
            double VaR_result  = 0;
            double Cvar_result = 0;
            int    position    = 0;

            if (Math.Floor(alpha * Actions.Lignes) == alpha * Actions.Lignes)
            {
                position = (int)(alpha * Actions.Lignes);
            }
            else
            {
                position = (int)Math.Floor(alpha * Actions.Lignes) + 1;
            }



            rendements = new Matrice(Actions.Lignes - 1, Actions.Colonnes);
            double[] VaR_actif  = new double[Actions.Colonnes];
            double[] Cvar_actif = new double[Actions.Colonnes];
            // Calcul des VaR individuelles
            for (int j = 0; j < Actions.Colonnes; j++)
            {
                for (int i = 1; i < Actions.Lignes; i++)
                {
                    rendements[i - 1, j] = (Actions[i, j] - Actions[i - 1, j]) / Actions[i - 1, j];
                }

                List <double> rendement_tri = new List <double>();

                for (int i = 0; i < Actions.Lignes - 1; i++)
                {
                    rendement_tri.Add(rendements[i, j]);
                }

                rendement_tri.Sort();


                VaR_actif[j]  = rendement_tri[position - 1]; // On récupére la VaR de l'actif seul; -1 car le tableau est indexé à 0
                Cvar_actif[j] = CalculCvarFromSorted(rendement_tri);
                VaR_result   += VaR_actif[j] * VaR_actif[j] * CompanyTab[j].Weight * CompanyTab[j].Weight;
                Cvar_result  += Cvar_actif[j] * Cvar_actif[j] * CompanyTab[j].Weight * CompanyTab[j].Weight;
            }
            ;



            // Calcul des corrélations entre les actifs
            for (int j = 0; j < Actions.Colonnes; j++)
            {
                for (int k = j + 1; k < Actions.Colonnes; k++)
                {
                    // Corrélation entre l'entreprise j et l'entreprise k
                    VaR_result  += 2 * Statistique.Correlation(rendements, j, k) * VaR_actif[j] * CompanyTab[j].Weight * VaR_actif[k] * CompanyTab[k].Weight;
                    Cvar_result += 2 * Statistique.Correlation(rendements, j, k) * Cvar_actif[j] * CompanyTab[j].Weight * Cvar_actif[k] * CompanyTab[k].Weight;
                }
            }

            return(new Tuple <double, double> (-Math.Sqrt(VaR_result), -Math.Sqrt(Cvar_result)));
        }
Example #3
0
        public override Tuple <double, double> Calcul()
        {
            double VaR_result  = 0;
            double Cvar_result = 0;
            int    position    = 0;

            if (Math.Floor(alpha * Actions.Lignes) == alpha * Actions.Lignes)
            {
                position = (int)(alpha * Actions.Lignes);
            }
            else
            {
                position = (int)Math.Floor(alpha * Actions.Lignes) + 1;
            }

            rendements = new Matrice(Actions.Lignes - 1, Actions.Colonnes);

            Matrice Er   = new Matrice(Actions.Lignes);
            Matrice Vol  = new Matrice(Actions.Lignes);
            Matrice Corr = new Matrice(Actions.Colonnes, Actions.Colonnes);

            for (int j = 0; j < Actions.Colonnes; j++)
            {
                for (int i = 1; i < Actions.Lignes; i++)
                {
                    rendements[i - 1, j] = (Actions[i, j] - Actions[i - 1, j]) / Actions[i - 1, j];
                }

                Er[j, 0]  = Statistique.Moyenne(rendements, j);
                Vol[j, 0] = Statistique.EcartType(rendements, j);
            }



            double[] VaR_actif  = new double[Actions.Colonnes];
            double[] Cvar_actif = new double[Actions.Colonnes];
            for (int j = 0; j < Actions.Colonnes; j++)
            {
                VaR_actif[j]  = Statistique.NormInv(Er[j, 0], Vol[j, 0], alpha);
                Cvar_actif[j] = Statistique.Moyenne(rendements, j) - (1 / alpha) * (1 / Math.Sqrt(Math.PI)) * Math.Exp(-0.5 * Statistique.NormInv(0, 1, alpha) * Statistique.NormInv(0, 1, alpha)) * Statistique.EcartType(rendements, j);
                VaR_result   += VaR_actif[j] * VaR_actif[j] * CompanyTab[j].Weight * CompanyTab[j].Weight;
                Cvar_result  += Cvar_actif[j] * Cvar_actif[j] * CompanyTab[j].Weight * CompanyTab[j].Weight;
            }

            // Calcul des corrélations entre les actifs
            for (int j = 0; j < Actions.Colonnes; j++)
            {
                for (int k = j + 1; k < Actions.Colonnes; k++)
                {
                    // Corrélation entre l'entreprise j et l'entreprise k
                    VaR_result  += 2 * Statistique.Correlation(rendements, j, k) * VaR_actif[j] * CompanyTab[j].Weight * VaR_actif[k] * CompanyTab[k].Weight;
                    Cvar_result += 2 * Statistique.Correlation(rendements, j, k) * Cvar_actif[j] * CompanyTab[j].Weight * Cvar_actif[k] * CompanyTab[k].Weight;
                }
            }



            return(new Tuple <double, double>  (-Math.Sqrt(VaR_result), -Math.Sqrt(Cvar_result)));
        }
 public MainViewModel(int _Dim = 50)
 {
     Dim              = _Dim;
     Terrain          = new Terrain(Dim);
     Statistique      = new Statistique(Terrain);
     TitreApplication = "Fourmilière MOC 2";
     VitesseExec      = 200;
 }
Example #5
0
 public void Click_StatsMenu()
 {
     if (Statistique.activeSelf == true)
     {
         Statistique.SetActive(false);
     }
     else
     {
         Statistique.SetActive(true);
     }
 }
Example #6
0
        public ActionResult Budget()
        {
            statistiqueTotalService          = new StatistiqueTotalService();
            statistiqueLivraisonCarteService = new StatistiqueLivraisonCarteService();
            List <StatistiqueTotal>          listStatistique          = statistiqueTotalService.getAll();
            List <StatistiqueLivraisonCarte> listStatistiqueLivraison = statistiqueLivraisonCarteService.getAll();
            List <PourcentageVenteCarte>     listPourcenteCarte       = new Statistique().getPourcentageVenteCarte(listStatistique,
                                                                                                                   listStatistiqueLivraison);

            ViewBag.ListStatistique = listStatistique;
            ViewBag.ListPourcentage = listPourcenteCarte;
            return(View());
        }
        private void Path_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            int x = int.Parse((((Path)sender).Name).Remove(0, 1));

            if (preference.IndexOf(true) < 0)
            {
                MessageBoxAlert.Show("Vous devez sélectionner au moins une préférence.", "");
            }
            else
            {
                Statistique stat = new Statistique(x, preference);
                stat.Show();
            }
        }
Example #8
0
        public void CreerNouveauPersonnage(string name)
        {
            Personnage persoNiveau1 = new Personnage();

            Statistique statsNiveau1 = new Statistique(1, 1, 1, 1, 1, 1, 1, 1, 1);

            persoNiveau1.StatistiquesNaturelles = statsNiveau1;
            persoNiveau1.Niveau    = 1;
            persoNiveau1.Nom       = name;
            persoNiveau1.MaxHP     = 55;
            persoNiveau1.CurrentHP = 55;
            persoNiveau1.Batiments = new List <Batiment>();
            persoNiveau1.Or        = 50;
            persoNiveau1.Position  = new Position(1, 1, 1);
            persoNiveau1.Squadd    = null;
            persoNiveau1.XP        = 0;

            using (personnageDao)
            {
                personnageDao.CreatePersonnage(persoNiveau1);
            }
        }
        ///!!!!!!!!!!!!!!!!!!!!---------statistique-----------!!!!!!!!!!\\\
        public ActionResult Statistique3A()
        {
            if (isAdmin())
            {
                List <Statistique> statistiquesPre      = new List <Statistique>();
                List <Statistique> statistiquesConvoque = new List <Statistique>();

                List <Filiere> filieres = new List <Filiere>();

                Statistique statPerDiplomPre  = new Statistique();
                Statistique statPerDiplomConv = new Statistique();



                filieres = statistique.GetFilieres();
                foreach (var f in filieres)
                {
                    statistiquesPre.Add(new Statistique
                    {
                        nbDeug       = statistique.getCandidatPreisncrit(f.ID, "deug", 3),
                        nbDut        = statistique.getCandidatPreisncrit(f.ID, "dut", 3),
                        nbLicenceFnd = statistique.getCandidatPreisncrit(f.ID, "Lic.fnd", 3),
                        nbLicencePro = statistique.getCandidatPreisncrit(f.ID, "Lic.pro", 3),
                        nbLicenceSt  = statistique.getCandidatPreisncrit(f.ID, "Lic.st", 3),
                        nomFiliere   = f.Nom
                    });
                    statistiquesConvoque.Add(new Statistique
                    {
                        nbDeug       = statistique.getCandidatConv(f.ID, "deug", 3),
                        nbDut        = statistique.getCandidatConv(f.ID, "dut", 3),
                        nbLicenceFnd = statistique.getCandidatConv(f.ID, "Lic.fnd", 3),
                        nbLicencePro = statistique.getCandidatConv(f.ID, "Lic.pro", 3),
                        nbLicenceSt  = statistique.getCandidatConv(f.ID, "Lic.st", 3),
                        nomFiliere   = f.Nom
                    });
                }
                statPerDiplomPre = new Statistique
                {
                    nbDeug       = statistique.getNbCandidatPerDiplome("deug", 3),
                    nbDut        = statistique.getNbCandidatPerDiplome("dut", 3),
                    nbLicenceFnd = statistique.getNbCandidatPerDiplome("Lic.fnd", 3),
                    nbLicenceSt  = statistique.getNbCandidatPerDiplome("Lic.st", 3),
                    nbLicencePro = statistique.getNbCandidatPerDiplome("Lic.pro", 3),
                };
                statPerDiplomConv = new Statistique
                {
                    nbDeug       = statistique.getNbCandidatPerDiplomeConv("deug", 3),
                    nbDut        = statistique.getNbCandidatPerDiplomeConv("dut", 3),
                    nbLicenceFnd = statistique.getNbCandidatPerDiplomeConv("Lic.fnd", 3),
                    nbLicenceSt  = statistique.getNbCandidatPerDiplomeConv("Lic.st", 3),
                    nbLicencePro = statistique.getNbCandidatPerDiplomeConv("Lic.pro", 3),
                };


                ViewData["statistiquesPre"]      = statistiquesPre;
                ViewData["statistiquesConvoque"] = statistiquesConvoque;
                ViewBag.statPerDiplomPre         = statPerDiplomPre;
                ViewBag.statPerDiplomConv        = statPerDiplomConv;
                return(View());
            }
            return(RedirectToAction("Login", "AdminAuth"));
        }
 public StatistiqueService(DataContext context)
 {
     _context     = context;
     statistiquea = new Statistique();
     statistiqueb = new Statistique();
 }
        public ActionResult Statistique4ApresConcour()
        {
            if (isAdmin())
            {
                List <Statistique> statistiquesPresent   = new List <Statistique>();
                List <Statistique> statistiquesPrincipal = new List <Statistique>();
                List <Statistique> statistiquesAttente   = new List <Statistique>();


                List <Filiere> filieres = new List <Filiere>();

                Statistique statPerDiplomPresent    = new Statistique();
                Statistique statPerDiplomPrincipale = new Statistique();
                Statistique statPerDiplomAtt        = new Statistique();



                filieres = statistique.GetFilieres();
                foreach (var f in filieres)
                {
                    statistiquesPresent.Add(new Statistique
                    {
                        nbDeug       = statistique.getCandidatPresent(f.ID, "deug", 4),
                        nbDut        = statistique.getCandidatPresent(f.ID, "dut", 4),
                        nbLicenceFnd = statistique.getCandidatPresent(f.ID, "Lic.fnd", 4),
                        nbLicencePro = statistique.getCandidatPresent(f.ID, "Lic.pro", 4),
                        nbLicenceSt  = statistique.getCandidatPresent(f.ID, "Lic.st", 4),
                        nomFiliere   = f.Nom
                    });
                    statistiquesPrincipal.Add(new Statistique
                    {
                        nbDeug       = statistique.getCandidatPrincipale(f.ID, "deug", 4),
                        nbDut        = statistique.getCandidatPrincipale(f.ID, "dut", 4),
                        nbLicenceFnd = statistique.getCandidatPrincipale(f.ID, "Lic.fnd", 4),
                        nbLicencePro = statistique.getCandidatPrincipale(f.ID, "Lic.pro", 4),
                        nbLicenceSt  = statistique.getCandidatPrincipale(f.ID, "Lic.st", 4),
                        nomFiliere   = f.Nom
                    });
                    statistiquesAttente.Add(new Statistique
                    {
                        nbDeug       = statistique.getCandidatListeAtt(f.ID, "deug", 4),
                        nbDut        = statistique.getCandidatListeAtt(f.ID, "dut", 3),
                        nbLicenceFnd = statistique.getCandidatListeAtt(f.ID, "Lic.fnd", 4),
                        nbLicencePro = statistique.getCandidatListeAtt(f.ID, "Lic.pro", 4),
                        nbLicenceSt  = statistique.getCandidatListeAtt(f.ID, "Lic.st", 4),
                        nomFiliere   = f.Nom
                    });
                }
                statPerDiplomPresent = new Statistique
                {
                    nbDeug       = statistique.getNbCandidatPresentPerDiplome("deug", 4),
                    nbDut        = statistique.getNbCandidatPresentPerDiplome("dut", 4),
                    nbLicenceFnd = statistique.getNbCandidatPresentPerDiplome("Lic.fnd", 4),
                    nbLicenceSt  = statistique.getNbCandidatPresentPerDiplome("Lic.st", 4),
                    nbLicencePro = statistique.getNbCandidatPresentPerDiplome("Lic.pro", 4),
                };
                statPerDiplomPrincipale = new Statistique
                {
                    nbDeug       = statistique.getNbCandidatPrincipalPerDiplome("deug", 4),
                    nbDut        = statistique.getNbCandidatPrincipalPerDiplome("dut", 4),
                    nbLicenceFnd = statistique.getNbCandidatPrincipalPerDiplome("Lic.fnd", 4),
                    nbLicenceSt  = statistique.getNbCandidatPrincipalPerDiplome("Lic.st", 4),
                    nbLicencePro = statistique.getNbCandidatPrincipalPerDiplome("Lic.pro", 4),
                };
                statPerDiplomAtt = new Statistique
                {
                    nbDeug       = statistique.getNbCandidatAttPerDiplome("deug", 4),
                    nbDut        = statistique.getNbCandidatAttPerDiplome("dut", 4),
                    nbLicenceFnd = statistique.getNbCandidatAttPerDiplome("Lic.fnd", 4),
                    nbLicenceSt  = statistique.getNbCandidatAttPerDiplome("Lic.st", 4),
                    nbLicencePro = statistique.getNbCandidatAttPerDiplome("Lic.pro", 4),
                };



                ViewData["statistiquesPresent"]   = statistiquesPresent;
                ViewData["statistiquesPrincipal"] = statistiquesPrincipal;
                ViewData["statistiquesAttente"]   = statistiquesAttente;
                ViewBag.statPerDiplomPresent      = statPerDiplomPresent;
                ViewBag.statPerDiplomPrincipale   = statPerDiplomPrincipale;
                ViewBag.statPerDiplomAtt          = statPerDiplomAtt;
                return(View());
            }
            return(RedirectToAction("Login", "AdminAuth"));
        }
 internal void MiseAjour()
 {
     Terrain.MiseAjour();
     Statistique.MiseAjour();
     // Statistique = Statistique.GetStatistique();
 }
        private void OuvrirFichier()
        {
            App.MainVM.stop();
            while (App.MainVM.Runnin)
            {
            }

            OpenFileDialog OFDialog = new OpenFileDialog();

            OFDialog.InitialDirectory = Convert.ToString(Environment.SpecialFolder.MyDocuments);
            OFDialog.DefaultExt       = "xml";
            OFDialog.Filter           = "XML Files|*.xml|All Files|*.*";
            OFDialog.FilterIndex      = 1;
            if (OFDialog.ShowDialog() == true && OFDialog.FileName.Length > 0)
            {
                // CHARGER LE FICHIER ET VERIFIER SA VALIDITE
                XmlDocument Chargement = new XmlDocument();
                Chargement.Load(OFDialog.FileName);
                XmlNode MainVMXML;
                if ((MainVMXML = Chargement.SelectSingleNode("MainVM")) == null)
                {
                    System.Media.SystemSounds.Beep.Play();
                    MessageBox.Show("Fichier incompatible !", "Chargement", MessageBoxButton.OK);
                    return;
                }

                // RECUPERER DATA DE MAINVM
                int    Dim = int.Parse(MainVMXML.SelectSingleNode("Dim").InnerText);
                String TitreApplication = MainVMXML.SelectSingleNode("TitreApplication").InnerText;
                int    VitesseExec      = int.Parse(MainVMXML.SelectSingleNode("VitesseExec").InnerText);
                bool   Runnin           = bool.Parse(MainVMXML.SelectSingleNode("Runnin").InnerText);

                Terrain Terrain = new Terrain(Dim);

                // RECUPERER DATA DE TERRAIN
                XmlNode TerrainXML     = MainVMXML.SelectSingleNode("Terrain");
                int     NbToursTerrain = int.Parse(TerrainXML.SelectSingleNode("NbTours").InnerText);
                XmlNode CasesXML       = TerrainXML.SelectSingleNode("Cases");
                foreach (XmlNode CaseXML in CasesXML.SelectNodes("Case"))
                {
                    CaseAbstrait Case;
                    String       CaseClass           = CaseXML.SelectSingleNode("Class").InnerText;
                    int          CordX               = int.Parse(CaseXML.SelectSingleNode("CordX").InnerText);
                    int          CordY               = int.Parse(CaseXML.SelectSingleNode("CordY").InnerText);
                    int          PheromoneMaison     = int.Parse(CaseXML.SelectSingleNode("PheromoneMaison").InnerText);
                    int          PheromoneNourriture = int.Parse(CaseXML.SelectSingleNode("PheromoneNourriture").InnerText);
                    int          NbToursCase         = int.Parse(CaseXML.SelectSingleNode("NbTours").InnerText);

                    if (CaseClass == "CaseNourriture")
                    {
                        Case = new CaseNourriture(Terrain, CordX, CordY);
                        int        NourriturePoids = int.Parse(CaseXML.SelectSingleNode("Nourriture/Poids").InnerText);
                        Nourriture Nourriture      = new Nourriture(Case, NourriturePoids);
                        ((CaseNourriture)Case).Nourriture = Nourriture;
                    }
                    else if (CaseClass == "CaseFourmiliere")
                    {
                        Case = new CaseFourmiliere(Terrain, CordX, CordY);
                        int         NombreNourritures      = int.Parse(CaseXML.SelectSingleNode("Fourmiliere/NombreNourritures").InnerText);
                        int         NombreToursFourmiliere = int.Parse(CaseXML.SelectSingleNode("Fourmiliere/NombreTours").InnerText);
                        Fourmiliere Fourmiliere            = new Fourmiliere(Case, 0);
                        Fourmiliere.NombreNourritures       = NombreNourritures;
                        Fourmiliere.NombreTours             = NombreToursFourmiliere;
                        ((CaseFourmiliere)Case).Fourmiliere = Fourmiliere;
                    }
                    else if (CaseClass == "CaseNormal")
                    {
                        Case = new CaseNormal(Terrain, CordX, CordY);
                    }
                    else
                    {
                        System.Media.SystemSounds.Beep.Play();
                        MessageBox.Show("Erreur au chargement", "Chargement", MessageBoxButton.OK);
                        return;
                    }
                    Case.PheromoneMaison     = PheromoneMaison;
                    Case.PheromoneNourriture = PheromoneNourriture;
                    Case.NbTours             = NbToursCase;

                    XmlNode FourmisXML = CaseXML.SelectSingleNode("Fourmis");
                    foreach (XmlNode FourmiXML in FourmisXML.SelectNodes("Fourmi"))
                    {
                        int    Vie             = int.Parse(FourmiXML.SelectSingleNode("Vie").InnerText);
                        String StrategieFourmi = FourmiXML.SelectSingleNode("StrategieFourmi").InnerText;
                        Fourmi Fourmi          = new Fourmi(Case);
                        Fourmi.Vie = Vie;
                        if (StrategieFourmi == "StrategieRetourMaison")
                        {
                            Fourmi.StrategieFourmi = new StrategieRetourMaison();
                        }
                        Case.Fourmis.Add(Fourmi);
                    }
                    Terrain.Cases[Case.CordX, Case.CordY] = Case;
                }
                Terrain.NbTours = NbToursTerrain;

                XmlNode StatistiqueXML         = MainVMXML.SelectSingleNode("Statistique");
                int     NombreFourmis          = int.Parse(StatistiqueXML.SelectSingleNode("NombreFourmis").InnerText);
                int     NombreToursStatistique = int.Parse(StatistiqueXML.SelectSingleNode("NombreTours").InnerText);

                Statistique Statistique = new Statistique(Terrain);
                Statistique.NombreFourmis = NombreFourmis;
                Statistique.NombreTours   = NombreToursStatistique;

                App.MainVM.Dim              = Dim;
                App.MainVM.Terrain          = Terrain;
                App.MainVM.TitreApplication = TitreApplication;
                App.MainVM.VitesseExec      = VitesseExec;
                App.MainVM.Statistique      = Statistique;
                DessinePlateau();
                System.Media.SystemSounds.Beep.Play();
                MessageBox.Show("Fichier Chargé !", "Chargement", MessageBoxButton.OK);
            }
        }
Example #14
0
        public ActionResult Statistique4ApresConcour()
        {
            if (Session["admin"] != null)
            {
                if (Session["admin"].Equals(true))
                {
                    List <Statistique> statistiquesPresent   = new List <Statistique>();
                    List <Statistique> statistiquesPrincipal = new List <Statistique>();
                    List <Statistique> statistiquesAttente   = new List <Statistique>();


                    List <Filiere> filieres = new List <Filiere>();

                    Statistique statPerDiplomPresent    = new Statistique();
                    Statistique statPerDiplomPrincipale = new Statistique();
                    Statistique statPerDiplomAtt        = new Statistique();


                    using (IStatistiques3AService dal = new Statistique3AImpl())
                    {
                        filieres = dal.GetFilieres();
                        foreach (var f in filieres)
                        {
                            statistiquesPresent.Add(new Statistique
                            {
                                nbDeug       = dal.getCandidatPresent(f.ID, "deug", 4),
                                nbDut        = dal.getCandidatPresent(f.ID, "dut", 4),
                                nbLicenceFnd = dal.getCandidatPresent(f.ID, "Lic.fnd", 4),
                                nbLicencePro = dal.getCandidatPresent(f.ID, "Lic.pro", 4),
                                nbLicenceSt  = dal.getCandidatPresent(f.ID, "Lic.st", 4),
                                nomFiliere   = f.Nom
                            });
                            statistiquesPrincipal.Add(new Statistique
                            {
                                nbDeug       = dal.getCandidatPrincipale(f.ID, "deug", 4),
                                nbDut        = dal.getCandidatPrincipale(f.ID, "dut", 4),
                                nbLicenceFnd = dal.getCandidatPrincipale(f.ID, "Lic.fnd", 4),
                                nbLicencePro = dal.getCandidatPrincipale(f.ID, "Lic.pro", 4),
                                nbLicenceSt  = dal.getCandidatPrincipale(f.ID, "Lic.st", 4),
                                nomFiliere   = f.Nom
                            });
                            statistiquesAttente.Add(new Statistique
                            {
                                nbDeug       = dal.getCandidatListeAtt(f.ID, "deug", 4),
                                nbDut        = dal.getCandidatListeAtt(f.ID, "dut", 3),
                                nbLicenceFnd = dal.getCandidatListeAtt(f.ID, "Lic.fnd", 4),
                                nbLicencePro = dal.getCandidatListeAtt(f.ID, "Lic.pro", 4),
                                nbLicenceSt  = dal.getCandidatListeAtt(f.ID, "Lic.st", 4),
                                nomFiliere   = f.Nom
                            });
                        }
                        statPerDiplomPresent = new Statistique
                        {
                            nbDeug       = dal.getNbCandidatPresentPerDiplome("deug", 4),
                            nbDut        = dal.getNbCandidatPresentPerDiplome("dut", 4),
                            nbLicenceFnd = dal.getNbCandidatPresentPerDiplome("Lic.fnd", 4),
                            nbLicenceSt  = dal.getNbCandidatPresentPerDiplome("Lic.st", 4),
                            nbLicencePro = dal.getNbCandidatPresentPerDiplome("Lic.pro", 4),
                        };
                        statPerDiplomPrincipale = new Statistique
                        {
                            nbDeug       = dal.getNbCandidatPrincipalPerDiplome("deug", 4),
                            nbDut        = dal.getNbCandidatPrincipalPerDiplome("dut", 4),
                            nbLicenceFnd = dal.getNbCandidatPrincipalPerDiplome("Lic.fnd", 4),
                            nbLicenceSt  = dal.getNbCandidatPrincipalPerDiplome("Lic.st", 4),
                            nbLicencePro = dal.getNbCandidatPrincipalPerDiplome("Lic.pro", 4),
                        };
                        statPerDiplomAtt = new Statistique
                        {
                            nbDeug       = dal.getNbCandidatAttPerDiplome("deug", 4),
                            nbDut        = dal.getNbCandidatAttPerDiplome("dut", 4),
                            nbLicenceFnd = dal.getNbCandidatAttPerDiplome("Lic.fnd", 4),
                            nbLicenceSt  = dal.getNbCandidatAttPerDiplome("Lic.st", 4),
                            nbLicencePro = dal.getNbCandidatAttPerDiplome("Lic.pro", 4),
                        };
                    }

                    ViewData["statistiquesPresent"]   = statistiquesPresent;
                    ViewData["statistiquesPrincipal"] = statistiquesPrincipal;
                    ViewData["statistiquesAttente"]   = statistiquesAttente;
                    ViewBag.statPerDiplomPresent      = statPerDiplomPresent;
                    ViewBag.statPerDiplomPrincipale   = statPerDiplomPrincipale;
                    ViewBag.statPerDiplomAtt          = statPerDiplomAtt;
                    return(View());
                }
            }
            return(RedirectToAction("Login", "AdminAuth"));
        }
        public async Task <Statistique> GetAllStatistiqueAsync()
        {
            //statistique.NbrTriturationTotal = await _context.Factures.Where(c => c.TypeFactureId == 1).CountAsync();
            var trituration = await _context.Factures.AsNoTracking().Include(c => c.Trituration).Where(c => c.TypeFactureId == 1).ToListAsync();

            foreach (var item in trituration)
            {
                statistiquea.MontantTriturationTotal = statistiquea.MontantTriturationTotal + item.Montant;
                statistiquea.NbrTriturationTotal     = statistiquea.NbrTriturationTotal + item.Trituration.Poids;
            }
            ////////////////////////////////////
            // statistique.NbrAchatTotal = await _context.Factures.Where(c => c.TypeFactureId == 2).CountAsync();
            var achats = await _context.Factures.Include(c => c.Achat).AsNoTracking().Where(c => c.TypeFactureId == 2).ToListAsync();

            foreach (var item in achats)
            {
                statistiquea.MontantAchatTotal = statistiquea.MontantAchatTotal + item.Montant;
                statistiquea.NbrAchatTotal     = statistiquea.NbrAchatTotal + item.Achat.QteAchete;
            }
            ////////////////////////////////////
            //statistique.NbrVenteTotal = await _context.Factures.Where(c => c.TypeFactureId == 3).CountAsync();
            var ventes = await _context.Factures.Include(c => c.VenteHuile).AsNoTracking().Where(c => c.TypeFactureId == 3).ToListAsync();

            foreach (var item in ventes)
            {
                statistiquea.MontantVenteTotal = statistiquea.MontantVenteTotal + item.Montant;
                statistiquea.NbrVenteTotal     = statistiquea.NbrVenteTotal + item.VenteHuile.Qte_Vente;
                // statistiquea.NbrVenteTotal = 0;
            }
            ///////////////////////////////////
            //statistique.NbrGrigonsTotal = await _context.Factures.Include(c => c.Grignon).Where(c => c.TypeFactureId == 4).CountAsync();
            var grigons = await _context.Factures.Where(c => c.TypeFactureId == 4).Include(c => c.Grignon).AsNoTracking().ToListAsync();

            foreach (var item in grigons)
            {
                statistiquea.MontantGrigonsTotal = statistiquea.MontantGrigonsTotal + item.Montant;
                statistiquea.NbrGrigonsTotal     = statistiquea.NbrGrigonsTotal + item.Grignon.Poids;
            }
            ///////////////////////
            statistiquea.NbrCaisseTotal = await _context.Caisses.CountAsync();

            var caises = await _context.Caisses.AsNoTracking().ToListAsync();

            foreach (var item in caises)
            {
                statistiquea.MontantCaiseTotal = statistiquea.MontantCaiseTotal + item.Montant;
            }
            //////////////////////////////
            ///

            var timeNows = FirstDateOfWeekISO8601(DateTime.Now.Date.Year, GetIso8601WeekOfYear(DateTime.Now));
            var weeaka   = WeekDays(timeNows);

            foreach (var item in weeaka)
            {
                totaltrituration   = 0; totalachat = 0; totalvente = 0; totalgrignons = 0; totalCaisse = 0;
                montanttrituration = 0; montantachat = 0; montantvente = 0; montantgrignons = 0; montantcaisse = 0;
                var toatalCaisseMon = await _context.Caisses.Where(c => c.Date.DayOfYear == item.DayOfYear).ToListAsync();


                foreach (var itema in toatalCaisseMon)
                {
                    montantcaisse = montantcaisse + itema.Montant;
                    totalCaisse++;
                }
                StatiqueWeekTrituration statcaisee = new StatiqueWeekTrituration()
                {
                    Total   = totalCaisse,
                    Montant = montantcaisse
                };
                statistiquea.WeekCaisse.Add(statcaisee);
                var gloablFacture = _context.Factures.Include(c => c.Grignon).Include(c => c.Trituration).Include(c => c.Achat).Include(c => c.VenteHuile).Where(c => c.Date.DayOfYear == item.DayOfYear).Include(c => c.TypeFacture).ToList();
                foreach (var itemaw in gloablFacture)
                {
                    if (itemaw.TypeFactureId == 1)
                    {
                        montanttrituration = montanttrituration + itemaw.Montant;
                        totaltrituration   = totaltrituration + itemaw.Trituration.Poids;
                    }
                    else if (itemaw.TypeFactureId == 2)
                    {
                        montantachat = montantachat + itemaw.Montant;
                        totalachat   = totalachat + itemaw.Achat.QteAchete;
                    }
                    else if (itemaw.TypeFactureId == 3)
                    {
                        montantvente = montantvente + itemaw.Montant;
                        totalvente   = totalvente + itemaw.VenteHuile.Qte_Vente;
                    }
                    else if (itemaw.TypeFactureId == 4)
                    {
                        montantgrignons = montantgrignons + itemaw.Montant;
                        totalgrignons   = totalgrignons + itemaw.Grignon.Poids;
                    }
                    else
                    {
                        montanttrituration = 0; montantachat = 0; montantvente = 0; montantgrignons = 0; montantcaisse = 0;
                    }
                }
                StatiqueWeekTrituration statrituration = new StatiqueWeekTrituration()
                {
                    Total   = totaltrituration,
                    Montant = montanttrituration
                };
                statistiquea.WeekTriturations.Add(statrituration);
                ///////////////////////
                StatiqueWeekTrituration statachat = new StatiqueWeekTrituration()
                {
                    Total   = totalachat,
                    Montant = montantachat
                };
                statistiquea.WeekAchats.Add(statachat);
                //////////////////////////
                StatiqueWeekTrituration statvente = new StatiqueWeekTrituration()
                {
                    Total   = totalvente,
                    Montant = montantvente
                };
                statistiquea.WeekVentes.Add(statvente);
                //////////////////////////
                StatiqueWeekTrituration statgrignons = new StatiqueWeekTrituration()
                {
                    Total   = totalgrignons,
                    Montant = montantgrignons
                };
                statistiquea.WeekGrignons.Add(statgrignons);
            }
            var staLocal = statistiquea;

            statistiquea = null;
            return(staLocal);
        }
Example #16
0
        public ActionResult Statistique4A()
        {
            if (Session["admin"] != null)
            {
                if (Session["admin"].Equals(true))
                {
                    List <Statistique> statistiquesPre      = new List <Statistique>();
                    List <Statistique> statistiquesConvoque = new List <Statistique>();

                    List <Filiere> filieres = new List <Filiere>();

                    Statistique statPerDiplomPre  = new Statistique();
                    Statistique statPerDiplomConv = new Statistique();

                    using (IStatistiques3AService dal = new Statistique3AImpl())
                    {
                        filieres = dal.GetFilieres();
                        foreach (var f in filieres)
                        {
                            statistiquesPre.Add(new Statistique
                            {
                                nbDeug       = dal.getCandidatPreisncrit(f.ID, "deug", 4),
                                nbDut        = dal.getCandidatPreisncrit(f.ID, "dut", 4),
                                nbLicenceFnd = dal.getCandidatPreisncrit(f.ID, "Lic.fnd", 4),
                                nbLicencePro = dal.getCandidatPreisncrit(f.ID, "Lic.pro", 4),
                                nbLicenceSt  = dal.getCandidatPreisncrit(f.ID, "Lic.st", 4),
                                nomFiliere   = f.Nom
                            });
                            statistiquesConvoque.Add(new Statistique
                            {
                                nbDeug       = dal.getCandidatConv(f.ID, "deug", 4),
                                nbDut        = dal.getCandidatConv(f.ID, "dut", 4),
                                nbLicenceFnd = dal.getCandidatConv(f.ID, "Lic.fnd", 4),
                                nbLicencePro = dal.getCandidatConv(f.ID, "Lic.pro", 4),
                                nbLicenceSt  = dal.getCandidatConv(f.ID, "Lic.st", 4),
                                nomFiliere   = f.Nom
                            });
                        }
                        statPerDiplomPre = new Statistique
                        {
                            nbDeug       = dal.getNbCandidatPerDiplome("deug", 4),
                            nbDut        = dal.getNbCandidatPerDiplome("dut", 4),
                            nbLicenceFnd = dal.getNbCandidatPerDiplome("Lic.fnd", 4),
                            nbLicenceSt  = dal.getNbCandidatPerDiplome("Lic.st", 4),
                            nbLicencePro = dal.getNbCandidatPerDiplome("Lic.pro", 4),
                        };
                        statPerDiplomConv = new Statistique
                        {
                            nbDeug       = dal.getNbCandidatPerDiplomeConv("deug", 4),
                            nbDut        = dal.getNbCandidatPerDiplomeConv("dut", 4),
                            nbLicenceFnd = dal.getNbCandidatPerDiplomeConv("Lic.fnd", 4),
                            nbLicenceSt  = dal.getNbCandidatPerDiplomeConv("Lic.st", 4),
                            nbLicencePro = dal.getNbCandidatPerDiplomeConv("Lic.pro", 4),
                        };
                    }

                    ViewData["statistiquesPre"]      = statistiquesPre;
                    ViewData["statistiquesConvoque"] = statistiquesConvoque;
                    ViewBag.statPerDiplomPre         = statPerDiplomPre;
                    ViewBag.statPerDiplomConv        = statPerDiplomConv;
                    return(View());
                }
            }
            return(RedirectToAction("Login", "AdminAuth"));
        }
        public async Task <Statistique> GetAllStatistiqueByWeekAsync(TimeByWeek timeWeek)
        {
            int yeara    = timeWeek.AnyDayInWeek.Year;
            var timeNows = FirstDateOfWeekISO8601(yeara, GetIso8601WeekOfYear(timeWeek.AnyDayInWeek));
            var weeaka   = WeekDays(timeNows);

            foreach (var item in weeaka)
            {
                totaltrituration   = 0; totalachat = 0; totalvente = 0; totalgrignons = 0; totalCaisse = 0;
                montanttrituration = 0; montantachat = 0; montantvente = 0; montantgrignons = 0; montantcaisse = 0;
                var gloablFacture = await _context.Factures.Include(c => c.Grignon).Include(c => c.Trituration)
                                    .Include(c => c.Achat).Include(c => c.VenteHuile).Where(c => c.Date.DayOfYear == item.DayOfYear)
                                    .Include(c => c.TypeFacture).ToListAsync();

                var toatalCaisseMon = await _context.Caisses.Where(c => c.Date.DayOfYear == item.DayOfYear).ToListAsync();


                foreach (var itemaa in toatalCaisseMon)
                {
                    montantcaisse = montantcaisse + itemaa.Montant;
                    statistiqueb.MontantCaiseTotal = statistiqueb.MontantCaiseTotal + itemaa.Montant;
                    statistiqueb.NbrCaisseTotal++;
                    totalCaisse++;
                }
                StatiqueWeekTrituration statcaisee = new StatiqueWeekTrituration()
                {
                    Total   = totalCaisse,
                    Montant = montantcaisse
                };
                statistiqueb.WeekCaisse.Add(statcaisee);
                foreach (var itema in gloablFacture)
                {
                    if (itema.TypeFactureId == 1)
                    {
                        montanttrituration = montanttrituration + itema.Montant;
                        statistiqueb.MontantTriturationTotal = statistiqueb.MontantTriturationTotal + itema.Montant;
                        statistiqueb.NbrTriturationTotal     = statistiqueb.NbrTriturationTotal + itema.Trituration.Poids;
                        totaltrituration = statistiqueb.NbrTriturationTotal;
                    }
                    else if (itema.TypeFactureId == 2)
                    {
                        montantachat = montantachat + itema.Montant;
                        statistiqueb.MontantAchatTotal = statistiqueb.MontantAchatTotal + itema.Montant;
                        statistiqueb.NbrAchatTotal     = statistiqueb.NbrAchatTotal + itema.Achat.QteAchete;;
                        totalachat = statistiqueb.NbrAchatTotal;
                    }
                    else if (itema.TypeFactureId == 3)
                    {
                        montantvente = montantvente + itema.Montant;
                        statistiqueb.MontantVenteTotal = statistiqueb.MontantVenteTotal + itema.Montant;
                        statistiqueb.NbrVenteTotal     = statistiqueb.NbrVenteTotal + itema.VenteHuile.Qte_Vente;
                        totalvente = statistiqueb.NbrVenteTotal;
                    }
                    else if (itema.TypeFactureId == 4)
                    {
                        montantgrignons = montantgrignons + itema.Montant;
                        statistiqueb.MontantGrigonsTotal = statistiqueb.MontantGrigonsTotal + itema.Montant;
                        statistiqueb.NbrGrigonsTotal     = statistiqueb.NbrGrigonsTotal + itema.Grignon.Poids;
                        totalgrignons = statistiqueb.NbrGrigonsTotal;
                    }
                }
                StatiqueWeekTrituration statrituration = new StatiqueWeekTrituration()
                {
                    Total   = totaltrituration,
                    Montant = montanttrituration
                };
                statistiqueb.WeekTriturations.Add(statrituration);
                ///////////////////////
                StatiqueWeekTrituration statachat = new StatiqueWeekTrituration()
                {
                    Total   = totalachat,
                    Montant = montantachat
                };
                statistiqueb.WeekAchats.Add(statachat);
                //////////////////////////
                StatiqueWeekTrituration statvente = new StatiqueWeekTrituration()
                {
                    Total   = totalvente,
                    Montant = montantvente
                };
                statistiqueb.WeekVentes.Add(statvente);
                //////////////////////////
                StatiqueWeekTrituration statgrignons = new StatiqueWeekTrituration()
                {
                    Total   = totalgrignons,
                    Montant = montantgrignons
                };
                statistiqueb.WeekGrignons.Add(statgrignons);
            }
            var staLocal = statistiqueb;

            statistiqueb = null;
            return(staLocal);
        }
Example #18
0
        public override double Calcul()
        {
            int position = 0;

            if (Math.Floor(alpha * Actions.Lignes) == alpha * Actions.Lignes)
            {
                position = (int)(alpha * Actions.Lignes);
            }
            else
            {
                position = (int)Math.Floor(alpha * Actions.Lignes) + 1;
            }

            Matrice rendements = new Matrice(Actions.Lignes - 1, Actions.Colonnes);

            Matrice Er   = new Matrice(Actions.Lignes);
            Matrice Vol  = new Matrice(Actions.Lignes);
            Matrice Corr = new Matrice(Actions.Colonnes, Actions.Colonnes);

            for (int j = 0; j < Actions.Colonnes; j++)
            {
                for (int i = 1; i < Actions.Lignes; i++)
                {
                    rendements[i - 1, j] = (Actions[i, j] - Actions[i - 1, j]) / Actions[i - 1, j];
                }

                Er[j, 0]  = Statistique.Moyenne(rendements, j);
                Vol[j, 0] = Statistique.EcartType(rendements, j);
            }

            // Calcul de la partie supérieure de la matrice de corrélation
            for (int j = 0; j < Actions.Colonnes; j++)
            {
                for (int k = j + 1; k < Actions.Colonnes; k++)
                {
                    // Corrélation entre l'entreprise j et l'entreprise k
                    Corr[j, k] = Statistique.Correlation(rendements, j, k);
                }
            }

            // Génération de la partie infèrieure par symétrie
            for (int j = 0; j < Actions.Colonnes; j++)
            {
                for (int k = j + 1; k < Actions.Colonnes; k++)
                {
                    Corr[k, j] = Corr[j, k];
                }
            }

            // Remplissage de la diagonale avec la valeur 1
            for (int j = 0; j < Actions.Colonnes; j++)
            {
                Corr[j, j] = 1;
            }


            // Décomposition de Cholesky
            Decomposition decompo = new Cholesky(Corr);

            decompo.Decomposer();
            Matrice L = decompo.L;


            rendements = Simulation(Er, Vol, decompo, rendements.Lignes);

            double[] VaR_actif = new double[Actions.Colonnes];
            // Calcul des VaR individuelles
            for (int j = 0; j < Actions.Colonnes; j++)
            {
                List <double> rendement_tri = new List <double>();

                for (int i = 0; i < Actions.Lignes - 1; i++)
                {
                    rendement_tri.Add(rendements[i, j]);
                }

                rendement_tri.Sort();

                VaR_actif[j] = rendement_tri[position - 1]; // On récupére la VaR de l'actif seul; -1 car le tableau est indexé à 0
                Console.WriteLine("VaR actif " + j + " : " + VaR_actif[j]);
                VaR_result += VaR_actif[j] * VaR_actif[j] * CompanyTab[j].Weight * CompanyTab[j].Weight;
            }
            ;


            // Calcul des corrélations entre les actifs
            for (int j = 0; j < Actions.Colonnes; j++)
            {
                for (int k = j + 1; k < Actions.Colonnes; k++)
                {
                    // Corrélation entre l'entreprise j et l'entreprise k
                    VaR_result += 2 * Statistique.Correlation(rendements, j, k) * VaR_actif[j] * CompanyTab[j].Weight * VaR_actif[k] * CompanyTab[k].Weight;
                }
            }

            return(-Math.Sqrt(VaR_result));
        }
Example #19
0
        public override double Calcul()
        {
            int position = 0;

            if (Math.Floor(alpha * Actions.Lignes) == alpha * Actions.Lignes)
            {
                position = (int)(alpha * Actions.Lignes);
            }
            else
            {
                position = (int)Math.Floor(alpha * Actions.Lignes) + 1;
            }

            Matrice rendements = new Matrice(Actions.Lignes - 1, Actions.Colonnes);

            Matrice Er   = new Matrice(Actions.Lignes);
            Matrice Vol  = new Matrice(Actions.Lignes);
            Matrice Corr = new Matrice(Actions.Colonnes, Actions.Colonnes);

            for (int j = 0; j < Actions.Colonnes; j++)
            {
                for (int i = 1; i < Actions.Lignes; i++)
                {
                    rendements[i - 1, j] = (Actions[i, j] - Actions[i - 1, j]) / Actions[i - 1, j];
                }

                Er[j, 0]  = Statistique.Moyenne(rendements, j);
                Vol[j, 0] = Statistique.EcartType(rendements, j);
            }

            // Calcul de la partie supérieure de la matrice de corrélation
            for (int j = 0; j < Actions.Colonnes; j++)
            {
                for (int k = j + 1; k < Actions.Colonnes; k++)
                {
                    // Corrélation entre l'entreprise j et l'entreprise k
                    Corr[j, k] = Statistique.Correlation(rendements, j, k);
                }
            }

            // Génération de la partie infèrieure par symétrie
            for (int j = 0; j < Actions.Colonnes; j++)
            {
                for (int k = j + 1; k < Actions.Colonnes; k++)
                {
                    Corr[k, j] = Corr[j, k];
                }
            }

            // Remplissage de la diagonale avec la valeur 1
            for (int j = 0; j < Actions.Colonnes; j++)
            {
                Corr[j, j] = 1;
            }



            Statistique.NormInv(0, 1, p);

            return(-Math.Sqrt(VaR_result));
        }
Example #20
0
        private void resultat_Click(object sender, EventArgs e)
        {
            Statistique statistique = new Statistique(_pist);

            statistique.Show();
        }