Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14686


Ignore:
Timestamp:
02/17/17 15:54:27 (8 years ago)
Author:
mkommend
Message:

#2205: Updated FeatureSelectionOrchestrator.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.MachineLearning/FeatureSelectionOrchestrator.cs

    r14675 r14686  
    105105      var orchestrationMessage = RegressionOrchestrationPort.PrepareMessage();
    106106      orchestrationMessage["Problem"] = new RegressionProblem() { ProblemData = problemData };
    107       orchestrationMessage["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(OrchestrationMessage.Prepare);
     107      orchestrationMessage["OrchestrationMessage"] = new EnumValue<OrchestrationMessage>(OrchestrationMessage.Prepare | OrchestrationMessage.ClearRuns);
    108108      RegressionOrchestrationPort.SendMessage(orchestrationMessage, token);
    109109
     
    115115
    116116      var regressionSolution = results.Select(r => r.Value).OfType<IRegressionSolution>().First();
     117      double quality = regressionSolution.TestMeanAbsoluteError;
    117118
    118119      UpdatedResults(binaryVector, regressionSolution);
    119 
    120 
    121       double quality = regressionSolution.TestMeanAbsoluteError;
    122120      evaluationMessage["Quality"] = new DoubleValue(quality);
    123121    }
    124122
    125123    private void UpdatedResults(BinaryVector binaryVector, IRegressionSolution solution) {
    126       if (!Results.ContainsKey("Best Solution Vector")) {
    127         Results.Add(new Result("Best Solution Vector", typeof(BinaryVector)));
    128         //Results.Add(new Result("Best Solution Variables", typeof(DoubleArray)));
    129         Results.Add(new Result("Best Symbolic Solution", typeof(IRegressionSolution)));
    130       }
     124      if (!Results.ContainsKey("Best Vector")) Results.Add(new Result("Best Vector", typeof(BinaryVector)));
     125      if (!Results.ContainsKey("Best Solution")) Results.Add(new Result("Best Solution", typeof(IRegressionSolution)));
    131126
    132       var previousBestVector = (BinaryVector)Results["Best Solution Vector"].Value;
     127      var previousBestVector = (BinaryVector)Results["Best Vector"].Value;
     128      var prevoiusBestSolution = (IRegressionSolution)Results["Best Solution"].Value;
    133129
    134       //check if better vector has been found
    135       if (previousBestVector != null && binaryVector.SequenceEqual(previousBestVector))
     130      //check if better vector & solution has been found
     131      if (prevoiusBestSolution != null && prevoiusBestSolution.TestMeanAbsoluteError < solution.TestMeanAbsoluteError)
    136132        return;
    137133
    138       Results["Best Solution Vector"].Value = binaryVector;
    139       Results["Best Symbolic Solution"].Value = solution;
    140 
    141       //var variableNames = solution.ProblemData.AllowedInputVariables;
    142       //alglib.linearmodel lm = BuildModel(best, problemData);
    143 
    144       //double[] coefficients = null;
    145       //int nFeatures = -1;
    146       //alglib.lrunpack(lm, out coefficients, out nFeatures);
    147 
    148       //var doubleArray = new DoubleArray(coefficients.ToArray());
    149       //doubleArray.ElementNames = variableNames;
    150       //Results["Best Solution Variables"].Value = doubleArray;
    151 
    152 
     134      Results["Best Vector"].Value = binaryVector;
     135      Results["Best Solution"].Value = solution;
    153136    }
    154137
     
    156139    //TODO Remove methods
    157140    public override void Pause() { network.Pause(); }
    158     public override void Prepare(bool clearRuns = false) { network.Prepare(clearRuns); }
     141    public override void Prepare(bool clearRuns = false) { network.Prepare(clearRuns); Results.Clear(); }
    159142    public override void Start() { network.Start(); }
    160143    public override void Stop() { network.Stop(); }
Note: See TracChangeset for help on using the changeset viewer.