Changeset 5073 for branches/OKB/HeuristicLab.Clients.OKB-3.3/OKBClient.cs
- Timestamp:
- 12/09/10 02:27:03 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OKB/HeuristicLab.Clients.OKB-3.3/OKBClient.cs
r5071 r5073 361 361 362 362 #region Experiment Methods 363 public Experiment GetExperiment(long id) { 364 try { 365 return CallAdminService<Experiment>(s => s.GetExperiment(id)); 366 } 367 catch (Exception ex) { 368 ErrorHandling.ShowErrorDialog("Refresh experiment failed.", ex); 369 return null; 370 } 371 } 363 372 public ItemCollection<Experiment> GetExperiments(long algorithmId, long problemId) { 364 373 try { … … 381 390 runs.AddRange(CallAdminService<Run[]>(s => s.GetRuns(experimentId)).OrderByDescending(x => x.FinishedDate)); 382 391 runs.ItemsRemoved += new CollectionItemsChangedEventHandler<Run>(runs_ItemsRemoved); 392 return runs; 393 } 394 catch (Exception ex) { 395 ErrorHandling.ShowErrorDialog("Refresh runs failed.", ex); 396 return null; 397 } 398 } 399 public ItemCollection<Run> QueryRuns(string query) { 400 try { 401 ItemCollection<Run> runs = new ItemCollection<Run>(); 402 runs.AddRange(CallAdminService<Run[]>(s => s.QueryRuns(query)).OrderByDescending(x => x.FinishedDate)); 383 403 return runs; 384 404 } … … 593 613 } 594 614 } 615 public RunCollection ConvertOKBRunsToOptimizationRuns(IItemCollection<Run> runs) { 616 RunCollection runCollection = new RunCollection(); 617 foreach (Run run in runs) { 618 Optimization.Run r = new Optimization.Run(); 619 foreach (ResultValue resultValue in run.ResultValues) { 620 Result result = GetResult(resultValue.ResultId); 621 if (resultValue is ResultBlobValue) { 622 IItem item = null; 623 using (MemoryStream stream = new MemoryStream(((ResultBlobValue)resultValue).Value)) { 624 try { 625 item = XmlParser.Deserialize<IItem>(stream); 626 } 627 catch (Exception ex) { 628 ErrorHandling.ShowErrorDialog(ex); 629 } 630 stream.Close(); 631 } 632 r.Results.Add(result.Name, item); 633 } else if (resultValue is ResultBoolValue) { 634 r.Results.Add(result.Name, new BoolValue(((ResultBoolValue)resultValue).Value)); 635 } else if (resultValue is ResultFloatValue) { 636 r.Results.Add(result.Name, new DoubleValue(((ResultFloatValue)resultValue).Value)); 637 } else if (resultValue is ResultIntValue) { 638 r.Results.Add(result.Name, new IntValue((int)((ResultIntValue)resultValue).Value)); 639 } else if (resultValue is ResultStringValue) { 640 r.Results.Add(result.Name, new StringValue(((ResultStringValue)resultValue).Value)); 641 } 642 } 643 644 Experiment exp = GetExperiment(run.ExperimentId); 645 foreach (AlgorithmParameterValue algorithmParameterValue in exp.AlgorithmParameterValues) { 646 AlgorithmParameter algorithmParameter = GetAlgorithmParameter(algorithmParameterValue.AlgorithmParameterId); 647 if (algorithmParameterValue is AlgorithmParameterBlobValue) { 648 IItem item = null; 649 using (MemoryStream stream = new MemoryStream(((AlgorithmParameterBlobValue)algorithmParameterValue).Value)) { 650 try { 651 item = XmlParser.Deserialize<IItem>(stream); 652 } 653 catch (Exception ex) { 654 ErrorHandling.ShowErrorDialog(ex); 655 } 656 stream.Close(); 657 } 658 r.Parameters.Add(algorithmParameter.Name, item); 659 } else if (algorithmParameterValue is AlgorithmParameterBoolValue) { 660 r.Parameters.Add(algorithmParameter.Name, new BoolValue(((AlgorithmParameterBoolValue)algorithmParameterValue).Value)); 661 } else if (algorithmParameterValue is AlgorithmParameterFloatValue) { 662 r.Parameters.Add(algorithmParameter.Name, new DoubleValue(((AlgorithmParameterFloatValue)algorithmParameterValue).Value)); 663 } else if (algorithmParameterValue is AlgorithmParameterIntValue) { 664 r.Parameters.Add(algorithmParameter.Name, new IntValue((int)((AlgorithmParameterIntValue)algorithmParameterValue).Value)); 665 } else if (algorithmParameterValue is AlgorithmParameterStringValue) { 666 r.Parameters.Add(algorithmParameter.Name, new StringValue(((AlgorithmParameterStringValue)algorithmParameterValue).Value)); 667 } 668 } 669 foreach (ProblemParameterValue problemParameterValue in exp.ProblemParameterValues) { 670 ProblemParameter problemParameter = GetProblemParameter(problemParameterValue.ProblemParameterId); 671 if (problemParameterValue is ProblemParameterBlobValue) { 672 IItem item = null; 673 using (MemoryStream stream = new MemoryStream(((ProblemParameterBlobValue)problemParameterValue).Value)) { 674 try { 675 item = XmlParser.Deserialize<IItem>(stream); 676 } 677 catch (Exception ex) { 678 ErrorHandling.ShowErrorDialog(ex); 679 } 680 stream.Close(); 681 } 682 r.Parameters.Add(problemParameter.Name, item); 683 } else if (problemParameterValue is ProblemParameterBoolValue) { 684 r.Parameters.Add(problemParameter.Name, new BoolValue(((ProblemParameterBoolValue)problemParameterValue).Value)); 685 } else if (problemParameterValue is ProblemParameterFloatValue) { 686 r.Parameters.Add(problemParameter.Name, new DoubleValue(((ProblemParameterFloatValue)problemParameterValue).Value)); 687 } else if (problemParameterValue is ProblemParameterIntValue) { 688 r.Parameters.Add(problemParameter.Name, new IntValue((int)((ProblemParameterIntValue)problemParameterValue).Value)); 689 } else if (problemParameterValue is ProblemParameterStringValue) { 690 r.Parameters.Add(problemParameter.Name, new StringValue(((ProblemParameterStringValue)problemParameterValue).Value)); 691 } 692 } 693 runCollection.Add(r); 694 } 695 return runCollection; 696 } 595 697 #endregion 596 698
Note: See TracChangeset
for help on using the changeset viewer.