Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/28/18 17:05:11 (6 years ago)
Author:
gkronber
Message:

#2929: renaming things

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2929_PrioritizedGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.PGE/3.3/PGE.cs

    r16196 r16197  
    1818  public unsafe class PGE : BasicAlgorithm {
    1919
    20     [DllImport("go-pge.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
    21     public static extern void addTestData(IntPtr indepNames, IntPtr depndNames, IntPtr matrix, int nEntries);
     20    [DllImport("go-pge.dll", EntryPoint = "addTestData", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
     21    public static extern void AddTestData(IntPtr indepNames, IntPtr depndNames, IntPtr matrix, int nEntries);
    2222
    23     [DllImport("go-pge.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
    24     public static extern void addTrainData(IntPtr indepNames, IntPtr depndNames, IntPtr matrix, int nEntries);
     23    [DllImport("go-pge.dll", EntryPoint = "addTrainData", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
     24    public static extern void AddTrainData(IntPtr indepNames, IntPtr depndNames, IntPtr matrix, int nEntries);
    2525
    26     [DllImport("go-pge.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
    27     public static extern void initSearch(int maxGen, int pgeRptEpoch, int pgeRptCount, int pgeArchiveCap, int peelCnt, int evalrCount, double zeroEpsilon, IntPtr initMethod, IntPtr growMethod, int sortType);
     26    [DllImport("go-pge.dll", EntryPoint = "initSearch", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
     27    public static extern void InitSearch(int maxGen, int pgeRptEpoch, int pgeRptCount, int pgeArchiveCap, int peelCnt, int evalrCount, double zeroEpsilon, IntPtr initMethod, IntPtr growMethod, int sortType);
    2828
    29     [DllImport("go-pge.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
    30     public static extern void initTreeParams(IntPtr Roots, IntPtr Nodes, IntPtr NonTrig, IntPtr Leafs, IntPtr UsableVars, int UsableVarsN, int MaxSize, int MinSize, int MaxDepth, int MinDepth);
     29    [DllImport("go-pge.dll", EntryPoint = "initTreeParams", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
     30    public static extern void InitTreeParams(IntPtr Roots, IntPtr Nodes, IntPtr NonTrig, IntPtr Leafs, IntPtr UsableVars, int UsableVarsN, int MaxSize, int MinSize, int MaxDepth, int MinDepth);
    3131
    32     [DllImport("go-pge.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
    33     public static extern void initProblem(IntPtr Name, int MaxIter, double HitRatio, int SearchVar, IntPtr ProblemTypeString, int numProcs);
     32    [DllImport("go-pge.dll", EntryPoint = "initProblem", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
     33    public static extern void InitProblem(IntPtr Name, int MaxIter, double HitRatio, int SearchVar, IntPtr ProblemTypeString, int numProcs);
    3434
    35     [DllImport("go-pge.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
    36     public static extern void stepW();
     35    [DllImport("go-pge.dll", EntryPoint = "stepW", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
     36    public static extern void StepW();
    3737
    38     [DllImport("go-pge.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
    39     public static extern IntPtr getStepResult(out Int64 nobestpush, out Int64 bestnewminerr, out Int64 bestlen1, out Int64 bestlen2, out Int64 testscore, out IntPtr coeff, out Int64 nCoeff);
     38    [DllImport("go-pge.dll", EntryPoint = "getStepResult", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
     39    public static extern IntPtr GetStepResult(out Int64 nobestpush, out Int64 bestnewminerr, out Int64 bestlen1, out Int64 bestlen2, out Int64 testscore, out IntPtr coeff, out Int64 nCoeff);
    4040
    4141    public override Type ProblemType { get { return typeof(RegressionProblem); } }
     
    285285    }
    286286
    287     // Persistence uses this ctor to improve deserialization efficiency.
    288     // If we would use the default ctor instead this would completely initialize the object (e.g. creating parameters)
    289     // even though the data is later overwritten by the stored data.
     287 
    290288    [StorableConstructor]
    291289    public PGE(bool deserializing) : base(deserializing) { }
    292290
    293     // Each clonable item must have a cloning ctor (deep cloning, the cloner is used to handle cyclic object references)
    294     public PGE(PGE original, Cloner cloner) : base(original, cloner) {
    295       // Don't forget to call the cloning ctor of the base class
    296       // TODO: if this class has fields then they need to be cloned here
     291   
     292    public PGE(PGE original, Cloner cloner) : base(original, cloner) {   
     293      // nothing to clone
    297294    }
    298295
     
    303300    protected override void Run(CancellationToken cancellationToken) {
    304301
     302      // TODO: the following is potentially problematic for other go processes run on the same machine at the same time
    305303      Environment.SetEnvironmentVariable("GOGC", "off");
    306304      Environment.SetEnvironmentVariable("GODEBUG", "cgocheck=0");
    307305      Environment.SetEnvironmentVariable("CGO_ENABLED", "1");
    308306
    309       //Parameter
    310       int MaxIter = MaxIterations;
    311       string indepNames = IndependedNames;
    312       string depndNames = DependedNames;
    313307     
    314308      int nTrainData = 200;   //Woher ?
     
    321315      string Name = "Korns_02";
    322316
    323       //Calcs
    324       int indepLen = indepNames.Split(' ').Length;
    325       int depLen = depndNames.Split(' ').Length;
    326317
    327       IntPtr TrainData = GetTrainData(indepLen, depLen, nTrainData);
    328       IntPtr TestData = GetTestData(indepLen, depLen, nTestData);
     318      int indepLen = IndependedNames.Split(' ').Length;
     319      int depLen = DependedNames.Split(' ').Length;
    329320
    330       IntPtr CindepNames = Marshal.StringToHGlobalAnsi(indepNames);
    331       IntPtr CdepndNames = Marshal.StringToHGlobalAnsi(depndNames);
     321      IntPtr trainData = GetTrainData(indepLen, depLen, nTrainData);
     322      IntPtr testData = GetTestData(indepLen, depLen, nTestData);
    332323
    333       IntPtr CinitMethod = Marshal.StringToHGlobalAnsi(InitMethod);
    334       IntPtr CgrowMethod = Marshal.StringToHGlobalAnsi(GrowMethod);
     324      IntPtr cIndepNames = Marshal.StringToHGlobalAnsi(IndependedNames);
     325      IntPtr cDependentNames = Marshal.StringToHGlobalAnsi(DependedNames);
    335326
    336       IntPtr Croots = Marshal.StringToHGlobalAnsi(Roots);
    337       IntPtr Cnodes = Marshal.StringToHGlobalAnsi(Nodes);
    338       IntPtr CnonTrig = Marshal.StringToHGlobalAnsi(NonTrig);
    339       IntPtr Cleafs = Marshal.StringToHGlobalAnsi(Leafs);
     327      IntPtr cInitMethod = Marshal.StringToHGlobalAnsi(InitMethod);
     328      IntPtr cGrowMethod = Marshal.StringToHGlobalAnsi(GrowMethod);
    340329
    341       IntPtr Cname = Marshal.StringToHGlobalAnsi(Name);
    342       IntPtr CproblemTypeString = Marshal.StringToHGlobalAnsi(ProblemTypeString);
     330      IntPtr cRoots = Marshal.StringToHGlobalAnsi(Roots);
     331      IntPtr cNodes = Marshal.StringToHGlobalAnsi(Nodes);
     332      IntPtr cNonTrig = Marshal.StringToHGlobalAnsi(NonTrig);
     333      IntPtr cLeafs = Marshal.StringToHGlobalAnsi(Leafs);
     334
     335      IntPtr cName = Marshal.StringToHGlobalAnsi(Name);
     336      IntPtr cProblemTypeString = Marshal.StringToHGlobalAnsi(ProblemTypeString);
    343337
    344338
    345       Console.WriteLine("AddTrainData");
    346       addTestData(CindepNames, CdepndNames, TestData, nTestData);
     339      AddTestData(cIndepNames, cDependentNames, testData, nTestData);
    347340
    348       Console.WriteLine("AddTestData");
    349       addTrainData(CindepNames, CdepndNames, TrainData, nTrainData);
     341      AddTrainData(cIndepNames, cDependentNames, trainData, nTrainData);
    350342
    351343      IntPtr UsableVars = GetUsableVars(NumberOfUseableVariables);
    352344
    353       Console.WriteLine("InitSearch");
    354       initSearch(MaxGen, PgeRptEpoch, PgeRptCount, PgeArchiveCap, PeelCnt, EvalrCount, ZeroEpsilon, CinitMethod, CgrowMethod, SortType);
     345      InitSearch(MaxGen, PgeRptEpoch, PgeRptCount, PgeArchiveCap, PeelCnt, EvalrCount, ZeroEpsilon, cInitMethod, cGrowMethod, SortType);
    355346
    356       Console.WriteLine("InitTree");
    357       initTreeParams(Croots, Cnodes, CnonTrig, Cleafs, UsableVars, NumberOfUseableVariables, MaxSize, MinSize, MaxDepth, MinDepth);
     347      InitTreeParams(cRoots, cNodes, cNonTrig, cLeafs, UsableVars, NumberOfUseableVariables, MaxSize, MinSize, MaxDepth, MinDepth);
    358348
    359       Console.WriteLine("InitProblem");
    360       initProblem(Cname, MaxIter, HitRatio, SearchVar, CproblemTypeString, NumProcs);
     349      InitProblem(cName, MaxIterations, HitRatio, SearchVar, cProblemTypeString, NumProcs);
    361350
    362       Console.WriteLine("Finished Init");
    363351
    364352      var curItersItem = new IntValue();
     
    368356      Marshal.Copy(coeffmem, 0, Coeff, NumberOfUseableVariables);
    369357
    370       for (int iter = 1; iter <= MaxIter; iter++) {
     358      for (int iter = 1; iter <= MaxIterations; iter++) {
    371359        curItersItem.Value = iter;
    372360
    373361        Console.WriteLine("Step " + iter);
    374         stepW();
     362        StepW();
    375363
    376364        for (int iPeel = 0; iPeel < PeelCnt; iPeel++) {
     
    382370          Int64 TestScore = 0;
    383371
    384           IntPtr eqn = getStepResult(out nobestpush, out bestnewminerr, out bestlen1, out bestlen2, out TestScore, out Coeff, out nCoeff);
     372          IntPtr eqn = GetStepResult(out nobestpush, out bestnewminerr, out bestlen1, out bestlen2, out TestScore, out Coeff, out nCoeff);
    385373
    386374          string eqnStr = Marshal.PtrToStringAnsi(eqn);
     
    418406      //Marshal.FreeHGlobal(CproblemTypeString);
    419407      //Marshal.FreeHGlobal(Cname);
    420       Results.Add(new Result("Execution time", new TimeSpanValue(this.ExecutionTime)));
     408      // done anyway?
     409      // Results.Add(new Result("Execution time", new TimeSpanValue(this.ExecutionTime)));
    421410    }
    422411
Note: See TracChangeset for help on using the changeset viewer.