- Timestamp:
- 08/08/09 10:15:33 (15 years ago)
- Location:
- trunk/tools
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/tools/CedmaImporter/CedmaImporter.csproj ¶
r2259 r2260 31 31 <WarningLevel>4</WarningLevel> 32 32 </PropertyGroup> 33 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> 34 <DebugSymbols>true</DebugSymbols> 35 <OutputPath>bin\x86\Debug\</OutputPath> 36 <DefineConstants>DEBUG;TRACE</DefineConstants> 37 <DebugType>full</DebugType> 38 <PlatformTarget>x86</PlatformTarget> 39 <ErrorReport>prompt</ErrorReport> 40 </PropertyGroup> 41 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> 42 <OutputPath>bin\x86\Release\</OutputPath> 43 <DefineConstants>TRACE</DefineConstants> 44 <Optimize>true</Optimize> 45 <DebugType>pdbonly</DebugType> 46 <PlatformTarget>x86</PlatformTarget> 47 <ErrorReport>prompt</ErrorReport> 48 </PropertyGroup> 33 49 <ItemGroup> 34 <Reference Include="HeuristicLab.CEDMA.Server-3.3, Version=3.3.0.22 38, Culture=neutral, processorArchitecture=x86">50 <Reference Include="HeuristicLab.CEDMA.Server-3.3, Version=3.3.0.2258, Culture=neutral, processorArchitecture=x86"> 35 51 <SpecificVersion>False</SpecificVersion> 36 52 <HintPath>..\..\sources\HeuristicLab\bin\x86\Release\plugins\HeuristicLab.CEDMA.Server-3.3.dll</HintPath> … … 75 91 <SpecificVersion>False</SpecificVersion> 76 92 <HintPath>..\..\sources\HeuristicLab\bin\x86\Release\plugins\HeuristicLab.SupportVectorMachines-3.2.dll</HintPath> 93 </Reference> 94 <Reference Include="LibSVM, Version=2.84.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=x86"> 95 <SpecificVersion>False</SpecificVersion> 96 <HintPath>..\..\sources\HeuristicLab\bin\x86\Release\plugins\LibSVM.dll</HintPath> 77 97 </Reference> 78 98 <Reference Include="System" /> -
TabularUnified trunk/tools/CedmaImporter/Importer.cs ¶
r2259 r2260 6 6 using HeuristicLab.Modeling.Database; 7 7 using HeuristicLab.Modeling.Database.SQLServerCompact; 8 using HeuristicLab.GP; 9 using HeuristicLab.GP.Interfaces; 10 using HeuristicLab.GP.StructureIdentification; 11 using System.Diagnostics; 8 12 9 13 namespace CedmaImporter { … … 33 37 using (StreamReader reader = File.OpenText(fileName)) { 34 38 ReadResultsAndInputVariables(reader); 35 ImportAllModels( reader, database);39 ImportAllModels(dirName, reader, database); 36 40 } 37 41 } … … 56 60 } 57 61 58 private void ImportAllModels( StreamReader reader, DatabaseService database) {62 private void ImportAllModels(string dirName, StreamReader reader, DatabaseService database) { 59 63 while (!reader.EndOfStream) { 60 64 string modelLine = reader.ReadLine(); 61 65 string[] modelData = modelLine.Split(';'); 62 66 int id = int.Parse(modelData[ID_COLUMN]); 63 string fileName = modelData[FILENAME_COLUMN];64 string targetVariableName = modelData[TARGETVARIABLE_COLUMN];65 string algoName = modelData[ALGORITHM_COLUMN];66 Variable targetVariable = newVariable(targetVariableName);67 string targetVariableName = modelData[TARGETVARIABLE_COLUMN].Trim(); 68 string algoName = modelData[ALGORITHM_COLUMN].Trim(); 69 HeuristicLab.Core.IItem modelItem = ParseModel(dirName, modelData[FILENAME_COLUMN].Trim(), algoName); 70 HeuristicLab.Modeling.Database.SQLServerCompact.Variable targetVariable = new HeuristicLab.Modeling.Database.SQLServerCompact.Variable(targetVariableName); 67 71 Algorithm algorithm = new Algorithm(algoName); 68 72 Model model = new Model(targetVariable, algorithm); … … 83 87 //foreach (InputVariableResult inputVariableResult in inputVariableResults) 84 88 // database.Persist(inputVariableResult); 85 89 86 90 } 87 91 } … … 91 95 return from i in Enumerable.Range(0, inputVariables.Count()) 92 96 where inputVariables[i] != null && results[i] != null && double.TryParse(modelData[i], out temp) 93 select new InputVariableResult(new InputVariable(model, new Variable(inputVariables[i])), results[i], double.Parse(modelData[i]));97 select new InputVariableResult(new InputVariable(model, new HeuristicLab.Modeling.Database.SQLServerCompact.Variable(inputVariables[i])), results[i], double.Parse(modelData[i])); 94 98 } 95 99 … … 99 103 select new ModelResult(model, results[i], double.Parse(modelData[i])); 100 104 } 105 106 Dictionary<string, IFunction> knownFunctions = new Dictionary<string, IFunction>() { 107 {"+", new Addition()}, 108 {"and", new And()}, 109 {"mean", new Average()}, 110 {"cos", new Cosinus()}, 111 {"/", new Division()}, 112 {"equ", new Equal()}, 113 {"exp", new Exponential()}, 114 {">", new GreaterThan()}, 115 {"if", new IfThenElse()}, 116 {"<", new LessThan()}, 117 {"log", new Logarithm()}, 118 {"*", new Multiplication()}, 119 {"not", new Not()}, 120 {"or", new Or()}, 121 {"expt", new Power()}, 122 {"sign", new Signum()}, 123 {"sin",new Sinus()}, 124 {"sqrt", new Sqrt()}, 125 {"-", new Subtraction()}, 126 {"tan", new Tangens()}, 127 {"xor", new Xor()} 128 }; 129 Constant constant = new Constant(); 130 HeuristicLab.GP.StructureIdentification.Variable variable = new HeuristicLab.GP.StructureIdentification.Variable(); 131 Differential differential = new Differential(); 132 133 private HeuristicLab.Core.IItem ParseModel(string dirName, string modelFileName, string algoName) { 134 if (algoName == "SupportVectorRegression") { 135 HeuristicLab.Data.SVMModel model = new HeuristicLab.Data.SVMModel(); 136 model.Model = SVM.Model.Read(Path.Combine(dirName, modelFileName) + ".svm.model.txt"); 137 model.RangeTransform = SVM.RangeTransform.Read(Path.Combine(dirName, modelFileName) + ".svm.transform.txt"); 138 return model; 139 } else { 140 GeneticProgrammingModel model = new GeneticProgrammingModel(); 141 IEnumerable<Token> tokens = GetTokenStream(File.OpenText(Path.Combine(dirName, modelFileName) + ".gp.txt")); 142 model.FunctionTree = ParseSexp(new Queue<Token>(tokens)); 143 return model; 144 } 145 } 146 147 private IEnumerable<Token> GetTokenStream(StreamReader reader) { 148 return from line in GetLineStream(reader) 149 let strTokens = line.Split(new string[] { " ", "\t", Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).AsEnumerable() 150 from strToken in strTokens 151 let t = Token.Parse(strToken) 152 where t != null 153 select t; 154 } 155 156 private IEnumerable<string> GetLineStream(StreamReader reader) { 157 while (!reader.EndOfStream) yield return reader.ReadLine().Replace("(", " ( ").Replace(")", " ) "); 158 yield break; 159 } 160 161 private HeuristicLab.GP.Interfaces.IFunctionTree ParseSexp(Queue<Token> tokens) { 162 Expect(Token.LPAR, tokens); 163 164 if (tokens.Peek().Symbol == TokenSymbol.SYMB) { 165 if (tokens.Peek().StringValue.Equals("variable")) { 166 return ParseVariable(tokens); 167 } else if (tokens.Peek().StringValue.Equals("differential")) { 168 return ParseDifferential(tokens); 169 } else { 170 Token curToken = tokens.Dequeue(); 171 IFunctionTree tree = CreateTree(curToken); 172 while (!tokens.Peek().Equals(Token.RPAR)) { 173 tree.AddSubTree(ParseSexp(tokens)); 174 } 175 Expect(Token.RPAR, tokens); 176 return tree; 177 } 178 } else if (tokens.Peek().Symbol == TokenSymbol.NUMBER) { 179 ConstantFunctionTree t = (ConstantFunctionTree)constant.GetTreeNode(); 180 t.Value = tokens.Dequeue().DoubleValue; 181 return t; 182 } else { 183 throw new FormatException("Expected function or constant symbol"); 184 } 185 } 186 187 private IFunctionTree ParseDifferential(Queue<Token> tokens) { 188 Debug.Assert(tokens.Dequeue().StringValue == "differential"); 189 VariableFunctionTree t = (VariableFunctionTree)differential.GetTreeNode(); 190 t.Weight = tokens.Dequeue().DoubleValue; 191 t.VariableName = tokens.Dequeue().StringValue; 192 t.SampleOffset = (int)tokens.Dequeue().DoubleValue; 193 Expect(Token.RPAR, tokens); 194 return t; 195 } 196 197 private IFunctionTree ParseVariable(Queue<Token> tokens) { 198 Debug.Assert(tokens.Dequeue().StringValue == "variable"); 199 VariableFunctionTree t = (VariableFunctionTree)variable.GetTreeNode(); 200 t.Weight = tokens.Dequeue().DoubleValue; 201 t.VariableName = tokens.Dequeue().StringValue; 202 t.SampleOffset = (int)tokens.Dequeue().DoubleValue; 203 Expect(Token.RPAR, tokens); 204 return t; 205 } 206 207 private IFunctionTree CreateTree(Token token) { 208 if (token.Symbol != TokenSymbol.SYMB) throw new FormatException("Expected function symbol, but got: " + token.StringValue); 209 return knownFunctions[token.StringValue].GetTreeNode(); 210 } 211 212 private void Expect(Token token, Queue<Token> tokens) { 213 Token cur = tokens.Dequeue(); 214 if (!token.Equals(cur)) throw new FormatException("Expected: " + token.StringValue + ", but got found: " + cur.StringValue); 215 } 216 217 private enum TokenSymbol { LPAR, RPAR, SYMB, NUMBER }; 218 private class Token { 219 public static readonly Token LPAR = Token.Parse("("); 220 public static readonly Token RPAR = Token.Parse(")"); 221 222 public TokenSymbol Symbol { get; set; } 223 public string StringValue { get; set; } 224 public double DoubleValue { get; set; } 225 public Token() { } 226 227 public override bool Equals(object obj) { 228 Token other = (obj as Token); 229 if (other == null) return false; 230 if (other.Symbol != Symbol) return false; 231 return other.StringValue == this.StringValue; 232 } 233 234 public static Token Parse(string strToken) { 235 strToken = strToken.Trim(); 236 Token t = new Token(); 237 t.StringValue = strToken.Trim(); 238 double temp; 239 if (strToken == "") { 240 t = null; 241 } else if (strToken == "(") { 242 t.Symbol = TokenSymbol.LPAR; 243 } else if (strToken == ")") { 244 t.Symbol = TokenSymbol.RPAR; 245 } else if (double.TryParse(strToken, out temp)) { 246 t.Symbol = TokenSymbol.NUMBER; 247 t.DoubleValue = double.Parse(strToken); 248 } else { 249 t.Symbol = TokenSymbol.SYMB; 250 } 251 return t; 252 } 253 } 101 254 } 102 255 } -
TabularUnified trunk/tools/ConfigMerger/ConfigMerger.csproj ¶
r858 r2260 34 34 <WarningLevel>4</WarningLevel> 35 35 <DocumentationFile>bin\Release\ConfigMerger.XML</DocumentationFile> 36 </PropertyGroup> 37 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> 38 <DebugSymbols>true</DebugSymbols> 39 <OutputPath>bin\x86\Debug\</OutputPath> 40 <DefineConstants>DEBUG;TRACE</DefineConstants> 41 <DebugType>full</DebugType> 42 <PlatformTarget>x86</PlatformTarget> 43 <ErrorReport>prompt</ErrorReport> 44 </PropertyGroup> 45 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> 46 <OutputPath>bin\x86\Release\</OutputPath> 47 <DefineConstants>TRACE</DefineConstants> 48 <DocumentationFile>bin\Release\ConfigMerger.XML</DocumentationFile> 49 <Optimize>true</Optimize> 50 <DebugType>pdbonly</DebugType> 51 <PlatformTarget>x86</PlatformTarget> 52 <ErrorReport>prompt</ErrorReport> 36 53 </PropertyGroup> 37 54 <ItemGroup> -
TabularUnified trunk/tools/Tools.sln ¶
r2259 r2260 17 17 GlobalSection(SolutionConfigurationPlatforms) = preSolution 18 18 Debug|Any CPU = Debug|Any CPU 19 Debug|x86 = Debug|x86 19 20 Release|Any CPU = Release|Any CPU 21 Release|x86 = Release|x86 20 22 EndGlobalSection 21 23 GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 24 {E94C5E71-3F29-408D-BCDF-23E096CA84CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 25 {E94C5E71-3F29-408D-BCDF-23E096CA84CA}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 {E94C5E71-3F29-408D-BCDF-23E096CA84CA}.Debug|x86.ActiveCfg = Debug|x86 27 {E94C5E71-3F29-408D-BCDF-23E096CA84CA}.Debug|x86.Build.0 = Debug|x86 24 28 {E94C5E71-3F29-408D-BCDF-23E096CA84CA}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 29 {E94C5E71-3F29-408D-BCDF-23E096CA84CA}.Release|Any CPU.Build.0 = Release|Any CPU 30 {E94C5E71-3F29-408D-BCDF-23E096CA84CA}.Release|x86.ActiveCfg = Release|Any CPU 31 {E94C5E71-3F29-408D-BCDF-23E096CA84CA}.Release|x86.Build.0 = Release|Any CPU 26 32 {1E4B971A-83BA-4C39-BE19-D09B13CF7242}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 33 {1E4B971A-83BA-4C39-BE19-D09B13CF7242}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 {1E4B971A-83BA-4C39-BE19-D09B13CF7242}.Debug|x86.ActiveCfg = Debug|x86 35 {1E4B971A-83BA-4C39-BE19-D09B13CF7242}.Debug|x86.Build.0 = Debug|x86 28 36 {1E4B971A-83BA-4C39-BE19-D09B13CF7242}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 37 {1E4B971A-83BA-4C39-BE19-D09B13CF7242}.Release|Any CPU.Build.0 = Release|Any CPU 38 {1E4B971A-83BA-4C39-BE19-D09B13CF7242}.Release|x86.ActiveCfg = Release|Any CPU 39 {1E4B971A-83BA-4C39-BE19-D09B13CF7242}.Release|x86.Build.0 = Release|Any CPU 30 40 {F4818BCF-A57F-413C-8DEE-C0532C7F7C7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 41 {F4818BCF-A57F-413C-8DEE-C0532C7F7C7F}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 {F4818BCF-A57F-413C-8DEE-C0532C7F7C7F}.Debug|x86.ActiveCfg = Debug|x86 43 {F4818BCF-A57F-413C-8DEE-C0532C7F7C7F}.Debug|x86.Build.0 = Debug|x86 32 44 {F4818BCF-A57F-413C-8DEE-C0532C7F7C7F}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 45 {F4818BCF-A57F-413C-8DEE-C0532C7F7C7F}.Release|Any CPU.Build.0 = Release|Any CPU 46 {F4818BCF-A57F-413C-8DEE-C0532C7F7C7F}.Release|x86.ActiveCfg = Release|Any CPU 47 {F4818BCF-A57F-413C-8DEE-C0532C7F7C7F}.Release|x86.Build.0 = Release|Any CPU 34 48 EndGlobalSection 35 49 GlobalSection(SolutionProperties) = preSolution -
TabularUnified trunk/tools/Wizards/Wizards.csproj ¶
r1546 r2260 32 32 <ErrorReport>prompt</ErrorReport> 33 33 <WarningLevel>4</WarningLevel> 34 </PropertyGroup> 35 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> 36 <DebugSymbols>true</DebugSymbols> 37 <OutputPath>bin\x86\Debug\</OutputPath> 38 <DefineConstants>DEBUG;TRACE</DefineConstants> 39 <DebugType>full</DebugType> 40 <PlatformTarget>x86</PlatformTarget> 41 <ErrorReport>prompt</ErrorReport> 42 </PropertyGroup> 43 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> 44 <OutputPath>bin\x86\Release\</OutputPath> 45 <DefineConstants>TRACE</DefineConstants> 46 <Optimize>true</Optimize> 47 <DebugType>pdbonly</DebugType> 48 <PlatformTarget>x86</PlatformTarget> 49 <ErrorReport>prompt</ErrorReport> 34 50 </PropertyGroup> 35 51 <ItemGroup>
Note: See TracChangeset
for help on using the changeset viewer.