コード例 #1
0
    void getComponents()
    {
        GameObject functions = GameObject.Find ("Functions");
        saveData = functions.GetComponent<SaveData> ();
        readCSV = functions.GetComponent<ReadCSV> ();

        gameData = GameObject.Find ("GameData").GetComponent<GameData> ();

        remainingGoldText = GameObject.Find ("RemainingGold").GetComponent<Text> ();

        ListAllItems_Values = GameObject.Find ("ListAllItems_Values");
        ListAllItems_SampleValue = GameObject.Find ("ListAllItems_SampleValue");

        ListAllItems_Buttons = GameObject.Find ("ListAllItems_Buttons");
        ListAllItems_SampleButton = GameObject.Find ("ListAllItems_SampleButton");

        ListStoreInv_Values = GameObject.Find ("ListStoreInv_Values");
        ListStoreInv_SampleValue = GameObject.Find ("ListStoreInv_SampleValue");

        ListStoreInv_Buttons = GameObject.Find ("ListStoreInv_Buttons");
        ListStoreInv_SampleButton = GameObject.Find ("ListStoreInv_SampleButton");

        ListAllItems_ScrollContent = GameObject.Find ("ListAllItems_ScrollContent");
        ListStoreInv_ScrollContent = GameObject.Find ("ListStoreInv_ScrollContent");

        ListAllItems_ScrollView = GameObject.Find ("ListAllItems_ScrollView");
        ListStoreInv_ScrollView = GameObject.Find ("ListStoreInv_ScrollView");

        ListAllItems_ScrollBar = GameObject.Find ("ListAllItems_ScrollBar");
        ListStoreInv_ScrollBar = GameObject.Find ("ListStoreInv_ScrollBar");

        StartGame_Button = GameObject.Find ("StartGame_Button");
        StartGame_Button.GetComponent<Button>().onClick.AddListener(delegate { startGame(); });
    }
コード例 #2
0
        public void TestClassification()
        {
            FileInfo rawFile = TEMP_DIR.CreateFile("simple.csv");
            FileInfo egaFile = TEMP_DIR.CreateFile("simple.ega");
            FileInfo outputFile = TEMP_DIR.CreateFile("simple_output.csv");

            FileUtil.CopyResource("Encog.Resources.simple.csv", rawFile);
            FileUtil.CopyResource("Encog.Resources.simple-c.ega", egaFile);

            EncogAnalyst analyst = new EncogAnalyst();
            analyst.AddAnalystListener(new ConsoleAnalystListener());
            analyst.Load(egaFile);

            analyst.ExecuteTask("task-full");

            ReadCSV csv = new ReadCSV(outputFile.ToString(), true, CSVFormat.English);
            while (csv.Next())
            {
                Assert.AreEqual(csv.Get(3), csv.Get(4));
            }

            Assert.AreEqual(4, analyst.Script.Fields.Length);
            Assert.AreEqual(3, analyst.Script.Fields[3].ClassMembers.Count);

            csv.Close();
        }
コード例 #3
0
ファイル: TestAnalystRegression.cs プロジェクト: jongh0/MTree
        public void TestRegression()
        {
            FileInfo rawFile = TEMP_DIR.CreateFile("simple.csv");
            FileInfo egaFile = TEMP_DIR.CreateFile("simple.ega");
            FileInfo outputFile = TEMP_DIR.CreateFile("simple_output.csv");

            FileUtil.CopyResource("Encog.Resources.simple.csv", rawFile);
            FileUtil.CopyResource("Encog.Resources.simple-r.ega", egaFile);

            EncogAnalyst analyst = new EncogAnalyst();
            analyst.Load(egaFile);

            analyst.ExecuteTask("task-full");

            ReadCSV csv = new ReadCSV(outputFile.ToString(), true, CSVFormat.English);
            while (csv.Next())
            {
                double diff = Math.Abs(csv.GetDouble(2) - csv.GetDouble(4));
                Assert.IsTrue(diff < 1.5);
            }

            Assert.AreEqual(4, analyst.Script.Fields.Length);
            Assert.AreEqual(3, analyst.Script.Fields[3].ClassMembers.Count);

            csv.Close();
        }
コード例 #4
0
        public ICollection<LoadedMarketData> Load(
            TickerSymbol ticker,
            IList<MarketDataType> dataNeeded,
            DateTime from,
            DateTime to)
        {
            // TODO: nyyyyyyyaaagh!

            ICollection<LoadedMarketData> result =
                new List<LoadedMarketData>();
            Uri url = BuildURL(ticker, from, to);
            WebRequest http = HttpWebRequest.Create(url);
            HttpWebResponse response = http.GetResponse() as HttpWebResponse;

            using (Stream istream = response.GetResponseStream())
            {
                ReadCSV csv = new ReadCSV(
                    istream,
                    true,
                    CSVFormat.DECIMAL_POINT
                );

                while (csv.Next())
                {
                    // todo: edit headers to match
                    DateTime date = csv.GetDate("DATE");
                    date =
                        date.Add(
                            new TimeSpan(
                                csv.GetDate("TIME").Hour,
                                csv.GetDate("TIME").Minute,
                                csv.GetDate("TIME").Second
                            )
                        );
                    double open = csv.GetDouble("OPEN");
                    double high = csv.GetDouble("MIN");
                    double low = csv.GetDouble("MAX");
                    double close = csv.GetDouble("CLOSE");
                    double volume = csv.GetDouble("VOLUME");

                    LoadedMarketData data =
                        new LoadedMarketData(date, ticker);
                    data.SetData(MarketDataType.OPEN, open);
                    data.SetData(MarketDataType.HIGH, high);
                    data.SetData(MarketDataType.LOW, low);
                    data.SetData(MarketDataType.CLOSE, close);
                    data.SetData(MarketDataType.VOLUME, volume);
                    result.Add(data);
                }

                csv.Close();
                istream.Close();
            }
            return result;
        }
