예제 #1
0
 public Product(type_ inBoxType, Box parentBox_)
 { // Constructor for box.packagedbud and box.packagedproduct
     productGO   = null;
     productType = inBoxType;
     parentBox   = parentBox_;
     DetermineCategory();
 }
예제 #2
0
    public float height;                                                              // if a pipe, this is length
    public DesiredGlass(type_ referenceType_) : base(type_.reference, referenceType_) // The customer wants
    {
        float rand = UnityEngine.Random.value;

        if (rand > .5)                                                                    // 50%
        {
            if (referenceType_ == type_.glassPipe || referenceType_ == type_.acrylicPipe) // Pipes minimum length is 1
            {
                height = UnityEngine.Random.Range(1, 10);                                 // Desired height (or length)
            }
            else // Bongs minimum height is 4
            {
                height = UnityEngine.Random.Range(4, 10); // Desired height (or length)
            }
        }
        else if (rand > .25)                           // 25%
        {
            height = UnityEngine.Random.Range(10, 14); // Desired height (or length)
        }
        else if (rand > .1)                            // 15%
        {
            height = UnityEngine.Random.Range(12, 18); // Desired height (or length)
        }
        else // 10%
        {
            height = UnityEngine.Random.Range(18, 24); // Desired height (or length)
        }
    }
예제 #3
0
 public Product(StoreObjectReference reference, GameObject createdObject, type_ type__)
 {
     productReference = reference;
     productGO        = createdObject;
     productType      = type__;
     DetermineCategory();
 }
예제 #4
0
 public Product(type_ type__, type_ referenceType_)
 {
     productGO     = null;
     productType   = type__;
     referenceType = referenceType_;
     productType   = type__;
     DetermineCategory();
 }
예제 #5
0
        /******************************************************************************
        * ************ Valeur d'une option basket avec la méthode de réduction *******
        ****************   de la variance Robbins Monro (Arouna)   *******************
        * ****************************************************************************/
        public double[] MC_RM_ArounaBasketOptionVal(type_ op)
        {
            //RobbinsMonroAlgorithme RM;
            List <double> Payoff_;

            double[,] ST_;
            double[] res = new double[2];           //Tableau résultat
            Payoff_ = new List <double>();
            ST_     = new double[NSim_, S0_.Count];
            double NormBoxMuller;

            switch (op)
            {
            case type_.Call:
                for (int j = 0; j < NSim_; j++)
                {
                    double som = 0;
                    for (int i = 0; i < S0_.Count; i++)
                    {
                        NormBoxMuller = LoiNormal.random_normal_parBoxMuller(rnd);
                        ST_[j, i]     = S0_[i] * Math.Exp((r_ - 0.5 * Math.Pow(Sigma_[i], 2)) * t_ + Sigma_[i] * Math.Sqrt(t_) * NormBoxMuller);
                        if (j < NSim_ - 1)
                        {
                            ST_[j + 1, i] = S0_[i] * Math.Exp((r_ - 0.5 * Math.Pow(Sigma_[i], 2)) * t_ + Sigma_[i] * Math.Sqrt(t_) * NormBoxMuller);
                        }
                        som += ST_[j, i];
                    }
                    j++;
                    Payoff_.Add(Math.Exp(-r_ * t_) * Math.Max((som / S0_.Count - K_), 0.0));
                }
                break;

            case type_.Put:
                for (int j = 0; j < NSim_; j++)
                {
                    double som = 0;
                    for (int i = 0; i < S0_.Count; i++)
                    {
                        NormBoxMuller = LoiNormal.random_normal_parBoxMuller(rnd);
                        ST_[j, i]     = S0_[i] * Math.Exp((r_ - 0.5 * Math.Pow(Sigma_[i], 2)) * t_ + Sigma_[i] * Math.Sqrt(t_) * NormBoxMuller);
                        if (j < NSim_ - 1)
                        {
                            ST_[j + 1, i] = S0_[i] * Math.Exp((r_ - 0.5 * Math.Pow(Sigma_[i], 2)) * t_ + Sigma_[i] * Math.Sqrt(t_) * NormBoxMuller);
                        }
                        som += ST_[j, i];
                    }
                    j++;
                    Payoff_.Add(Math.Exp(-r_ * t_) * Math.Max((K_ - som / S0_.Count), 0.0));
                }
                break;

            default:
                throw new InvalidOperationException("Impossible de traiter le type d'option entrer!!!!: " + op);
            }
            res[0] = Payoff_.Average();                                      //La valeur de l'option, Esperance des payoff actualisés
            res[1] = Math.Sqrt(Variance(Payoff_, res[0], 0, Payoff_.Count)); //L'ecarte type de simulation,
            return(res);
        }
