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 |
|
---|
8 | using System;
|
---|
9 | using System.Linq;
|
---|
10 | using System.Collections.Generic;
|
---|
11 |
|
---|
12 | using HeuristicLab.Core;
|
---|
13 | using HeuristicLab.Common;
|
---|
14 | //using HeuristicLab.Collections;
|
---|
15 | //using HeuristicLab.Data;
|
---|
16 | using HeuristicLab.Problems.Instances.DataAnalysis;
|
---|
17 | using System.IO;
|
---|
18 |
|
---|
19 | public 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 | }
|
---|