コード例 #5
0
ファイル: YahooFinanceLoader.cs プロジェクト: jongh0/MTree
        /// <summary>
        /// Load the specified financial data. 
        /// </summary>
        /// <param name="ticker">The ticker symbol to load.</param>
        /// <param name="dataNeeded">The financial data needed.</param>
        /// <param name="from">The beginning date to load data from.</param>
        /// <param name="to">The ending date to load data to.</param>
        /// <returns>A collection of LoadedMarketData objects that represent the data
        /// loaded.</returns>
        public ICollection<LoadedMarketData> Load(TickerSymbol ticker,
                                                  IList<MarketDataType> dataNeeded, DateTime from,
                                                  DateTime to)
        {
            ICollection<LoadedMarketData> result =
                new List<LoadedMarketData>();
            Uri url = BuildURL(ticker, from, to);
            WebRequest http = WebRequest.Create(url);
            var response = (HttpWebResponse) http.GetResponse();

            using (Stream istream = response.GetResponseStream())
            {
                var csv = new ReadCSV(istream, true, CSVFormat.DecimalPoint);

                while (csv.Next())
                {
                    DateTime date = csv.GetDate("date");
                    double adjClose = csv.GetDouble("adj close");
                    double open = csv.GetDouble("open");
                    double close = csv.GetDouble("close");
                    double high = csv.GetDouble("high");
                    double low = csv.GetDouble("low");
                    double volume = csv.GetDouble("volume");

                    var data =
                        new LoadedMarketData(date, ticker);
                    data.SetData(MarketDataType.AdjustedClose, adjClose);
                    data.SetData(MarketDataType.Open, open);
                    data.SetData(MarketDataType.Close, close);
                    data.SetData(MarketDataType.High, high);
                    data.SetData(MarketDataType.Low, low);
                    data.SetData(MarketDataType.Open, open);
                    data.SetData(MarketDataType.Volume, volume);
                    result.Add(data);
                }

                csv.Close();
                istream.Close();
            }
            return result;
        }
コード例 #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            openFileDialog1 = new OpenFileDialog();


            openFileDialog1.InitialDirectory = ("c:\\");
            openFileDialog1.Filter           = ("txt files (*.csv)|*.csv|All files (*.*)|*.*");
            openFileDialog1.FilterIndex      = (2);
            openFileDialog1.RestoreDirectory = (true);
            this.Visible = false;

            DialogResult result = this.openFileDialog1.ShowDialog(); // Show the dialog.

            if (result == DialogResult.OK)                           // Test result.
            {
                string file = openFileDialog1.FileName;
                try
                {
                    Chosenfile = file;
                    format     = FormatDictionary[CSVFormatsCombo.Text];
                    foreach (string item in MarketDataTypesListBox.SelectedItems)
                    {
                        TypesLoaded.Add((MarketDataType)Enum.Parse(typeof(MarketDataType), item));
                    }

                    ReadCSV csv = new ReadCSV(Chosenfile, true, format);

                    var ColQuery =
                        from Names in csv.ColumnNames

                        select new { Names };

                    //ComboBox comboxTypes = new ComboBox();
                    // comboxTypes.Items.Add("DateTime");
                    // comboxTypes.Items.Add("Double");
                    // comboxTypes.Items.Add("Skip");
                    // comboxTypes.SelectedIndex = 0;


                    // DataGridViewRow dr = new DataGridViewRow();
                    // DataGridViewComboBoxCell CellGrids = new DataGridViewComboBoxCell();

                    // foreach (string item in comboxTypes.Items)
                    // {
                    //     CellGrids.Items.Add(item);
                    // }



                    // dr.Cells.Add(CellGrids);
                    // //newColumnsSetup.dataGridView1.Rows.Add(dr);

                    // DataGridViewColumn cols = new DataGridViewColumn(CellGrids);
                    // cols.Name = "Combo";

                    // newColumnsSetup.dataGridView1.Columns.Add(cols);



                    //DataGridViewColumn aCol = new DataGridViewColumn();
                    //foreach (DataGridViewRow item in newColumnsSetup.dataGridView1.Rows)
                    //{
                    //    DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)(item.Cells[0]);

                    //}
                }
                catch (Exception ex)
                {
                    toolStripStatusLabel1.Text = "Error Loading the CSV:" + ex.Message;
                }
            }
        }
コード例 #7
0
ファイル: GameData.cs プロジェクト: rayfrye/Gwain-Item-Shop
    void getComponents()
    {
        GameObject functions = GameObject.Find ("Functions");

        readCSV = functions.GetComponent<ReadCSV> ();
    }
コード例 #8
0
ファイル: YahooDownload.cs プロジェクト: neismit/emds
 public void LoadAllData(string ticker, string output, CSVFormat outputFormat, DateTime from, DateTime to)
 {
     try
     {
         HttpWebResponse response;
         ReadCSV dcsv;
         TextWriter writer;
         DateTime time;
         double num;
         double num2;
         double num3;
         double num4;
         double num5;
         long num6;
         StringBuilder builder;
         Uri requestUri = x38c212309d8d5dd3(ticker, from, to);
         goto Label_029A;
     Label_0010:
         builder.Append(outputFormat.Format(num, this.Precision));
         writer.WriteLine(builder.ToString());
     Label_0034:
         if (dcsv.Next())
         {
             goto Label_01E2;
         }
         writer.Close();
         return;
     Label_0049:
         builder.Append(outputFormat.Separator);
         builder.Append(outputFormat.Format(num3, this.Precision));
         builder.Append(outputFormat.Separator);
         builder.Append(num6);
         builder.Append(outputFormat.Separator);
         if ((((uint) num4) + ((uint) num2)) >= 0)
         {
             goto Label_0010;
         }
         return;
     Label_00B3:
         builder.Append(outputFormat.Format(num2, this.Precision));
         builder.Append(outputFormat.Separator);
         builder.Append(outputFormat.Format(num4, this.Precision));
         if ((((uint) num6) | 4) == 0)
         {
             goto Label_0034;
         }
         builder.Append(outputFormat.Separator);
     Label_0116:
         builder.Append(outputFormat.Format(num5, this.Precision));
         goto Label_0192;
     Label_012E:
         builder.Append(NumericDateUtil.DateTime2Long(time));
         builder.Append(outputFormat.Separator);
         builder.Append(NumericDateUtil.x93295384d7a86d9d(time));
         if ((((uint) num6) | 3) == 0)
         {
             goto Label_020C;
         }
         if (-2147483648 == 0)
         {
             goto Label_01FE;
         }
         builder.Append(outputFormat.Separator);
         goto Label_00B3;
     Label_0192:
         if (0 == 0)
         {
             goto Label_0049;
         }
         return;
     Label_019D:
         builder = new StringBuilder();
         if (((uint) num4) >= 0)
         {
             goto Label_012E;
         }
         goto Label_027A;
     Label_01BE:
         num5 = dcsv.GetDouble("low");
         num6 = (long) dcsv.GetDouble("volume");
         goto Label_0243;
     Label_01E2:
         time = dcsv.GetDate("date");
         num = dcsv.GetDouble("adj close");
     Label_01FE:
         num2 = dcsv.GetDouble("open");
     Label_020C:
         num3 = dcsv.GetDouble("close");
         num4 = dcsv.GetDouble("high");
         if ((((uint) num3) - ((uint) num4)) <= uint.MaxValue)
         {
             goto Label_01BE;
         }
     Label_0243:
         if ((((uint) num6) & 0) == 0)
         {
             goto Label_019D;
         }
     Label_0257:
         writer.WriteLine("date,time,open price,high price,low price,close price,volume,adjusted price");
         if (((uint) num) >= 0)
         {
             goto Label_0034;
         }
         goto Label_019D;
     Label_027A:
         if ((((uint) num5) & 0) != 0)
         {
             goto Label_0116;
         }
         goto Label_0257;
     Label_029A:
         response = (HttpWebResponse) WebRequest.Create(requestUri).GetResponse();
         Stream responseStream = response.GetResponseStream();
         if (((uint) num5) < 0)
         {
             goto Label_00B3;
         }
         dcsv = new ReadCSV(responseStream, true, CSVFormat.English);
         writer = new StreamWriter(output);
         goto Label_027A;
     }
     catch (WebException exception)
     {
         throw new QuantError(exception);
     }
 }