예제 #6
0
 //Constructeur de l'objet MCRMBasketOption.
 public MCRMBasketOption(List <double> S0, double K, int t, List <double> sigma, double r, long NSim, type_ op)
 {
     this.op_    = op;
     this.S0_    = S0;
     this.K_     = K;
     this.t_     = t;
     this.Sigma_ = sigma;
     this.r_     = r;
     this.NSim_  = NSim;
     rnd         = new Random();
 }
 public RMAlgoPagesLemaire(double S0, double K, int t, double sigma, double r, long NSim, type_ op)
 {
     this.op_    = op;
     this.S0_    = S0;
     this.K_     = K;
     this.T_     = t;
     this.Sigma_ = sigma;
     this.r_     = r;
     this.NSim_  = NSim;
     rnd         = new Random();
 }
예제 #8
0
        public string edit_comp_type2(int comp, int type, int c_serv
                                      )
        {
            component_p c = components_p.get(comp);

            c.revise("comp_type", type
                     );

            type_ r = type_s.get(type);

            return(comp + s240 + r.type);
        }
        /*********************************************************************************************************
         * Fonction return à la valeur d'une option européenne type=Call ou Put
         * return à une vecteur de taille 2: première composante de la table contenant la valeur de l'option
         * Deuxième composante: l'erreur de la simulation MC
         **********************************************************************************************************/
        public double[] MCEuropOptionVal(type_ op)
        {
            List <double> ST_, Payoff_, SquareEsperance;
            double        mu  = (r_ - 0.5 * Math.Pow(Sigma_, 2)) * t_;
            double        sig = Sigma_ * Math.Sqrt(t_);
            double        NormBoxMuller;           //Variable Normale centrée reduite

            ST_             = new List <double>(); //Tableau pour stocker les valeurs de ST simuler
            Payoff_         = new List <double>(); //Tableau des PayOff
            SquareEsperance = new List <double>(); //Esperance des crées
            double[] res = new double[2];          //Tableau résultat

            for (int i = 0; i < NSim_; i++)
            {
                NormBoxMuller = LoiNormal.random_normal_parBoxMuller(rnd);
                ST_.Add(S0_ * Math.Exp(mu + sig * NormBoxMuller));
                if (i < NSim_ - 1)
                {
                    ST_.Add(S0_ * Math.Exp(mu - (sig * NormBoxMuller)));
                }
                i++;
            }
            switch (op)
            {
            case type_.Call:
                for (int i = 0; i < NSim_; i++)
                {
                    Payoff_.Add(Math.Exp(-r_ * t_) * Math.Max((ST_[i] - K_), 0.0));
                    SquareEsperance.Add(Math.Pow(Payoff_[i], 2));
                }
                break;

            case type_.Put:
                for (int i = 0; i < NSim_; i++)
                {
                    Payoff_.Add(Math.Exp(-r_ * t_) * Math.Max((K_ - ST_[i]), 0.0));
                    SquareEsperance.Add(Math.Pow(Payoff_[i], 2));
                }
                break;

            default:
                throw new InvalidOperationException("Impossible de traiter le type d'option entrer!!!!: " + op);
            }
            res[0] = Payoff_.Average();                                      //La valeur de l'option, Esperance des payoff actualisés
            res[1] = Math.Sqrt(Variance(Payoff_, res[0], 0, Payoff_.Count)); //L'ecarte type de simulation,
            return(res);
        }
