Changeset 16303


Ignore:
Timestamp:
11/16/18 11:55:13 (17 months ago)
Author:
chaider
Message:

#2956: Added intermediate of a-priori knowledge

Location:
branches/2956_apriori_knowledge
Files:
19 added
8 edited

Legend:

Unmodified
Added
Removed
  • branches/2956_apriori_knowledge/HeuristicLab 3.3.sln

    r15682 r16303  
    22Microsoft Visual Studio Solution File, Format Version 12.00
    33# Visual Studio 15
    4 VisualStudioVersion = 15.0.26730.16
     4VisualStudioVersion = 15.0.26403.7
    55MinimumVisualStudioVersion = 10.0.40219.1
    66Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{96396439-A764-4022-A8D2-BE021449B8D1}"
     
    462462EndProject
    463463Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Algorithms.MOCMAEvolutionStrategy-3.3", "HeuristicLab.Algorithms.MOCMAEvolutionStrategy\3.3\HeuristicLab.Algorithms.MOCMAEvolutionStrategy-3.3.csproj", "{0E2E224F-E9B2-41F3-B510-09183EEBA2AF}"
     464EndProject
     465Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Algorithms.DataAnalysis.KnowledgeIntegration", "HeuristicLab.Algorithms.DataAnalysis.KnowledgeIntegration\3.4\HeuristicLab.Algorithms.DataAnalysis.KnowledgeIntegration-3.4.csproj", "{5E8B5347-4281-4D89-92E5-8D81E297BBCA}"
    464466EndProject
    465467Global
     
    22492251    {0E2E224F-E9B2-41F3-B510-09183EEBA2AF}.Release|x86.ActiveCfg = Release|x86
    22502252    {0E2E224F-E9B2-41F3-B510-09183EEBA2AF}.Release|x86.Build.0 = Release|x86
     2253    {5E8B5347-4281-4D89-92E5-8D81E297BBCA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     2254    {5E8B5347-4281-4D89-92E5-8D81E297BBCA}.Debug|Any CPU.Build.0 = Debug|Any CPU
     2255    {5E8B5347-4281-4D89-92E5-8D81E297BBCA}.Debug|x64.ActiveCfg = Debug|Any CPU
     2256    {5E8B5347-4281-4D89-92E5-8D81E297BBCA}.Debug|x64.Build.0 = Debug|Any CPU
     2257    {5E8B5347-4281-4D89-92E5-8D81E297BBCA}.Debug|x86.ActiveCfg = Debug|Any CPU
     2258    {5E8B5347-4281-4D89-92E5-8D81E297BBCA}.Debug|x86.Build.0 = Debug|Any CPU
     2259    {5E8B5347-4281-4D89-92E5-8D81E297BBCA}.Release|Any CPU.ActiveCfg = Release|Any CPU
     2260    {5E8B5347-4281-4D89-92E5-8D81E297BBCA}.Release|Any CPU.Build.0 = Release|Any CPU
     2261    {5E8B5347-4281-4D89-92E5-8D81E297BBCA}.Release|x64.ActiveCfg = Release|Any CPU
     2262    {5E8B5347-4281-4D89-92E5-8D81E297BBCA}.Release|x64.Build.0 = Release|Any CPU
     2263    {5E8B5347-4281-4D89-92E5-8D81E297BBCA}.Release|x86.ActiveCfg = Release|Any CPU
     2264    {5E8B5347-4281-4D89-92E5-8D81E297BBCA}.Release|x86.Build.0 = Release|Any CPU
    22512265  EndGlobalSection
    22522266  GlobalSection(SolutionProperties) = preSolution
  • branches/2956_apriori_knowledge/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/HeuristicLab.Algorithms.DataAnalysis.Views-3.4.csproj

    r15124 r16303  
    353353</PreBuildEvent>
    354354  </PropertyGroup>
     355  <PropertyGroup>
     356    <PreBuildEvent>set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
     357set ProjectDir=$(ProjectDir)
     358set SolutionDir=$(SolutionDir)
     359set Outdir=$(Outdir)
     360
     361call PreBuildEvent.cmd
     362</PreBuildEvent>
     363  </PropertyGroup>
    355364  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
    356365       Other similar extension points exist, see Microsoft.Common.targets.
  • branches/2956_apriori_knowledge/HeuristicLab.Data.Views/3.3/HeuristicLab.Data.Views-3.3.csproj

    r15009 r16303  
    177177      <DependentUpon>StringConvertibleMatrixRowVisibilityDialog.cs</DependentUpon>
    178178    </Compile>
     179    <Compile Include="StringIntervalView.cs">
     180      <SubType>UserControl</SubType>
     181    </Compile>
     182    <Compile Include="StringIntervalView.Designer.cs">
     183      <DependentUpon>StringIntervalView.cs</DependentUpon>
     184    </Compile>
    179185    <Compile Include="StringConvertibleValueTupleView.cs">
    180186      <SubType>UserControl</SubType>
     
    272278      <Name>HeuristicLab.PluginInfrastructure-3.3</Name>
    273279      <Private>False</Private>
     280    </ProjectReference>
     281    <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis\3.4\HeuristicLab.Problems.DataAnalysis-3.4.csproj">
     282      <Project>{DF87C13E-A889-46FF-8153-66DCAA8C5674}</Project>
     283      <Name>HeuristicLab.Problems.DataAnalysis-3.4</Name>
    274284    </ProjectReference>
    275285  </ItemGroup>
     
    290300      <Install>true</Install>
    291301    </BootstrapperPackage>
     302  </ItemGroup>
     303  <ItemGroup>
     304    <EmbeddedResource Include="StringIntervalView.resx">
     305      <DependentUpon>StringIntervalView.cs</DependentUpon>
     306    </EmbeddedResource>
    292307  </ItemGroup>
    293308  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • branches/2956_apriori_knowledge/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj

    r14255 r16303  
    206206  </ItemGroup>
    207207  <ItemGroup>
     208    <ProjectReference Include="..\..\HeuristicLab.Algorithms.DataAnalysis.KnowledgeIntegration\3.4\HeuristicLab.Algorithms.DataAnalysis.KnowledgeIntegration-3.4.csproj">
     209      <Project>{5e8b5347-4281-4d89-92e5-8d81e297bbca}</Project>
     210      <Name>HeuristicLab.Algorithms.DataAnalysis.KnowledgeIntegration-3.4</Name>
     211    </ProjectReference>
    208212    <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
    209213      <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
  • branches/2956_apriori_knowledge/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs

    r15583 r16303  
    2626using System.Threading.Tasks;
    2727using System.Windows.Forms;
     28using HeuristicLab.Algorithms.DataAnalysis.KnowledgeIntegration.Interpreter;
     29using HeuristicLab.Algorithms.DataAnalysis.KnowledgeIntegration.IntervalArithmetic;
     30using HeuristicLab.Algorithms.DataAnalysis.KnowledgeIntegration.Util;
    2831using HeuristicLab.Common;
    2932using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    3639    private Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> foldedNodes;
    3740    private Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> changedNodes;
     41    //private Dictionary<ISymbolicExpressionTreeNode, Interval> intervals;
     42    private Dictionary<ISymbolicExpressionTreeNode, Interval> intervals;
    3843    private Dictionary<ISymbolicExpressionTreeNode, double> nodeImpacts;
    3944
     
    5055      changedNodes = new Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>();
    5156      nodeImpacts = new Dictionary<ISymbolicExpressionTreeNode, double>();
     57      //intervals = new Dictionary<ISymbolicExpressionTreeNode, Interval>();
    5258      this.Caption = "Interactive Solution Simplifier";
    5359      this.impactCalculator = impactCalculator;
     
    185191      progress.Start("Calculate Impact and Replacement Values ...");
    186192      var impactAndReplacementValues = await Task.Run(() => CalculateImpactAndReplacementValues(tree));
     193      var interpreter = new SymbolicDataAnalysisIntervalArithmeticInterpreter();
     194
     195      //var intervalParam = ((IRegressionProblemData)Content.ProblemData).IntervalVariable;
     196      var customIntervals = new Dictionary<String, Interval>();
     197      var parser = new FormulationParser();
     198      //foreach (var ci in intervalParam) {
     199      //var inter = parser.Parse(ci.Formulation.GetValue());
     200      //customIntervals.Add(ci.Variable.GetValue(), new Interval(0, 1));
     201      //}
     202      var resultInterval = interpreter.GetSymbolicExressionTreeIntervals(tree, Content.ProblemData.Dataset, Content.ProblemData.TrainingIndices, out intervals);
    187203      await Task.Delay(500); // wait for progressbar to finish animation
    188204      var replacementValues = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item2);
     
    190206        foldedNodes[pair.Key] = MakeConstantTreeNode(pair.Value);
    191207      }
     208      //Instruction currentInstr = instructions.NextInstruction();
     209      //while (instructions.HasNextInstruction()) {
     210      //  //intervals[currentInstr.dynamicNode] = (Interval)currentInstr.data;
     211      //  intervals.Add(Tuple.Create(currentInstr.dynamicNode, (Interval)currentInstr.data));
     212      //  currentInstr = instructions.NextInstruction();
     213      //}
     214     
     215     
     216
     217      //intervals.Add(Tuple.Create(currentInstr.dynamicNode, (Interval)currentInstr.data));
    192218      nodeImpacts = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item1);
    193219      progress.Finish();
    194       PaintNodeImpacts();
     220      PaintIntervals();
     221      //PaintNodeImpacts();
    195222    }
    196223
     
    253280    }
    254281
     282    private void PaintIntervals() {
     283      int node = 0;
     284      var impacts = nodeImpacts.Values;
     285      double max = impacts.Max();
     286      double min = impacts.Min();
     287
     288      foreach (ISymbolicExpressionTreeNode treeNode in Content.Model.SymbolicExpressionTree.IterateNodesPrefix()) {
     289        VisualTreeNode<ISymbolicExpressionTreeNode> visualTree = treeChart.GetVisualSymbolicExpressionTreeNode(treeNode);
     290
     291        if (visualTree != null) {
     292          visualTree.ToolTip = visualTree.Content.ToString();
     293          //visualTree.ToolTip += String.Format($"{Environment.NewLine}Intervals: [{intervals[node].Item2.LowerBound:E4} ... {intervals[node].Item2.UpperBound:E4}]{Environment.NewLine}");
     294          visualTree.ToolTip += String.Format($"{Environment.NewLine}Intervals: [{intervals[treeNode].LowerBound:E4} ... {intervals[treeNode].UpperBound:E4}]{Environment.NewLine}]");
     295          node++;
     296         
     297          if (!(treeNode is ConstantTreeNode) && nodeImpacts.ContainsKey(treeNode)) {
     298            double impact = nodeImpacts[treeNode];
     299
     300            // impact = 0 if no change
     301            // impact < 0 if new solution is better
     302            // impact > 0 if new solution is worse
     303            if (impact < 0.0) {
     304              visualTree.FillColor = Color.FromArgb((int)(impact / min * 255), Color.Red);
     305            } else if (impact.IsAlmost(0.0)) {
     306              visualTree.FillColor = Color.White;
     307            } else {
     308              // max is guaranteed to be > 0
     309              visualTree.FillColor = Color.FromArgb((int)(impact / max * 255), Color.Green);
     310            }
     311            visualTree.ToolTip += String.Format($"{Environment.NewLine} Node impact: {impact:E4}");
     312            var constantReplacementNode = foldedNodes[treeNode] as ConstantTreeNode;
     313            if (constantReplacementNode != null) {
     314              visualTree.ToolTip += String.Format($"{Environment.NewLine} Replacement value: {constantReplacementNode.Value:E4}");
     315            }
     316          }
     317          if (changedNodes.ContainsKey(treeNode)) {
     318            visualTree.LineColor = Color.DodgerBlue;
     319          } else if (treeNode is ConstantTreeNode && foldedNodes.ContainsKey(treeNode)) {
     320            visualTree.LineColor = Color.DarkOrange;
     321          }
     322        }
     323      }
     324      treeChart.RepaintNodes();
     325    }
     326
    255327    private void PaintNodeImpacts() {
    256328      var impacts = nodeImpacts.Values;
  • branches/2956_apriori_knowledge/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj

    r15638 r16303  
    176176    <Compile Include="Interfaces\IDataset.cs" />
    177177    <Compile Include="Interfaces\IDependencyCalculator.cs" />
     178    <Compile Include="Interfaces\IInterval.cs" />
    178179    <Compile Include="Interfaces\ITransformation.cs" />
    179180    <Compile Include="Interfaces\ITransformationMapper.cs" />
     
    190191    <Compile Include="Interfaces\TimeSeriesPrognosis\ITimeSeriesPrognosisProblemData.cs" />
    191192    <Compile Include="Interfaces\TimeSeriesPrognosis\ITimeSeriesPrognosisSolution.cs" />
     193    <Compile Include="IntervalItem.cs" />
    192194    <Compile Include="ModifiableDataset.cs" />
    193195    <Compile Include="OnlineCalculators\AutoCorrelationCalculator.cs" />
  • branches/2956_apriori_knowledge/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs

    r16244 r16303  
    3434  public class RegressionProblemData : DataAnalysisProblemData, IRegressionProblemData, IStorableContent {
    3535    protected const string TargetVariableParameterName = "TargetVariable";
     36    protected const string VariableRangeParameterName = "VariableRanges";
    3637    public string Filename { get; set; }
    3738
     
    9192      problemData.Parameters.Add(new FixedValueParameter<IntRange>(TestPartitionParameterName, "", (IntRange)new IntRange(0, 0).AsReadOnly()));
    9293      problemData.Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>()));
     94      problemData.Parameters.Add(new OptionalValueParameter<DoubleMatrix>(VariableRangeParameterName, ""));
    9395      emptyProblemData = problemData;
    9496    }
    9597    #endregion
     98
     99    public OptionalValueParameter<DoubleMatrix> VariableRangeParameter {
     100      get { return (OptionalValueParameter<DoubleMatrix>)Parameters[VariableRangeParameterName]; }
     101    }
    96102
    97103    public IConstrainedValueParameter<StringValue> TargetVariableParameter {
     
    120126    }
    121127
     128    public DoubleMatrix VariableRanges {
     129      get { return VariableRangeParameter.Value; }
     130    }
    122131
    123132    [StorableConstructor]
     
    152161      var variables = InputVariables.Select(x => x.AsReadOnly()).ToList();
    153162      Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>(variables), variables.Where(x => x.Value == targetVariable).First()));
     163
     164      DoubleMatrix variableRanges = new DoubleMatrix(variables.Count, 2, new string[] { "Lower Bound", "Upper Bound" }, variables.Select(x => x.Value));
     165      Parameters.Add(new FixedValueParameter<DoubleMatrix>(VariableRangeParameterName, variableRanges));
     166
     167      int row = 0;
     168      foreach (var variable in variables) {
     169        IList<double> values = new List<double>();
     170        foreach (var value in dataset.GetReadOnlyDoubleValues(variable.Value)) {
     171          values.Add(value);
     172        }
     173        variableRanges[row, 0] = values.Min();
     174        variableRanges[row, 1] = values.Max();
     175        ++row;
     176      }
     177
    154178      RegisterParameterEvents();
    155179    }
  • branches/2956_apriori_knowledge/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionProblemData.cs

    r15583 r16303  
    2121
    2222using System.Collections.Generic;
     23using HeuristicLab.Core;
     24using HeuristicLab.Data;
    2325
    2426namespace HeuristicLab.Problems.DataAnalysis {
    2527  public interface IRegressionProblemData : IDataAnalysisProblemData {
    2628    string TargetVariable { get; set; }
     29    DoubleMatrix VariableRanges { get; }
    2730
    2831    IEnumerable<double> TargetVariableValues { get; }
Note: See TracChangeset for help on using the changeset viewer.