コード例 #9
0
        /// <inheritDoc/>
        public void Close()
        {
            if (this.readCSV != null)
            {
                this.readCSV.Close();
                this.readCSV = null;
            }

            if (this.output != null)
            {
                this.output.Close();
                this.output = null;
            }

        }
コード例 #10
0
        /// <summary>
        ///     Program entry point.
        /// </summary>
        /// <param name="app">Holds arguments and other info.</param>
        public void Execute(IExampleInterface app)
        {
            // Download the data that we will attempt to model.
            string irisFile = DownloadData(app.Args);

            // Define the format of the data file.
            // This area will change, depending on the columns and
            // format of the file that you are trying to model.
            IVersatileDataSource source = new CSVDataSource(irisFile, false,
                                                            CSVFormat.DecimalPoint);
            var data = new VersatileMLDataSet(source);

            data.DefineSourceColumn("sepal-length", 0, ColumnType.Continuous);
            data.DefineSourceColumn("sepal-width", 1, ColumnType.Continuous);
            data.DefineSourceColumn("petal-length", 2, ColumnType.Continuous);
            data.DefineSourceColumn("petal-width", 3, ColumnType.Continuous);

            // Define the column that we are trying to predict.
            ColumnDefinition outputColumn = data.DefineSourceColumn("species", 4,
                                                                    ColumnType.Nominal);

            // Analyze the data, determine the min/max/mean/sd of every column.
            data.Analyze();

            // Map the prediction column to the output of the model, and all
            // other columns to the input.
            data.DefineSingleOutputOthersInput(outputColumn);

            // Create feedforward neural network as the model type. MLMethodFactory.TYPE_FEEDFORWARD.
            // You could also other model types, such as:
            // MLMethodFactory.SVM:  Support Vector Machine (SVM)
            // MLMethodFactory.TYPE_RBFNETWORK: RBF Neural Network
            // MLMethodFactor.TYPE_NEAT: NEAT Neural Network
            // MLMethodFactor.TYPE_PNN: Probabilistic Neural Network
            var model = new EncogModel(data);

            model.SelectMethod(data, MLMethodFactory.TypeFeedforward);

            // Send any output to the console.
            model.Report = new ConsoleStatusReportable();

            // Now normalize the data.  Encog will automatically determine the correct normalization
            // type based on the model you chose in the last step.
            data.Normalize();

            // Hold back some data for a final validation.
            // Shuffle the data into a random ordering.
            // Use a seed of 1001 so that we always use the same holdback and will get more consistent results.
            model.HoldBackValidation(0.3, true, 1001);

            // Choose whatever is the default training type for this model.
            model.SelectTrainingType(data);

            // Use a 5-fold cross-validated train.  Return the best method found.
            var bestMethod = (IMLRegression)model.Crossvalidate(5, true);

            // Display the training and validation errors.
            Console.WriteLine(@"Training error: " + model.CalculateError(bestMethod, model.TrainingDataset));
            Console.WriteLine(@"Validation error: " + model.CalculateError(bestMethod, model.ValidationDataset));

            // Display our normalization parameters.
            NormalizationHelper helper = data.NormHelper;

            Console.WriteLine(helper.ToString());

            // Display the final model.
            Console.WriteLine(@"Final model: " + bestMethod);

            // Loop over the entire, original, dataset and feed it through the model.
            // This also shows how you would process new data, that was not part of your
            // training set.  You do not need to retrain, simply use the NormalizationHelper
            // class.  After you train, you can save the NormalizationHelper to later
            // normalize and denormalize your data.
            source.Close();
            var     csv   = new ReadCSV(irisFile, false, CSVFormat.DecimalPoint);
            var     line  = new String[4];
            IMLData input = helper.AllocateInputVector();

            while (csv.Next())
            {
                var result = new StringBuilder();
                line[0] = csv.Get(0);
                line[1] = csv.Get(1);
                line[2] = csv.Get(2);
                line[3] = csv.Get(3);
                String correct = csv.Get(4);
                helper.NormalizeInputVector(line, ((BasicMLData)input).Data, false);
                IMLData output     = bestMethod.Compute(input);
                String  irisChosen = helper.DenormalizeOutputVectorToString(output)[0];

                result.Append(line);
                result.Append(" -> predicted: ");
                result.Append(irisChosen);
                result.Append("(correct: ");
                result.Append(correct);
                result.Append(")");

                Console.WriteLine(result.ToString());
            }
            csv.Close();

            // Delete data file ande shut down.
            File.Delete(irisFile);
            EncogFramework.Instance.Shutdown();
        }
