- Timestamp:
- 04/10/13 13:29:24 (12 years ago)
- Location:
- branches/OaaS
- Files:
-
- 6 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HiveScenarioManager.cs
r9324 r9350 21 21 using System.Data; 22 22 using HeuristicLab.Services.Optimization.ControllerService.General; 23 using HeuristicLab.Services.Optimization.ControllerService.Parameters.HL; 23 24 24 25 namespace HeuristicLab.Services.Optimization.ControllerService { 25 public class ScenarioEntity : TableServiceEntity { 26 26 public class ScenarioEntity : TableServiceEntity { 27 27 public ScenarioEntity() { 28 28 } … … 41 41 42 42 public class HiveScenarioManager : IScenarioManager { 43 private static HLParameterMapper parameterMapper = new HLParameterMapper(); 43 44 private static IScenarioMapper tspMapper; 44 45 private static object lockable; … … 297 298 var value = run.Results[key]; 298 299 Parameter result = MapHiveDataType(key, value); 299 resultValues.Add(result); 300 resultValues.Add(result); 300 301 } 301 302 taskRun.Results = resultValues; 303 IList<Parameter> inputParameters = new List<Model.Parameter>(); 304 foreach (var key in run.Parameters.Keys) { 305 var value = run.Parameters[key]; 306 Parameter param = MapHiveDataType(key, value); 307 inputParameters.Add(param); 308 } 309 // crawl the copied experiment of the job 310 //taskRun.Experiment = dal.JobDao.FindByJobId(id); 311 taskRun.InputParameters = inputParameters; 302 312 runs.Add(taskRun); 303 313 } … … 310 320 311 321 private Parameter MapHiveDataType(string name, IItem item) { 312 Parameter result = new Parameter(); 322 323 if (parameterMapper.IsHandlerAvailable(item)) { 324 return parameterMapper.Map(name, item); 325 } 326 327 var result = new Parameter(); 313 328 result.Type = ParameterType.String; 314 329 //TODO: How shall we handle dll specific datatypes? … … 349 364 matrixValue[i][j] = matrix[j, i]; 350 365 } 351 } 366 } 367 matrixValue = transpose(matrixValue); 352 368 result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.DecimalMatrix() { Name = name, Value = matrixValue, RowNames = (matrix.ColumnNames.Count() > 0 ? matrix.ColumnNames.ToArray() : null) }; 353 369 } … … 408 424 } 409 425 else { 410 result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = "Cannot be displayedas string" };426 result.Value = new HeuristicLab.Services.Optimization.ControllerService.Model.StringValue() { Name = name, Value = item.ItemName != null ? item.ItemName + " (Cannot be displayed properly as string)" : "Cannot be displayed properly as string" }; 411 427 } 412 428 // TODO: Add workaround for TSP -
branches/OaaS/HeuristicLab.Services.Optimization.Controller/HeuristicLab.Services.Optimization.ControllerService.csproj
r9305 r9350 179 179 <Compile Include="Mockup\MockupDAL.cs" /> 180 180 <Compile Include="Mockup\MockupScenarioManager.cs" /> 181 <Compile Include="Parameters\HL\HLParameterHandler.cs" /> 182 <Compile Include="Parameters\HL\PathTSPParameterHandler.cs" /> 183 <Compile Include="Parameters\HL\PermutationTypeHandler.cs" /> 184 <Compile Include="Parameters\ParameterHandler.cs" /> 181 185 <Compile Include="Parsers\AlgorithmConverter.cs" /> 182 186 <Compile Include="PlaceholderControllerService.cs" /> -
branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/DAL.cs
r9324 r9350 39 39 IScenarioDao ScenarioDao { get; } 40 40 IBlobDao BlobDao { get; } 41 IExperimentDao ExperimentDao { get; } 41 IExperimentDao ExperimentDao { get; } 42 42 } 43 43 -
branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/Model/ControllerModel.cs
r9305 r9350 480 480 [DataMember] 481 481 public IList<Parameter> Results { get; set; } 482 483 [DataMember] 484 public IList<Parameter> InputParameters { get; set; } 482 485 } 483 486 -
branches/OaaS/HeuristicLab.Services.Optimization.Controller/Mockup/MockupDAL.cs
r9215 r9350 253 253 } 254 254 } 255 256 255 } 257 256 } -
branches/OaaS/HeuristicLab.Services.Optimization.Controller/Parsers/AlgorithmConverter.cs
r9324 r9350 189 189 jrun["name"] = run.Name; 190 190 jrun["results"] = ConvertParametersToJson(run.Results); 191 jrun["params"] = ConvertParametersToJson(run.InputParameters); 191 192 return jrun; 192 193 } … … 196 197 foreach (var run in runs) 197 198 jarray.Add(ConvertRunToJson(run)); 199 200 201 // if there are multiple different jobs to execute and they have the same id, we must change it here manually 202 var maxId = new Dictionary<string,int>(); 203 for (int i = 0; i < jarray.Count; i++) { 204 for (int j = i + 1; j < jarray.Count; j++) { 205 if (jarray[i]["id"].ToString() == jarray[j]["id"].ToString()) { 206 int max; 207 if (!maxId.TryGetValue(jarray[i]["id"].ToString(), out max)) { 208 max = 1; 209 maxId[jarray[i]["id"].ToString()] = max; 210 } 211 maxId[jarray[i]["id"].ToString()]++; 212 // change j's entry 213 jarray[j]["id"] = jarray[j]["id"].ToString() + " (" + max + ")"; 214 jarray[j]["name"] = jarray[j]["name"] + " (" + max + ")"; 215 } 216 } 217 } 198 218 return jarray; 199 219 } -
branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/experiment.view.js
r9335 r9350 824 824 var datatableSelect = $('.datatableOptions', ele); 825 825 826 var names = _.reduce(this.model.models, function (arr, model) { 827 return _.union(arr, _.map(model.get('results'), function (elem) { return elem.Name })); 828 }, []); 829 826 var names = []; 827 var previouslyFound = { results: {}, params: {} }; 828 _.each(this.model.models, function (model) { 829 _.each(model.get('results'), function (res) { 830 if (!previouslyFound['results'][res.Name]) { 831 previouslyFound['results'][res.Name] = true; 832 names.push({ name: res.Name, source: 'results' }); 833 } 834 }); 835 _.each(model.get('params'), function (res) { 836 if (!previouslyFound['params'][res.Name]) { 837 previouslyFound['params'][res.Name] = true; 838 names.push({ name: res.Name, source: 'params' }); 839 } 840 }); 841 }); 842 previouslyFound = {}; 843 this.options.modelMapping = names; 830 844 this.bubbleSelect = $('select[class="bubbleSize"]', ele); 831 845 832 _.each(names, function ( name) {833 var option = $("<option />", { value: name, text:name });846 _.each(names, function (entry) { 847 var option = $("<option />", { value: entry.name, text: entry.name }); 834 848 option.clone().appendTo(xAxisSelect); 835 849 option.clone().appendTo(yAxisSelect); … … 837 851 var rowNames = null; 838 852 var foundModel = _.find(self.model.models, function (model) { 839 var e ntry = _.find(model.get('results'), function (entry) { return entry.Name == name && entry.RowNames });840 if (e ntry)841 rowNames = e ntry.RowNames;842 return e ntry && entry.RowNames;853 var e = _.find(model.get(entry.source), function (e) { return e.Name == entry.name && e.RowNames }); 854 if (e) 855 rowNames = e.RowNames; 856 return e && e.RowNames; 843 857 }); 844 858 if (rowNames) { 845 self.options.datatables[ name] = rowNames;846 $('<option />', { value: name, text:name }).appendTo(datatableSelect);859 self.options.datatables[entry.name] = rowNames; 860 $('<option />', { value: entry.name, text: entry.name }).appendTo(datatableSelect); 847 861 } 848 862 }); … … 852 866 this.options.xAxis = this.model.models[0].get('results')[0].Name; 853 867 this.options.yAxis = this.options.xAxis; 868 this.options.selectedXIndex = 0; 869 this.options.selectedYIndex = 0; 854 870 this.options.plot = 'Boxplot'; 855 871 $('div[class="bubbleSlider"]', ele).slider({ … … 909 925 xAxisSelected: function (evt) { 910 926 var target = $(evt.target); 927 this.options.selectedXIndex = target.prop("selectedIndex"); 911 928 this.options.xAxis = target.val(); 912 929 this.createPlot(); … … 914 931 yAxisSelected: function (evt) { 915 932 var target = $(evt.target); 933 this.options.selectedYIndex = target.prop("selectedIndex"); 916 934 this.options.yAxis = target.val(); 917 935 this.createPlot(); … … 967 985 createBoxplot: function () { 968 986 var self = this; 969 987 var parameterXSource = this.options.modelMapping[this.options.selectedXIndex].source; // either 'params' or 'results' 988 var parameterYSource = this.options.modelMapping[this.options.selectedYIndex].source; // either 'params' or 'results' 970 989 // prepare data for boxplot 971 990 var values = {}; 972 991 for (var i = 0; i < this.model.models.length; i++) { 973 var xlabel = _.find(this.model.models[i].get( 'results'), function (itm) { return itm.Name == self.options.xAxis });992 var xlabel = _.find(this.model.models[i].get(parameterXSource), function (itm) { return itm.Name == self.options.xAxis }); 974 993 if (!xlabel) 975 994 continue; 976 995 977 996 if ($.isArray(xlabel.Value)) 978 values[ xlabel.Name + ' = ' + xlabel.Value[0]] = [];997 values[parameterXSource + '.' + xlabel.Name + ' = ' + xlabel.Value[0]] = []; 979 998 else 980 values[ xlabel.Name + ' = ' + xlabel.Value] = [];999 values[parameterXSource + '.' + xlabel.Name + ' = ' + xlabel.Value] = []; 981 1000 } 982 1001 983 1002 for (var i = 0; i < this.model.models.length; i++) { 984 var xlabel = _.find(this.model.models[i].get( 'results'), function (itm) { return itm.Name == self.options.xAxis });985 var entry = _.find(this.model.models[i].get( 'results'), function (itm) { return itm.Name == self.options.yAxis });1003 var xlabel = _.find(this.model.models[i].get(parameterXSource), function (itm) { return itm.Name == self.options.xAxis }); 1004 var entry = _.find(this.model.models[i].get(parameterYSource), function (itm) { return itm.Name == self.options.yAxis }); 986 1005 if (!xlabel || !entry || !entry.Value) 987 1006 continue; 988 1007 989 var index = xlabel.Name + ' = ' + ($.isArray(xlabel.Value) ? xlabel.Value[0] : xlabel.Value);1008 var index = parameterXSource + '.' + xlabel.Name + ' = ' + ($.isArray(xlabel.Value) ? xlabel.Value[0] : xlabel.Value); 990 1009 991 1010 if ($.isArray(entry.Value)) … … 1003 1022 createBubblechart: function () { 1004 1023 var self = this; 1005 1024 var parameterXSource = this.options.modelMapping[this.options.selectedXIndex].source; // either 'params' or 'results' 1025 var parameterYSource = this.options.modelMapping[this.options.selectedYIndex].source; // either 'params' or 'results' 1006 1026 // prepare data for bubble chart 1007 1027 var values = []; 1008 1028 var autoscaleBubbles = this.bubbleSelect.val() != 'Constant'; 1009 1029 for (var i = 0; i < this.model.models.length; i++) { 1010 var xValue = _.find(this.model.models[i].get( 'results'), function (itm) { return itm.Name == self.options.xAxis });1011 var yValue = _.find(this.model.models[i].get( 'results'), function (itm) { return itm.Name == self.options.yAxis });1030 var xValue = _.find(this.model.models[i].get(parameterXSource), function (itm) { return itm.Name == self.options.xAxis }); 1031 var yValue = _.find(this.model.models[i].get(parameterYSource), function (itm) { return itm.Name == self.options.yAxis }); 1012 1032 if (!xValue || !yValue) 1013 1033 continue; … … 1019 1039 } else { 1020 1040 var valueProvider = _.find(this.model.models[i].get('results'), function (itm) { return itm.Name == self.bubbleSelect.val(); }); 1021 if (!valueProvider) { 1041 if (!valueProvider) 1042 valueProvider = _.find(this.model.models[i].get('params'), function (itm) { return itm.Name == self.bubbleSelect.val(); }); 1043 1044 if (!valueProvider) { 1022 1045 size = this.options.bubbleSize; 1023 1046 } else { … … 1055 1078 for (var i = 0; i < this.model.models.length; i++) { 1056 1079 var table = _.find(this.model.models[i].get('results'), function (itm) { return itm.Name == self.options.selectedDatatable }); 1080 if (!table) 1081 table = _.find(this.model.models[i].get('params'), function (itm) { return itm.Name == self.options.selectedDatatable }); 1082 1057 1083 if (!table) 1058 1084 continue; -
branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/job.model.js
r9324 r9350 37 37 poll: function () { 38 38 var self = this; 39 this.fetch({ cache: false, update: true, success: function () {39 this.fetch({ cache: false, reset: true, success: function () { 40 40 self._poll(); 41 41 } -
branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/job.view.js
r9335 r9350 16 16 initialize: function () { 17 17 this.collection.bind('remove', this.render, this); 18 //this.collection.bind('a', this.render, this);19 18 }, 20 19 render: function () { … … 89 88 rcv.render(); 90 89 for (var i = 0; i < this.model.models.length; i++) { 90 $('<h3></h3>').text(this.model.models[i].get('name')).appendTo(this.$el); 91 91 var rev = new my.ResultEntryView({ model: this.model.models[i], el: this.$el }); 92 92 rev.render(); … … 150 150 initialize: function () { 151 151 this.plotted = {}; 152 this.plotted['params'] = {}; 153 this.plotted['results'] = {}; 152 154 }, 153 155 render: function () { 154 156 this.template = _.template($('#runTemplate').html()); 155 157 var table = $(this.template(this.model.attributes)); 156 var body = $( "tbody", table);158 var body = $('tbody[class="results"]', table); 157 159 table.appendTo(this.$el); 160 // render the results of the model 158 161 var results = this.model.get('results'); 159 162 for (var i = 0; i < results.length; i++) { 160 var row = $('<tr/>').attr('data-index', i); 161 $('<td/>').text(results[i].Name).appendTo(row); 162 if ($.isArray(results[i].Value)) { 163 var col = $('<td/>').appendTo(row); 164 var tevDiv = $('<div/>'); 165 var plotDiv = $('<div/>').appendTo($('#tmp'));; 166 this.plotted[i] = {}; 167 var tv = new my.TabView({ 168 model: [ 169 { name: 'Table', content: tevDiv }, 170 { name: 'Plot', content: plotDiv }, 171 ], 172 el: col 173 }); 174 this.listenTo(tv, 'tab-activated', this.tabActivated); 175 tv.render(); 176 177 } 178 else { 179 $('<td/>').text(results[i].Value).appendTo(row); 180 } 181 row.appendTo(body); 182 } 163 this.renderModelEntry(results[i], i, body, 'results'); 164 } 165 166 var inputs = this.model.get('params'); 167 body = $('tbody[class="inputs"]', table); 168 for (var i = 0; i < inputs.length; i++) { 169 this.renderModelEntry(inputs[i], i, body, 'params'); 170 } 171 172 var av = new my.AccordionView({el: $(table)}); 173 av.render(); 174 }, 175 renderModelEntry: function(entry, index, body, attribute) { 176 var row = $('<tr/>').attr('data-index', index).attr('data-attribute', attribute); 177 $('<td/>').text(entry.Name).appendTo(row); 178 if ($.isArray(entry.Value)) { 179 var col = $('<td/>').appendTo(row); 180 var tevDiv = $('<div/>'); 181 var plotDiv = $('<div/>').appendTo($('#tmp')); 182 this.plotted[attribute][index] = {}; 183 var tv = new my.TabView({ 184 model: [ 185 { name: 'Table', content: tevDiv }, 186 { name: 'Plot', content: plotDiv }, 187 ], 188 el: col 189 }); 190 this.listenTo(tv, 'tab-activated', this.tabActivated); 191 tv.render(); 192 } 193 else { 194 $('<td/>').text(entry.Value).appendTo(row); 195 } 196 row.appendTo(body); 183 197 }, 184 198 tabActivated: function (evt) { 185 199 var index = parseInt(evt.element.parents('tr').attr('data-index')); 186 if (evt.name == 'Plot' && !this.plotted[index].Plot) { 187 this.plotted[index].Plot = true; 200 var attribute = evt.element.parents('tr').attr('data-attribute'); 201 if (evt.name == 'Plot' && !this.plotted[attribute][index].Plot) { 202 this.plotted[attribute][index].Plot = true; 188 203 var plotDiv = $('<div/>').appendTo($('#tmp')); 189 var pv = new my.PlotView({ model: this.model.get( 'results')[index], el: plotDiv, transpose: true });204 var pv = new my.PlotView({ model: this.model.get(attribute)[index], el: plotDiv, transpose: true }); 190 205 pv.render(); 191 206 plotDiv.appendTo(evt.element); … … 198 213 }); 199 214 rv.render(); 200 } else if (evt.name == 'Table' && !this.plotted[index].Table) { 201 this.plotted[index].Table = true; 202 var tevDiv = $('<div/>'); 203 var tev = new my.TableEditView({ model: this.model.get('results')[index].Value, rowNames: this.model.get('results')[index].RowNames, useDatatable: true, el: tevDiv }); 215 plotDiv.width(rv.$el.width()); 216 plotDiv.height(rv.$el.height()); 217 pv.refresh(); 218 } else if (evt.name == 'Table' && !this.plotted[attribute][index].Table) { 219 this.plotted[attribute][index].Table = true; 220 var tevDiv = $('<div/>').css('overflow', 'scroll'); 221 var tev = new my.TableEditView({ model: this.model.get(attribute)[index].Value, rowNames: this.model.get(attribute)[index].RowNames, useDatatable: true, el: tevDiv }); 204 222 tev.render(); 205 223 tevDiv.appendTo(evt.element) -
branches/OaaS/HeuristicLab.Services.Optimization.Web/Mappings/tsp.xml
r9166 r9350 1 1 <?xml version='1.0'?> 2 2 <scenario xmlns="urn:scenario-schema"> 3 <name> Traveling Salesman Problem</name>3 <name>Genetic Algorithm - TSP</name> 4 4 <algorithm mapper="HeuristicLab.Mappers.TSPScenarioMapper"> 5 5 <parameters> -
branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Job/Index.cshtml
r9335 r9350 59 59 60 60 <script type="text/template" id="runTemplate"> 61 <h3><%= name %></h3> 62 <div> 61 <div class="accordion"> 62 <h3>Results</h3> 63 <div> 63 64 <table> 64 <thead>65 <thead> 65 66 <tr> 66 <td>Key</td>67 <td>Value</td>67 <td>Key</td> 68 <td>Value</td> 68 69 </tr> 69 </thead>70 <tbody>71 </tbody>70 </thead> 71 <tbody class="results"> 72 </tbody> 72 73 </table> 73 </div> 74 </div> 75 <h3>Inputs</h3> 76 <div> 77 <table> 78 <thead> 79 <tr> 80 <td>Key</td> 81 <td>Value</td> 82 </tr> 83 </thead> 84 <tbody class="inputs"> 85 </tbody> 86 </table> 87 </div> 88 </div> 74 89 </script> 75 90
Note: See TracChangeset
for help on using the changeset viewer.