Example #1
0
        public static void RemoveSoft()
        {
            SDateTime        time    = new SDateTime(1, 70);
            CompanyType      type    = new CompanyType();
            var              dict    = new Dictionary <string, string[]>();
            var              sim     = new MarketSimulation();
            SimulatedCompany simComp = new SimulatedCompany("Trainer Company", time, type, dict, 0f, sim);

            simComp.CanMakeTransaction(1000000000f);

            SoftwareProduct[] Products = Settings.simulation.GetAllProducts().Where(product =>
                                                                                    product.DevCompany == Settings.MyCompany &&
                                                                                    product.Inventor != Settings.MyCompany.Name).ToArray();

            if (Products.Length == 0)
            {
                return;
            }

            for (int i = 0; i < Products.Length; i++)
            {
                SoftwareProduct Product = Products[i];

                Product.Userbase       = 0;
                Product.PhysicalCopies = 0;
                Product.Marketing      = 0;
                Product.Trade(simComp);
            }

            WindowManager.SpawnDialog("Products that you didn't invent are removed.", false, DialogWindow.DialogType.Information);
        }
Example #2
0
 public NuclearPlant(double production, double emission, MarketSimulation marketsimulation)
 {
     this.production       = production;
     this.production_real  = production;
     this.emission         = emission;
     this.marketsimulation = marketsimulation;
 }
Example #3
0
 public GasPlant(double production, double emission, MarketSimulation marketsimulation)
 {
     this.production       = production;
     this.emission         = emission;
     this.marketsimulation = marketsimulation;
     this.number           = n;
     n++;
 }
Example #4
0
 public BuyElectricity(double production, double emission, MarketSimulation marketsimulation)
 {
     this.production       = production;
     this.emission         = emission;
     this.marketsimulation = marketsimulation;
     this.number           = n;
     n++;
 }
            /// <summary>
            /// called by MarketSimulation when a change is in the status of the security 
            /// </summary>
            public void callback(MarketSimulation.MarketData md)
            {
                int id = md.id;
                MarketSimulationMaof.Option option = marketSimulationMaof.GetOption(id);
                string optionName = option.GetName();

                // print everything out - name, bids, asks
                MarketSimulation.OrderPair[] bids = md.bid;
                MarketSimulation.OrderPair[] asks = md.ask;

                System.Collections.ArrayList values = new System.Collections.ArrayList();

                values.Add(md.tick);
                values.Add(id);
                values.Add(optionName);
                values.Add(md.lastTrade);
                values.Add(md.dayVolume);
                values.Add(OrderBook2String(bids, 9));
                values.Add(OrderBook2String(asks, 9));

                CommandLineInterface.printValues(iWrite, values, this.columns);
            }
 protected void placeOrderCallback(MarketSimulation.ReturnCode errorCode, MarketSimulation.ISystemLimitOrder lo, int quantity)
 {
     MarketSimulationMaof.Option option = marketSimulationMaof.GetOption(lo.SecurityId);
     string optionName = option.GetName();
     if (errorCode == MarketSimulation.ReturnCode.Fill)
     {
         System.Console.WriteLine("Tick {6} Order {0} {5} id {1} quantity {3} price {4} got fill at price {2}",
                                  optionName, lo.Id, lo.FillPrice, quantity, lo.Price, lo.SecurityId, lo.FillTick);
     }
     else
     {
         System.Console.WriteLine("Tick {5} Order {0} id {1} price {2} quantity {3} failed on {4}",
                                  optionName, lo.Id, lo.Price, quantity, errorCode.ToString(), lo.FillTick);
     }
 }
 protected static string OrderPair2String(MarketSimulation.OrderPair op, int columnSize)
 {
     string res = "" + op.price + ":" + op.size + " ";
     res = OutputUtils.FormatField(res, columnSize);
     return res;
 }
        protected static string OrderBook2String(MarketSimulation.OrderPair[] book, int columnSize)
        {
            string res = "";

            for (int i = 0; i < book.Length; i++)
            {
                MarketSimulation.OrderPair op = book[i];
                res = res + OrderPair2String(op, columnSize);
            }

            return res;
        }