コード例 #11
0
        /// <summary>
        /// Load financial data.
        /// </summary>
        /// <param name="ticker">The ticker symbol.</param>
        /// <param name="output">The output file.</param>
        /// <param name="outputFormat">The output format.</param>
        /// <param name="from">Starting date.</param>
        /// <param name="to">Ending date.</param>
        public void LoadAllData(String ticker, String output, CSVFormat outputFormat, DateTime from,
            DateTime to)
        {
            try
            {
                Uri urlData = BuildURL(ticker, from, to);
                WebRequest httpData = WebRequest.Create(urlData);
                var responseData = (HttpWebResponse) httpData.GetResponse();

                if (responseData != null)
                {
                    Stream istreamData = responseData.GetResponseStream();
                    var csvData = new ReadCSV(istreamData, true, CSVFormat.English);

                    TextWriter tw = new StreamWriter(output);
                    tw.WriteLine("date,time,open price,high price,low price,close price,volume,adjusted price");

                    while (csvData.Next())
                    {
                        DateTime date = csvData.GetDate("date");
                        double adjustedClose = csvData.GetDouble("adj close");
                        double open = csvData.GetDouble("open");
                        double close = csvData.GetDouble("close");
                        double high = csvData.GetDouble("high");
                        double low = csvData.GetDouble("low");
                        var volume = (long) csvData.GetDouble("volume");

                        var line = new StringBuilder();
                        line.Append(NumericDateUtil.DateTime2Long(date));
                        line.Append(outputFormat.Separator);
                        line.Append(NumericDateUtil.Time2Int(date));
                        line.Append(outputFormat.Separator);
                        line.Append(outputFormat.Format(open, Precision));
                        line.Append(outputFormat.Separator);
                        line.Append(outputFormat.Format(high, Precision));
                        line.Append(outputFormat.Separator);
                        line.Append(outputFormat.Format(low, Precision));
                        line.Append(outputFormat.Separator);
                        line.Append(outputFormat.Format(close, Precision));
                        line.Append(outputFormat.Separator);
                        line.Append(volume);
                        line.Append(outputFormat.Separator);
                        line.Append(outputFormat.Format(adjustedClose, Precision));
                        tw.WriteLine(line.ToString());
                    }

                    tw.Close();
                }
            }
            catch (WebException ex)
            {
                throw new QuantError(ex);
            }
        }
コード例 #12
0
    void getComponents()
    {
        GameObject functions = GameObject.Find ("Functions");
        saveData = functions.GetComponent<SaveData> ();
        readCSV = functions.GetComponent<ReadCSV> ();

        gameData = GameObject.Find ("GameData").GetComponent<GameData> ();

        remainingGoldText = GameObject.Find ("RemainingGold").GetComponent<Text> ();
        NPCGoldText = GameObject.Find ("NPCGold").GetComponent<Text> ();
        markupSlider = GameObject.Find ("MarkupSlider").GetComponent<Slider> ();
        markupValue = GameObject.Find ("MarkupValue").GetComponent<Text> ();
        markupSlider.value = 120;
        previousMarkupValue = 120;

        previousQuestOutcome = GameObject.Find ("PreviousQuestOutcome").transform.GetComponentInChildren<Text> ();

        ListStoreInv_Values = GameObject.Find ("ListStoreInv_Values");
        ListStoreInv_SampleValue = GameObject.Find ("ListStoreInv_SampleValue");

        ListStoreInv_Buttons = GameObject.Find ("ListStoreInv_Buttons");
        ListStoreInv_SampleButton = GameObject.Find ("ListStoreInv_SampleButton");

        ListStoreInv_ScrollContent = GameObject.Find ("ListStoreInv_ScrollContent");

        ListStoreInv_ScrollView = GameObject.Find ("ListStoreInv_ScrollView");

        ListStoreInv_ScrollBar = GameObject.Find ("ListStoreInv_ScrollBar");

        NPCDialogue_Text = GameObject.Find ("NPCDialogue_Text");
        Dialogue_ResponsePanel = GameObject.Find ("Dialogue_ResponsePanel");
        PlayerResponse_SampleButton = GameObject.Find ("PlayerResponse_SampleButton");

        Waypoint_Door = GameObject.Find ("Waypoint_Door");
        Waypoint_Counter = GameObject.Find ("Waypoint_Counter");
        CustomerSprite = GameObject.Find ("Customer");
    }