예제 #10
0
    public static string ProductTypeToString(type_ productTypeIn, bool makePlural)
    {
        string toReturn = string.Empty;

        switch (productTypeIn)
        {
        case type_.ashTray:
            toReturn = "Ash Tray";
            if (makePlural)
            {
                toReturn += "s";
            }
            return(toReturn);

        case type_.clothing:
            toReturn = "Clothing";     // already plural
            return(toReturn);

        case type_.fakeStash:
            toReturn = "Fake Stash";
            if (makePlural)
            {
                toReturn += "s";
            }
            return(toReturn);

        case type_.lighter:
            toReturn = "Lighter";
            if (makePlural)
            {
                toReturn += "s";
            }
            return(toReturn);

        case type_.rollingTray:
            toReturn = "Rolling Tray";
            if (makePlural)
            {
                toReturn += "s";
            }
            return(toReturn);

        case type_.rollingPaper:
            toReturn = "Rolling Paper";
            if (makePlural)
            {
                toReturn += "s";
            }
            return(toReturn);

        case type_.grinder:
            toReturn = "Grinder";
            if (makePlural)
            {
                toReturn += "s";
            }
            return(toReturn);

        case type_.storageJar:
            toReturn = "Storage Jar";
            if (makePlural)
            {
                toReturn += "s";
            }
            return(toReturn);

        case type_.curingJar:
            toReturn = "Curing Jar";
            if (makePlural)
            {
                toReturn += "s";
            }
            return(toReturn);

        case type_.edible:
            toReturn = "Edible";
            if (makePlural)
            {
                toReturn += "s";
            }
            return(toReturn);

        case type_.glassBong:
            toReturn = "Glass Bong";
            if (makePlural)
            {
                toReturn += "s";
            }
            return(toReturn);

        case type_.glassPipe:
            toReturn = "Glass Pipe";
            if (makePlural)
            {
                toReturn += "s";
            }
            return(toReturn);

        case type_.acrylicBong:
            toReturn = "Acrylic Bong";
            if (makePlural)
            {
                toReturn += "s";
            }
            return(toReturn);

        case type_.acrylicPipe:
            toReturn = "Acrylic Pipe";
            if (makePlural)
            {
                toReturn += "s";
            }
            return(toReturn);

        case type_.hashOil:
            toReturn = "Hash Oil";     // Already plural
            return(toReturn);

        case type_.shatter:
            toReturn = "Shatter";     // Already plural
            return(toReturn);

        case type_.tincture:
            toReturn = "Tincture";
            if (makePlural)
            {
                toReturn += "s";
            }
            return(toReturn);

        case type_.wax:
            toReturn = "Wax";
            return(toReturn);

        case type_.seed:
            toReturn = "Seed";
            if (makePlural)
            {
                toReturn += "s";
            }
            return(toReturn);

        case type_.topical:
            toReturn = "Topical";
            if (makePlural)
            {
                toReturn += "s";
            }
            return(toReturn);

        case type_.bowl:
            toReturn = "Bowl";
            if (makePlural)
            {
                toReturn += "s";
            }
            return(toReturn);

        case type_.box:
            toReturn = "Box";
            if (makePlural)
            {
                toReturn += "es";
            }
            return(toReturn);

        case type_.packagedBud:
            toReturn = "Packaged Bud";     // Already plural
            return(toReturn);

        case type_.packagedProduct:
            toReturn = "Packaged Product";
            if (makePlural)
            {
                toReturn += "s";
            }
            return(toReturn);
        }
        return(productTypeIn.ToString() + " Error");
    }