Example #9
0
        static void Main(string[] args)
        {
            MarketSimulation  france   = new MarketSimulation();
            WeatherSimulation belgique = new WeatherSimulation(0, 0);
            //NuclearPlant myprod = new NuclearPlant(1000,0,france);
            SolarPlant myprod = new SolarPlant(0, 1, belgique);

            //GasPlant myprod = new GasPlant(3,2,1);
            Console.WriteLine(myprod.getProduction());
            Console.WriteLine(myprod.getCost());
            Console.WriteLine(myprod.getEmission());



            //add a producer ;
            GasPlant gasProd1 = new GasPlant(3, 2, france);
            //Try to built a network
            // first of all the node
            DistribNode distrib1 = new DistribNode();
            DistribNode distrib2 = new DistribNode();
            DistribNode distrib3 = new DistribNode();

            ConcentNode concentrator1 = new ConcentNode();


            // Next the wire and add it to a node
            Wire myprodWire = new Wire(myprod, distrib1, 12);
            //distrib1.SetPowerSupply(myprodWire);
            Wire gasWire = new Wire(gasProd1, distrib2, 20);
            //distrib2.SetPowerSupply(gasWire);

            Wire wire1Concen1 = new Wire(concentrator1, distrib2, 8);
            Wire wire2Concen1 = new Wire(concentrator1, distrib1, 8);

            Wire wireNodeNode1 = new Wire(distrib2, distrib3, 20);


            //after
            City paris     = new City(12, "Longitude=1,Latitude=1", "Paris");
            Wire parisWire = new Wire(paris, distrib3, 10);


            Company ferrero     = new Company(12, "Longitude = 12, latitude =8", "ferrero");
            Wire    ferreroWire = new Wire(ferrero, distrib3, 12);


            Dissipaters dis1      = new Dissipaters(14, "Longitude = 12, latitude =19");
            Wire        disipWire = new Wire(dis1, distrib1, 4);

            // now we connect all the wire to the nodes
            distrib1.SetPowerSupply(myprodWire);
            Console.WriteLine("le sourant est de " + distrib1.GetActivCurrent());
            distrib1.AddConnection(wire1Concen1);
            distrib1.AddConnection(disipWire);
            double [] distributionProportions = { 0.7, 0.3 };

            distrib1.SetEnergyDistrib(distributionProportions);

            // juste pour controler si j'ai pas de problèmes
            List <Wire> wireliste = new List <Wire>();

            wireliste = distrib1.GetConnetions();
            Console.WriteLine("nombre de fils : " + wireliste.Count);
            Console.WriteLine("le courant est de " + wireliste[1].GetCost());
            foreach (Wire fils in wireliste)
            {
                Console.WriteLine("le fils est : " + fils.GetMaxCurrent() + "Activ current = " + fils.GetActivCurrent());
            }
            // fin
            Console.WriteLine("production gas line " + gasWire.GetActivCurrent());

            distrib2.SetPowerSupply(gasWire);
            distrib2.AddConnection(wire2Concen1);
            double [] distributionProportions2 = { 1 };
            Console.WriteLine("essais" + distrib2.GetActivCurrent());
            distrib2.SetEnergyDistrib(distributionProportions2);
            Console.WriteLine("essais2 " + wire2Concen1.GetActivCurrent());
            // fonctionne jusque ici !


            concentrator1.SetConcentreWire(wireNodeNode1);
            concentrator1.AddConnection(wire1Concen1);
            concentrator1.AddConnection(wire2Concen1);


            distrib3.SetPowerSupply(wireNodeNode1);
            distrib3.AddConnection(ferreroWire);
            distrib3.AddConnection(parisWire);


            //
            paris.SetQuantityEnergie(2);

            Console.WriteLine("enregie dans le fils node node : " + wireNodeNode1.GetActivCurrent());
            Console.WriteLine("le prix/kwh sur le neud distrib3 est : " + distrib3.GetCost());
            Console.WriteLine("Le prix pour la ville de paris est : " + paris.GetCost(parisWire));
        }