コード例 #13
0
        static void Main(string[] args)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            int         reading_method = Configuration.READING_MULTIITEM_METHOD;
            List <Item> items;

            if (reading_method == 0)
            {
                items = ReadCSV.readFromCSV();
            }
            else
            {
                items = ReadCSV.readFromCSVNoMultipleItems();
            }


            List <Item>           comparison;
            List <PotentialPoint> potentialpointsSx = new List <PotentialPoint>();
            List <PotentialPoint> potentialpointsDx = new List <PotentialPoint>();

            WriteCSV.WriteFullItemListWithID(items);

            /*TO CREATE NEW INSTANCES*/
            //        InstanceCreator.writeInstance();

            double upper_bound;

            upper_bound = Functions.objFunction(items);

            //WriteCSV.writeList(items);

            // furgonato
            Container c = new Container(Configuration.CONTAINER_WIDTH, Configuration.CONTAINER_HEIGHT, Configuration.CONTAINER_DEPTH, Configuration.CONTAINER_MAX_WEIGHT, Configuration.CONTAINER_UNLOADABLE_FROM_SIDE);


            List <Item> items1;

            Solution[] solution = Solver.multiRunSolution(items, c, potentialpointsSx, potentialpointsDx);


            Solution sol = solution[0];

            items1 = sol.getItemsPacked();

            WriteCSV.WriteItemPositionForVisualization(items1);
            WriteCSV.WriteOutpoutDescription(items1);


            double myResult;

            myResult = Functions.objFunction(items1);

            double x, y, z;

            x = Functions.dev_x(items1, c);
            y = Functions.dev_y(items1, c);
            //        z = Util.Functions.dev_z(items1, c);


            c.loadedItemsInZone(items1);

            double weightMax;

            weightMax = Functions.totalWeightOfItems(items);

            List <Item> unpackedItems         = Functions.getUnpackedItems(items, items1);
            int         priority1leftUnpacked = Functions.itemsPriorityOneUnpacked(unpackedItems);
            int         priority0leftUnpacked = Functions.itemsPriorityZeroUnpacked(unpackedItems);

            bool   feasible           = sol.zoneWeightFeasibility(c);
            double companyBound       = ReadCSV.getCompanyBound();
            double companyTotVol      = ReadCSV.getCompanyTotVol();
            double companyTotWeight   = ReadCSV.getCompanyTotWeight();
            int    companyItemsPacked = ReadCSV.getCompanyItemsPacked();

            sw.Stop();

            /*        System.err.println("Company bound: " + companyBound);
             *      System.err.println("My_bound: " + myResult);
             *      System.err.println("---------------------------------");*/
            Console.WriteLine("Performance : " + Functions.round((myResult / companyBound * (100)), 2) + " %");


            //Console.WriteLine("Read: " + StopwatchTimer.GetElapsedMillisecondsAndReset("read"));
            //Console.WriteLine("Write: " + StopwatchTimer.GetElapsedMillisecondsAndReset("write"));
            ////Console.WriteLine("Sort: " + StopwatchTimer.GetElapsedMillisecondsAndReset("sort"));
            //Console.WriteLine("Add: " + StopwatchTimer.GetElapsedMillisecondsAndReset("add"));
            ////Console.WriteLine("Pack: " + StopwatchTimer.GetElapsedMillisecondsAndReset("pack"));
            ////Console.WriteLine("Splice: " + StopwatchTimer.GetElapsedMillisecondsAndReset("splice"));
            ////Console.WriteLine("Overlap: " + StopwatchTimer.GetElapsedMillisecondsAndReset("overlap"));
            ////Console.WriteLine("Corner: " + StopwatchTimer.GetElapsedMillisecondsAndReset("corner"));
            ////Console.WriteLine("Dimension: " + StopwatchTimer.GetElapsedMillisecondsAndReset("dimension"));
            ////Console.WriteLine("Corners Checked: " + StopwatchTimer.CornerChecks);
            //Console.WriteLine("Corners Checked: " + Container.OverlapChecks);
            //Console.WriteLine("Elapsed: " + sw.ElapsedMilliseconds);
        }
コード例 #14
0
        /// <summary>
        /// Load the specified financial data. 
        /// </summary>
        /// <param name="ticker">The ticker symbol to load.</param>
        /// <param name="dataNeeded">The financial data needed.</param>
        /// <param name="from">The beginning date to load data from.</param>
        /// <param name="to">The ending date to load data to.</param>
        /// <returns>A collection of LoadedMarketData objects that represent the data
        /// loaded.</returns>
        public ICollection<LoadedMarketData> Load(TickerSymbol ticker,
                 IList<MarketDataType> dataNeeded, DateTime from,
                 DateTime to)
        {

            ICollection<LoadedMarketData> result =
               new List<LoadedMarketData>();
            Uri url = buildURL(ticker, from, to);
            WebRequest http = HttpWebRequest.Create(url);
            HttpWebResponse response = (HttpWebResponse)http.GetResponse();

            using (Stream istream = response.GetResponseStream())
            {
                ReadCSV csv = new ReadCSV(istream, true, CSVFormat.DECIMAL_POINT);

                while (csv.Next())
                {
                    DateTime date = csv.GetDate("date");
                    double adjClose = csv.GetDouble("adj close");
                    double open = csv.GetDouble("open");
                    double close = csv.GetDouble("close");
                    double high = csv.GetDouble("high");
                    double low = csv.GetDouble("low");
                    double volume = csv.GetDouble("volume");

                    LoadedMarketData data =
                       new LoadedMarketData(date, ticker);
                    data.SetData(MarketDataType.ADJUSTED_CLOSE, adjClose);
                    data.SetData(MarketDataType.OPEN, open);
                    data.SetData(MarketDataType.CLOSE, close);
                    data.SetData(MarketDataType.HIGH, high);
                    data.SetData(MarketDataType.LOW, low);
                    data.SetData(MarketDataType.OPEN, open);
                    data.SetData(MarketDataType.VOLUME, volume);
                    result.Add(data);
                }

                csv.Close();
                istream.Close();
            }
            return result;

        }
コード例 #15
0
ファイル: EncogUtility.cs プロジェクト: neismit/emds
 public static void ConvertCSV2Binary(FileInfo csvFile, CSVFormat format, FileInfo binFile, int[] input, int[] ideal, bool headers)
 {
     ReadCSV dcsv;
     BufferedMLDataSet set;
     BasicMLData data;
     BasicMLData data2;
     int num;
     int num2;
     binFile.Delete();
     goto Label_00FB;
     Label_0021:
     if (dcsv.Next() || ((((uint) num) - ((uint) num2)) > uint.MaxValue))
     {
         data = new BasicMLData(input.Length);
         if ((((uint) headers) | uint.MaxValue) != 0)
         {
             data2 = new BasicMLData(ideal.Length);
             if (4 != 0)
             {
                 if (((uint) num) <= uint.MaxValue)
                 {
                     goto Label_0073;
                 }
                 goto Label_00FB;
             }
         }
         goto Label_00C0;
     }
     set.EndLoad();
     if (0 == 0)
     {
         return;
     }
     Label_0073:
     num = 0;
     while (num < input.Length)
     {
         data[num] = dcsv.GetDouble(input[num]);
         num++;
     }
     for (num2 = 0; num2 < ideal.Length; num2++)
     {
         data2[num2] = dcsv.GetDouble(ideal[num2]);
     }
     set.Add(data, data2);
     goto Label_0021;
     Label_00C0:
     set = new BufferedMLDataSet(binFile.ToString());
     set.BeginLoad(input.Length, ideal.Length);
     goto Label_0021;
     Label_00FB:
     dcsv = new ReadCSV(csvFile.ToString(), headers, format);
     goto Label_00C0;
 }
コード例 #16
0
ファイル: CSVDataCODEC.cs プロジェクト: neismit/emds
 public void PrepareRead()
 {
     if (this._x43f451310e815b76 == 0)
     {
         throw new BufferedDataError("To import CSV, you must use the CSVDataCODEC constructor that specifies input and ideal sizes.");
     }
     this._x880b5c00ed0b619c = new ReadCSV(this._xb44380e048627945, this._x94e6ca5ac178dbd0, this._x5786461d089b10a0);
 }
