Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3022-FastFunctionExtraction/data/DataGenerationInHeuristicLab.txt @ 17305

Last change on this file since 17305 was 17218, checked in by lleko, 5 years ago

#3022 renamed C#-Project, Solution, Plugin and Algorithm
created sample data
downloaded python repo
created script for testing core.py functionality of python repo

File size: 1.7 KB
Line 
1// use 'vars' to access variables in the script's variable store (e.g. vars.x = 5)
2// use 'vars[string]' to access variables via runtime strings (e.g. vars["x"] = 5)
3// use 'vars.Contains(string)' to check if a variable exists
4// use 'vars.Clear()' to remove all variables
5// use 'foreach (KeyValuePair<string, object> v in vars) { ... }' to iterate over all variables
6// use 'variables' to work with IEnumerable<T> extension methods on the script's variable store
7
8using System;
9using System.Linq;
10using System.Collections.Generic;
11
12using HeuristicLab.Core;
13using HeuristicLab.Common;
14//using HeuristicLab.Collections;
15//using HeuristicLab.Data;
16using HeuristicLab.Problems.Instances.DataAnalysis;
17using System.IO;
18
19public class MyScript : HeuristicLab.Scripting.CSharpScriptBase {
20  public override void Main() {
21      var provider = new PhysicsInstanceProvider();
22      var count = 0;
23      foreach(var descriptor in provider.GetDataDescriptors()) {
24        var problemData = provider.LoadData(descriptor);
25        var path = "C:/repo/Bachelorarbeit/hl-core/branches/3022-FastFunctionExtraction/data/_" + count + "_.csv";
26        Console.Write(path);
27        provider.ExportData(problemData, path);
28        count++;
29       
30        var ds = problemData.Dataset;
31       
32        using (var sw = new StreamWriter(path))
33          {
34        for (int i =0; i <ds.Rows; ++i)
35          {
36          var variables = ds.DoubleVariables.ToList();
37         
38          for (int j = 0; j < ds.Columns; ++j)
39            {
40                                             sw.Write(ds.GetDoubleValue(variables[j], i).ToString() + ";");
41          }
42          sw.WriteLine();
43          }
44        }
45      }
46
47  // implement further classes and methods
48  }
49}
Note: See TracBrowser for help on using the repository browser.