コード例 #17
0
ファイル: TrainingSetUtil.cs プロジェクト: neismit/emds
 public static IMLDataSet LoadCSVTOMemory(CSVFormat format, string filename, bool headers, int inputSize, int idealSize)
 {
     ReadCSV dcsv;
     IMLData data;
     int num;
     IMLData data2;
     int num4;
     IMLDataSet set = new BasicMLDataSet();
     goto Label_00FF;
     Label_000B:
     if (idealSize > 0)
     {
         data = new BasicMLData(idealSize);
         num4 = 0;
         while (num4 < idealSize)
         {
             double num5 = dcsv.GetDouble(num++);
             data[num4] = num5;
             num4++;
         }
     }
     IMLDataPair inputData = new BasicMLDataPair(data2, data);
     set.Add(inputData);
     Label_0022:
     if (!dcsv.Next())
     {
         return set;
     }
     Label_00C4:
     data = null;
     num = 0;
     if (((uint) num4) < 0)
     {
         goto Label_0108;
     }
     data2 = new BasicMLData(inputSize);
     int num2 = 0;
     Label_006A:
     if (num2 < inputSize)
     {
         double num3 = dcsv.GetDouble(num++);
         if (-2147483648 != 0)
         {
             data2[num2] = num3;
             if ((((uint) idealSize) + ((uint) num)) >= 0)
             {
                 num2++;
             }
             if ((((uint) num) - ((uint) idealSize)) >= 0)
             {
                 goto Label_006A;
             }
             goto Label_0125;
         }
     }
     else
     {
         if (0 == 0)
         {
             goto Label_000B;
         }
         if (0 == 0)
         {
             goto Label_0125;
         }
     }
     goto Label_00C4;
     Label_00FF:
     dcsv = new ReadCSV(filename, headers, format);
     Label_0108:
     if ((((uint) num) + ((uint) num2)) < 0)
     {
         goto Label_00FF;
     }
     goto Label_0022;
     Label_0125:
     if (((uint) num4) >= 0)
     {
         goto Label_000B;
     }
     return set;
 }
コード例 #18
0
        /// <summary>
        ///     Process the file.
        /// </summary>
        /// <param name="outputFile">The output file.</param>
        /// <param name="method">THe method to use.</param>
        public void Process(FileInfo outputFile, IMLMethod method)
        {
            var csv = new ReadCSV(InputFilename.ToString(),
                                  ExpectInputHeaders, Format);

            IMLData output;

            foreach (AnalystField field in _analyst.Script.Normalize.NormalizedFields)
            {
                field.Init();
            }

            int outputLength = _analyst.DetermineTotalInputFieldCount();

            StreamWriter tw = PrepareOutputFile(outputFile);

            ResetStatus();
            while (csv.Next())
            {
                UpdateStatus(false);
                var row = new LoadedRow(csv, _outputColumns);

                double[] inputArray = AnalystNormalizeCSV.ExtractFields(_analyst,
                                                                        _analystHeaders, csv, outputLength, true);
                if (_series.TotalDepth > 1)
                {
                    inputArray = _series.Process(inputArray);
                }

                if (inputArray != null)
                {
                    IMLData input = new BasicMLData(inputArray);

                    // evaluation data
                    if ((method is IMLClassification) &&
                        !(method is IMLRegression))
                    {
                        // classification only?
                        var tmp = new BasicMLData(1);
                        tmp[0] = ((IMLClassification)method).Classify(input);
                        output = tmp;
                    }
                    else
                    {
                        // regression
                        output = ((IMLRegression)method).Compute(input);
                    }

                    // skip file data
                    int index       = _fileColumns;
                    int outputIndex = 0;


                    // display output
                    foreach (AnalystField field  in  _analyst.Script.Normalize.NormalizedFields)
                    {
                        if (_analystHeaders.Find(field.Name) != -1)
                        {
                            if (field.Output)
                            {
                                if (field.Classify)
                                {
                                    // classification
                                    ClassItem cls = field.DetermineClass(
                                        outputIndex, output);
                                    outputIndex += field.ColumnsNeeded;
                                    if (cls == null)
                                    {
                                        row.Data[index++] = "?Unknown?";
                                    }
                                    else
                                    {
                                        row.Data[index++] = cls.Name;
                                    }
                                }
                                else
                                {
                                    // regression
                                    double n = output[outputIndex++];
                                    n = field.DeNormalize(n);
                                    row.Data[index++] = Format
                                                        .Format(n, Precision);
                                }
                            }
                        }
                    }
                }

                WriteRow(tw, row);
            }
            ReportDone(false);
            tw.Close();
            csv.Close();
        }
コード例 #19
0
        /// <summary>
        /// Private constructor.
        /// </summary>
        ///
        private PropertyConstraints()
        {
            _data = new Dictionary <String, List <PropertyEntry> >();
            try
            {
                Stream mask0 = ResourceLoader.CreateStream("Encog.Resources.analyst.csv");
                var    csv   = new ReadCSV(mask0, false, CSVFormat.EgFormat);

                while (csv.Next())
                {
                    String sectionStr = csv.Get(0);
                    String nameStr    = csv.Get(1);
                    String typeStr    = csv.Get(2);

                    // determine type
                    PropertyType t;
                    if ("boolean".Equals(typeStr, StringComparison.InvariantCultureIgnoreCase))
                    {
                        t = PropertyType.TypeBoolean;
                    }
                    else if ("real".Equals(typeStr, StringComparison.InvariantCultureIgnoreCase))
                    {
                        t = PropertyType.TypeDouble;
                    }
                    else if ("format".Equals(typeStr, StringComparison.InvariantCultureIgnoreCase))
                    {
                        t = PropertyType.TypeFormat;
                    }
                    else if ("int".Equals(typeStr, StringComparison.InvariantCultureIgnoreCase))
                    {
                        t = PropertyType.TypeInteger;
                    }
                    else if ("list-string".Equals(typeStr, StringComparison.InvariantCultureIgnoreCase))
                    {
                        t = PropertyType.TypeListString;
                    }
                    else if ("string".Equals(typeStr, StringComparison.InvariantCultureIgnoreCase))
                    {
                        t = PropertyType.TypeString;
                    }
                    else
                    {
                        throw new AnalystError("Unknown type constraint: "
                                               + typeStr);
                    }

                    var entry = new PropertyEntry(t, nameStr,
                                                  sectionStr);
                    List <PropertyEntry> list;

                    if (_data.ContainsKey(sectionStr))
                    {
                        list = _data[sectionStr];
                    }
                    else
                    {
                        list = new List <PropertyEntry>();
                        _data[sectionStr] = list;
                    }

                    list.Add(entry);
                }

                csv.Close();
                mask0.Close();
            }
            catch (IOException e)
            {
                throw new EncogError(e);
            }
        }
コード例 #20
0
ファイル: AnalystReport.cs プロジェクト: neismit/emds
 private void x076efb43809972d8()
 {
     string str;
     FileInfo info;
     CSVFormat format;
     bool flag;
     ScriptProperties properties = this._x554f16462d8d4675.Script.Properties;
     Label_00AD:
     str = properties.GetPropertyString("HEADER:DATASOURCE_rawFile");
     do
     {
         info = this._x554f16462d8d4675.Script.ResolveFilename(str);
         if (((uint) flag) < 0)
         {
             goto Label_00AD;
         }
         format = this._x554f16462d8d4675.Script.DetermineInputFormat(str);
         flag = this._x554f16462d8d4675.Script.ExpectInputHeaders(str);
     }
     while (0 != 0);
     this._x0fe0496cde3d05e3 = 0;
     if (0 == 0)
     {
         this._xed3494f8db69efb7 = 0;
         ReadCSV dcsv = new ReadCSV(info.ToString(), flag, format);
         while (dcsv.Next())
         {
             this._x0fe0496cde3d05e3++;
             if (dcsv.HasMissing())
             {
                 this._xed3494f8db69efb7++;
             }
         }
         dcsv.Close();
         if (((uint) flag) > uint.MaxValue)
         {
             goto Label_00AD;
         }
     }
 }
コード例 #21
0
 /// <summary>
 /// Prepare to read from the CSV file.
 /// </summary>
 public void PrepareRead()
 {
     if (_inputCount == 0)
     {
         throw new BufferedDataError(
             "To import CSV, you must use the CSVDataCODEC constructor that specifies input and ideal sizes.");
     }
     _readCSV = new ReadCSV(_file, _headers,
                           _format);
 }
コード例 #22
0
        /// <summary>
        /// Analyze the file.
        /// </summary>
        private void AnalyzeFile()
        {
            ScriptProperties prop = _analyst.Script.Properties;

            // get filenames, headers & format
            String sourceID = prop.GetPropertyString(
                ScriptProperties.HeaderDatasourceRawFile);

            FileInfo sourceFile = _analyst.Script.ResolveFilename(sourceID);
            CSVFormat format = _analyst.Script.DetermineFormat();
            bool headers = _analyst.Script.ExpectInputHeaders(sourceID);

            // read the file
            _rowCount = 0;
            _missingCount = 0;

            var csv = new ReadCSV(sourceFile.ToString(), headers, format);
            while (csv.Next())
            {
                _rowCount++;
                if (csv.HasMissing())
                {
                    _missingCount++;
                }
            }
            csv.Close();
        }
コード例 #23
0
 void Awake()
 {
     dir     = GameObject.Find("BattleDirecter");
     csv     = dir.GetComponent <ReadCSV>();
     VScript = dir.GetComponent <ValueScript>();
 }
コード例 #24
0
ファイル: CSVDataCODEC.cs プロジェクト: neismit/emds
 public void Close()
 {
     if (this._x880b5c00ed0b619c == null)
     {
         goto Label_0014;
     }
     if (0 == 0)
     {
         goto Label_0025;
     }
     Label_000B:
     this._x9c13656d94fc62d0 = null;
     return;
     Label_0014:
     if (this._x9c13656d94fc62d0 != null)
     {
         this._x9c13656d94fc62d0.Close();
         goto Label_000B;
     }
     if (0x7fffffff != 0)
     {
         return;
     }
     Label_0025:
     this._x880b5c00ed0b619c.Close();
     this._x880b5c00ed0b619c = null;
     goto Label_0014;
 }
コード例 #25
0
        /// <summary>
        /// Analyze the input file.
        /// </summary>
        ///
        /// <param name="input">The input file.</param>
        /// <param name="headers">True, if there are headers.</param>
        /// <param name="format">The format of the CSV data.</param>
        public virtual void Analyze(FileInfo input, bool headers,
                                    CSVFormat format)
        {
            ResetStatus();
            InputFilename      = input;
            ExpectInputHeaders = headers;
            InputFormat        = format;
            _columnMapping.Clear();
            _columns.Clear();

            // first count the rows
            TextReader reader = null;

            try
            {
                int recordCount = 0;
                reader = new StreamReader(InputFilename.OpenRead());
                while (reader.ReadLine() != null)
                {
                    UpdateStatus(true);
                    recordCount++;
                }

                if (headers)
                {
                    recordCount--;
                }
                RecordCount = recordCount;
            }
            catch (IOException ex)
            {
                throw new QuantError(ex);
            }
            finally
            {
                ReportDone(true);
                if (reader != null)
                {
                    try
                    {
                        reader.Close();
                    }
                    catch (IOException e)
                    {
                        throw new QuantError(e);
                    }
                }
                InputFilename      = input;
                ExpectInputHeaders = headers;
                InputFormat        = format;
            }

            // now analyze columns
            ReadCSV csv = null;

            try
            {
                csv = new ReadCSV(input.ToString(), headers, format);
                if (!csv.Next())
                {
                    throw new QuantError("File is empty");
                }

                for (int i = 0; i < csv.ColumnCount; i++)
                {
                    String name;

                    if (headers)
                    {
                        name = AttemptResolveName(csv.ColumnNames[i]);
                    }
                    else
                    {
                        name = "Column-" + (i + 1);
                    }

                    // determine if it should be an input/output field

                    String str = csv.Get(i);

                    bool io = false;

                    try
                    {
                        InputFormat.Parse(str);
                        io = true;
                    }
                    catch (FormatException ex)
                    {
                        EncogLogging.Log(ex);
                    }

                    AddColumn(new FileData(name, i, io, io));
                }
            }
            finally
            {
                if (csv != null)
                {
                    csv.Close();
                }
                Analyzed = true;
            }
        }
コード例 #26
0
        public void EvaluateNetwork()
        {
            BasicNetwork network = LoadNetwork();
            DataNormalization norm = LoadNormalization();

            var csv = new ReadCSV(_config.EvaluateFile.ToString(), false, ',');
            var input = new double[norm.InputFields.Count];
            var eqField = (OutputEquilateral) norm.FindOutputField(
                typeof (OutputEquilateral), 0);

            int correct = 0;
            int total = 0;
            while (csv.Next())
            {
                total++;
                for (int i = 0; i < input.Length; i++)
                {
                    input[i] = csv.GetDouble(i);
                }
                IMLData inputData = norm.BuildForNetworkInput(input);
                IMLData output = network.Compute(inputData);
                int coverTypeActual = DetermineTreeType(eqField, output);
                int coverTypeIdeal = (int) csv.GetDouble(54) - 1;

                KeepScore(coverTypeActual, coverTypeIdeal);

                if (coverTypeActual == coverTypeIdeal)
                {
                    correct++;
                }
            }

            Console.WriteLine(@"Total cases:" + total);
            Console.WriteLine(@"Correct cases:" + correct);
            double percent = correct/(double) total;
            Console.WriteLine(@"Correct percent:"
                              + Format.FormatPercentWhole(percent));
            for (int i = 0; i < 7; i++)
            {
                double p = (_treeCorrect[i]/(double) _treeCount[i]);
                Console.WriteLine(@"Tree Type #" + i + @" - Correct/total: "
                                  + _treeCorrect[i] + @"/" + _treeCount[i] + @"("
                                  + Format.FormatPercentWhole(p) + @")");
            }
        }
コード例 #27
0
ファイル: TrackMenu.cs プロジェクト: yuwen41200/XRProject3
 private void Start()
 {
     readcsv = new ReadCSV();
     // OpenPanel();
 }
コード例 #28
0
        /// <summary>
        /// Process the input file and segregate into the output files.
        /// </summary>
        ///
        public void Process()
        {
            Validate();

            var csv = new ReadCSV(InputFilename.ToString(),
                                  ExpectInputHeaders, InputFormat);
            ResetStatus();

            foreach (SegregateTargetPercent target  in  _targets)
            {
                StreamWriter tw = PrepareOutputFile(target.Filename);

                while ((target.NumberRemaining > 0) && csv.Next()
                       && !ShouldStop())
                {
                    UpdateStatus(false);
                    var row = new LoadedRow(csv);
                    WriteRow(tw, row);
                    target.NumberRemaining = target.NumberRemaining - 1;
                }

                tw.Close();
            }
            ReportDone(false);
            csv.Close();
        }
コード例 #29
0
ファイル: YahooFinanceLoader.cs プロジェクト: neismit/emds
 public ICollection<LoadedMarketData> Load(TickerSymbol ticker, IList<MarketDataType> dataNeeded, DateTime from, DateTime to)
 {
     ICollection<LoadedMarketData> is2 = new List<LoadedMarketData>();
     HttpWebResponse response = (HttpWebResponse) WebRequest.Create(x38c212309d8d5dd3(ticker, from, to)).GetResponse();
     using (Stream stream = response.GetResponseStream())
     {
         DateTime time;
         double num;
         double num2;
         double num3;
         double num4;
         double num5;
         double num6;
         LoadedMarketData data;
         ReadCSV dcsv = new ReadCSV(stream, true, CSVFormat.DecimalPoint);
         goto Label_005B;
     Label_003F:
         data.SetData(MarketDataType.Open, num2);
     Label_0049:
         data.SetData(MarketDataType.Volume, num6);
         is2.Add(data);
     Label_005B:
         if (dcsv.Next())
         {
             goto Label_01AF;
         }
         dcsv.Close();
         stream.Close();
         if ((((uint) num) - ((uint) num5)) <= uint.MaxValue)
         {
             goto Label_0125;
         }
         if ((((uint) num) & 0) == 0)
         {
             goto Label_00B0;
         }
     Label_00A4:
         data.SetData(MarketDataType.Low, num5);
         goto Label_003F;
     Label_00B0:
         data.SetData(MarketDataType.AdjustedClose, num);
         do
         {
             data.SetData(MarketDataType.Open, num2);
             if ((((uint) num) - ((uint) num6)) > uint.MaxValue)
             {
                 goto Label_0049;
             }
             data.SetData(MarketDataType.Close, num3);
             data.SetData(MarketDataType.High, num4);
         }
         while ((((uint) num5) - ((uint) num3)) > uint.MaxValue);
         if (((uint) num2) >= 0)
         {
             goto Label_00A4;
         }
         goto Label_003F;
     Label_0125:
         if (((uint) num2) >= 0)
         {
             return is2;
         }
         goto Label_005B;
     Label_013C:
         num6 = dcsv.GetDouble("volume");
         data = new LoadedMarketData(time, ticker);
         if ((((uint) num2) | 2) == 0)
         {
             goto Label_017C;
         }
         goto Label_00B0;
     Label_016E:
         num2 = dcsv.GetDouble("open");
     Label_017C:
         num3 = dcsv.GetDouble("close");
         num4 = dcsv.GetDouble("high");
         num5 = dcsv.GetDouble("low");
         goto Label_013C;
     Label_01AF:
         time = dcsv.GetDate("date");
         num = dcsv.GetDouble("adj close");
         if ((((uint) num3) + ((uint) num6)) <= uint.MaxValue)
         {
             goto Label_016E;
         }
         goto Label_00B0;
     }
 }
コード例 #30
0
        /// <inheritDoc/>
        public void Close()
        {
            if (_readCSV != null)
            {
                _readCSV.Close();
                _readCSV = null;
            }

            if (_output != null)
            {
                _output.Close();
                _output = null;
            }
        }
コード例 #31
0
ファイル: LoadedRow.cs プロジェクト: shturm/encog-prim
 /// <summary>
 ///     Load a row from the specified CSV file.
 /// </summary>
 /// <param name="csv">The CSV file to use.</param>
 public LoadedRow(ReadCSV csv) : this(csv, 0)
 {
 }