- Location:
- /trunk/sources
- Files:
-
- 32 added
- 31 deleted
- 53 edited
Legend:
- Unmodified
- Added
- Removed
-
/trunk/sources/HeuristicLab.AdvancedOptimizationFrontend/HeuristicLab.AdvancedOptimizationFrontend.csproj
r20 r30 94 94 <ItemGroup> 95 95 <None Include="HeuristicLab.snk" /> 96 <None Include="Properties\AssemblyInfo.frame" /> 96 97 </ItemGroup> 97 98 <ItemGroup> … … 141 142 </Target> 142 143 --> 144 <PropertyGroup> 145 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 146 </PropertyGroup> 143 147 </Project> -
/trunk/sources/HeuristicLab.BitVector/HeuristicLab.BitVector.csproj
r20 r30 68 68 <ItemGroup> 69 69 <None Include="HeuristicLab.snk" /> 70 <None Include="Properties\AssemblyInfo.frame" /> 70 71 </ItemGroup> 71 72 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> … … 77 78 </Target> 78 79 --> 80 <PropertyGroup> 81 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 82 </PropertyGroup> 79 83 </Project> -
/trunk/sources/HeuristicLab.Charting.Data/HeuristicLab.Charting.Data.csproj
r20 r30 3 3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 4 4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> 5 <ProductVersion> 8.0.50727</ProductVersion>5 <ProductVersion>9.0.21022</ProductVersion> 6 6 <SchemaVersion>2.0</SchemaVersion> 7 7 <ProjectGuid>{E0740131-AA3E-4A3F-BA03-C9FF8327F4EE}</ProjectGuid> … … 69 69 <ItemGroup> 70 70 <None Include="HeuristicLab.snk" /> 71 <None Include="Properties\AssemblyInfo.frame" /> 71 72 </ItemGroup> 72 73 <ItemGroup> … … 84 85 </Target> 85 86 --> 87 <PropertyGroup> 88 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 89 </PropertyGroup> 86 90 </Project> -
/trunk/sources/HeuristicLab.Charting/HeuristicLab.Charting.csproj
r20 r30 3 3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 4 4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> 5 <ProductVersion> 8.0.50727</ProductVersion>5 <ProductVersion>9.0.21022</ProductVersion> 6 6 <SchemaVersion>2.0</SchemaVersion> 7 7 <ProjectGuid>{B462D3CC-8866-42F0-9832-AD0967613B72}</ProjectGuid> … … 96 96 <None Include="ClassDiagram.cd" /> 97 97 <None Include="HeuristicLab.snk" /> 98 <None Include="Properties\AssemblyInfo.frame" /> 98 99 </ItemGroup> 99 100 <ItemGroup> … … 111 112 </Target> 112 113 --> 114 <PropertyGroup> 115 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 116 </PropertyGroup> 113 117 </Project> -
/trunk/sources/HeuristicLab.Constraints/HeuristicLab.Constraints.csproj
r20 r30 154 154 <ItemGroup> 155 155 <None Include="HeuristicLab.snk" /> 156 <None Include="Properties\AssemblyInfo.frame" /> 156 157 </ItemGroup> 157 158 <ItemGroup> … … 212 213 </Target> 213 214 --> 215 <PropertyGroup> 216 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 217 </PropertyGroup> 214 218 </Project> -
/trunk/sources/HeuristicLab.Core/HeuristicLab.Core.csproj
r20 r30 229 229 <ItemGroup> 230 230 <None Include="HeuristicLab.snk" /> 231 <None Include="Properties\AssemblyInfo.frame" /> 231 232 </ItemGroup> 232 233 <ItemGroup> … … 342 343 </Target> 343 344 --> 345 <PropertyGroup> 346 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 347 </PropertyGroup> 344 348 </Project> -
/trunk/sources/HeuristicLab.Core/PersistenceManager.cs
r20 r30 62 62 } 63 63 public static void Save(IStorable instance, string filename) { 64 Save(instance, File.OpenWrite(filename)); 64 FileStream stream = File.Create(filename); 65 Save(instance, stream); 66 stream.Close(); 65 67 } 66 68 public static void Save(IStorable instance, Stream stream) { … … 70 72 } 71 73 public static IStorable Load(string filename) { 72 return Load(File.OpenRead(filename)); 74 FileStream stream = File.OpenRead(filename); 75 IStorable storable = Load(stream); 76 stream.Close(); 77 return storable; 73 78 } 74 79 public static IStorable Load(Stream stream) { -
/trunk/sources/HeuristicLab.Data/HeuristicLab.Data.csproj
r20 r30 193 193 <ItemGroup> 194 194 <None Include="HeuristicLab.snk" /> 195 <None Include="Properties\AssemblyInfo.frame" /> 195 196 </ItemGroup> 196 197 <ItemGroup> … … 260 261 </Target> 261 262 --> 263 <PropertyGroup> 264 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 265 </PropertyGroup> 262 266 </Project> -
/trunk/sources/HeuristicLab.DataAnalysis/HeuristicLab.DataAnalysis.csproj
r20 r30 80 80 <ItemGroup> 81 81 <None Include="HeuristicLab.snk" /> 82 <None Include="Properties\AssemblyInfo.frame" /> 82 83 </ItemGroup> 83 84 <ItemGroup> … … 95 96 </Target> 96 97 --> 98 <PropertyGroup> 99 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 100 </PropertyGroup> 97 101 </Project> -
/trunk/sources/HeuristicLab.DistributedEngine/DistributedEngine.cs
r20 r30 71 71 binding.ReaderQuotas.MaxStringContentLength = 100000000; // also 100M chars 72 72 binding.ReaderQuotas.MaxArrayLength = 100000000; // also 100M elements; 73 binding.Security.Mode = SecurityMode.None; 73 74 ChannelFactory<IGridServer> factory = new ChannelFactory<IGridServer>(binding); 74 75 server = factory.CreateChannel(new EndpointAddress(serverAddress)); -
/trunk/sources/HeuristicLab.DistributedEngine/HeuristicLab.DistributedEngine.csproj
r20 r30 72 72 <Name>HeuristicLab.PluginInfrastructure</Name> 73 73 </ProjectReference> 74 <ProjectReference Include="..\HeuristicLab.ThreadParallelEngine\HeuristicLab.ThreadParallelEngine.csproj">75 <Project>{6E757D0E-20F9-4E89-AF06-D7DA256870DB}</Project>76 <Name>HeuristicLab.ThreadParallelEngine</Name>77 </ProjectReference>78 74 </ItemGroup> 79 75 <ItemGroup> … … 82 78 <SubType>Designer</SubType> 83 79 </EmbeddedResource> 80 </ItemGroup> 81 <ItemGroup> 82 <None Include="Properties\AssemblyInfo.frame" /> 84 83 </ItemGroup> 85 84 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> … … 91 90 </Target> 92 91 --> 92 <PropertyGroup> 93 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 94 </PropertyGroup> 93 95 </Project> -
/trunk/sources/HeuristicLab.DistributedEngine/HeuristicLabDistributedEnginePlugin.cs
r20 r30 30 30 [Dependency(Dependency = "HeuristicLab.Core")] 31 31 [Dependency(Dependency = "HeuristicLab.Grid")] 32 [Dependency(Dependency = "HeuristicLab.ThreadParallelEngine")]33 32 public class HeuristicLabDistributedEnginePlugin : PluginBase { 34 33 } -
/trunk/sources/HeuristicLab.Evolutionary/HeuristicLab.Evolutionary.csproj
r20 r30 53 53 <ItemGroup> 54 54 <None Include="HeuristicLab.snk" /> 55 <None Include="Properties\AssemblyInfo.frame" /> 55 56 </ItemGroup> 56 57 <ItemGroup> … … 80 81 </Target> 81 82 --> 83 <PropertyGroup> 84 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 85 </PropertyGroup> 82 86 </Project> -
/trunk/sources/HeuristicLab.Functions/HeuristicLab.Functions.csproj
r20 r30 106 106 <ItemGroup> 107 107 <None Include="HeuristicLab.snk" /> 108 <None Include="Properties\AssemblyInfo.frame" /> 108 109 </ItemGroup> 109 110 <ItemGroup> … … 121 122 </Target> 122 123 --> 124 <PropertyGroup> 125 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 126 </PropertyGroup> 123 127 </Project> -
/trunk/sources/HeuristicLab.Grid/ClientForm.cs
r20 r30 56 56 binding.ReaderQuotas.MaxStringContentLength = 100000000; // also 100M chars 57 57 binding.ReaderQuotas.MaxArrayLength = 100000000; // also 100M elements; 58 binding.Security.Mode = SecurityMode.None; 58 59 factory = new ChannelFactory<IEngineStore>(binding); 59 60 engineStore = factory.CreateChannel(new EndpointAddress(addressTextBox.Text)); -
/trunk/sources/HeuristicLab.Grid/HeuristicLab.Grid.csproj
r20 r30 83 83 <Name>HeuristicLab.PluginInfrastructure</Name> 84 84 </ProjectReference> 85 <ProjectReference Include="..\HeuristicLab.ThreadParallelEngine\HeuristicLab.ThreadParallelEngine.csproj">86 <Project>{6E757D0E-20F9-4E89-AF06-D7DA256870DB}</Project>87 <Name>HeuristicLab.ThreadParallelEngine</Name>88 </ProjectReference>89 85 </ItemGroup> 90 86 <ItemGroup> … … 98 94 </EmbeddedResource> 99 95 </ItemGroup> 96 <ItemGroup> 97 <None Include="Properties\AssemblyInfo.frame" /> 98 </ItemGroup> 100 99 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 101 100 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. … … 106 105 </Target> 107 106 --> 107 <PropertyGroup> 108 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 109 </PropertyGroup> 108 110 </Project> -
/trunk/sources/HeuristicLab.Grid/HeuristicLabGridPlugin.cs
r20 r30 30 30 [PluginFile(Filename = "HeuristicLab.Grid.dll", Filetype = PluginFileType.Assembly)] 31 31 [Dependency(Dependency = "HeuristicLab.Core")] 32 [Dependency(Dependency = "HeuristicLab.ThreadParallelEngine")]33 32 public class HeuristicLabGridPlugin : PluginBase { 34 33 } -
/trunk/sources/HeuristicLab.Grid/ProcessingEngine.cs
r20 r30 26 26 using HeuristicLab.Core; 27 27 using System.Xml; 28 using System.Threading; 28 29 29 30 namespace HeuristicLab.Grid { 30 public class ProcessingEngine : ThreadParallelEngine.ThreadParallelEngine { 31 31 public class ProcessingEngine : EngineBase { 32 32 private AtomicOperation initialOperation; 33 33 public AtomicOperation InitialOperation { … … 56 56 initialOperation = (AtomicOperation)PersistenceManager.Restore(node.SelectSingleNode("InitialOperation"), restoredObjects); 57 57 } 58 59 protected override void ProcessNextOperation() { 60 IOperation operation = myExecutionStack.Pop(); 61 if(operation is AtomicOperation) { 62 AtomicOperation atomicOperation = (AtomicOperation)operation; 63 IOperation next = null; 64 try { 65 next = atomicOperation.Operator.Execute(atomicOperation.Scope); 66 } catch(Exception ex) { 67 // push operation on stack again 68 myExecutionStack.Push(atomicOperation); 69 Abort(); 70 ThreadPool.QueueUserWorkItem(delegate(object state) { OnExceptionOccurred(ex); }); 71 } 72 if(next != null) 73 myExecutionStack.Push(next); 74 OnOperationExecuted(atomicOperation); 75 if(atomicOperation.Operator.Breakpoint) Abort(); 76 } else if(operation is CompositeOperation) { 77 CompositeOperation compositeOperation = (CompositeOperation)operation; 78 for(int i = compositeOperation.Operations.Count - 1; i >= 0; i--) 79 myExecutionStack.Push(compositeOperation.Operations[i]); 80 } 81 } 58 82 } 59 83 } -
/trunk/sources/HeuristicLab.Grid/ServerForm.cs
r20 r30 58 58 binding.ReaderQuotas.MaxStringContentLength = 100000000; // also 100M chars 59 59 binding.ReaderQuotas.MaxArrayLength = 100000000; // also 100M elements; 60 binding.Security.Mode = SecurityMode.None; 60 61 61 62 externalHost.AddServiceEndpoint(typeof(IGridServer), binding, externalAddressTextBox.Text); -
/trunk/sources/HeuristicLab.Logging/HeuristicLab.Logging.csproj
r20 r30 67 67 <ItemGroup> 68 68 <None Include="HeuristicLab.snk" /> 69 <None Include="Properties\AssemblyInfo.frame" /> 69 70 </ItemGroup> 70 71 <ItemGroup> … … 112 113 </Target> 113 114 --> 115 <PropertyGroup> 116 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 117 </PropertyGroup> 114 118 </Project> -
/trunk/sources/HeuristicLab.Operators.Programmable/HeuristicLab.Operators.Programmable.csproj
r20 r30 62 62 <ItemGroup> 63 63 <None Include="HeuristicLab.snk" /> 64 <None Include="Properties\AssemblyInfo.frame" /> 64 65 </ItemGroup> 65 66 <ItemGroup> … … 95 96 </Target> 96 97 --> 98 <PropertyGroup> 99 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 100 </PropertyGroup> 97 101 </Project> -
/trunk/sources/HeuristicLab.Operators/HeuristicLab.Operators.csproj
r20 r30 109 109 <ItemGroup> 110 110 <None Include="HeuristicLab.snk" /> 111 <None Include="Properties\AssemblyInfo.frame" /> 111 112 </ItemGroup> 112 113 <ItemGroup> … … 124 125 </Target> 125 126 --> 127 <PropertyGroup> 128 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 129 </PropertyGroup> 126 130 </Project> -
/trunk/sources/HeuristicLab.OptimizationFrontend/HeuristicLab.OptimizationFrontend.csproj
r20 r30 93 93 <ItemGroup> 94 94 <None Include="HeuristicLab.snk" /> 95 <None Include="Properties\AssemblyInfo.frame" /> 95 96 </ItemGroup> 96 97 <ItemGroup> … … 138 139 </Target> 139 140 --> 141 <PropertyGroup> 142 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 143 </PropertyGroup> 140 144 </Project> -
/trunk/sources/HeuristicLab.Permutation/HeuristicLab.Permutation.csproj
r20 r30 84 84 <ItemGroup> 85 85 <None Include="HeuristicLab.snk" /> 86 <None Include="Properties\AssemblyInfo.frame" /> 86 87 </ItemGroup> 87 88 <ItemGroup> … … 111 112 </Target> 112 113 --> 114 <PropertyGroup> 115 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 116 </PropertyGroup> 113 117 </Project> -
/trunk/sources/HeuristicLab.PluginInfrastructure.GUI/HeuristicLab.PluginInfrastructure.GUI.csproj
r20 r30 139 139 <ItemGroup> 140 140 <None Include="HeuristicLab.snk" /> 141 <None Include="Properties\AssemblyInfo.frame" /> 141 142 <None Include="Resources\HeuristicLab.ico" /> 142 143 </ItemGroup> … … 153 154 </Target> 154 155 --> 156 <PropertyGroup> 157 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 158 </PropertyGroup> 155 159 </Project> -
/trunk/sources/HeuristicLab.PluginInfrastructure.GUI/ManagerForm.cs
r20 r30 37 37 private TreeNode availablePlugins; 38 38 private TreeNode allPlugins; 39 private TreeNode disabledPlugins; 39 40 private List<PluginTag> allTags = new List<PluginTag>(); 40 41 private Dictionary<PluginTag, PluginAction> actions = new Dictionary<PluginTag, PluginAction>(); … … 75 76 allPlugins.ImageIndex = 1; 76 77 allPlugins.SelectedImageIndex = 1; 78 disabledPlugins = new TreeNode("Disabled plugins"); 79 disabledPlugins.ImageIndex = 1; 80 disabledPlugins.SelectedImageIndex = 1; 77 81 78 82 pluginTreeView.Nodes.Add(installedPlugins); 79 83 pluginTreeView.Nodes.Add(availablePlugins); 84 pluginTreeView.Nodes.Add(disabledPlugins); 80 85 pluginTreeView.Nodes.Add(allPlugins); 81 86 82 foreach(PluginInfo pluginInfo in PluginManager.Manager. InstalledPlugins) {87 foreach(PluginInfo pluginInfo in PluginManager.Manager.ActivePlugins) { 83 88 // create a new PluginAction tag for the plugin 84 89 PluginTag tag = new PluginTag(allTags, pluginInfo, PluginState.Installed); … … 91 96 installedPlugins.Nodes.Add(installedPluginsNode); 92 97 98 // add to all "plugins node" 99 TreeNode allPluginsNode = new TreeNode(pluginInfo.Name); 100 allPluginsNode.ContextMenuStrip = pluginContextMenuStrip; 101 allPluginsNode.Tag = tag; 102 allPluginsNode.ImageIndex = 0; 103 allPlugins.Nodes.Add(allPluginsNode); 104 } 105 foreach(PluginInfo pluginInfo in PluginManager.Manager.DisabledPlugins) { 106 PluginTag tag = new PluginTag(allTags, pluginInfo, PluginState.Disabled); 107 allTags.Add(tag); 108 TreeNode disabledPluginsNode = new TreeNode(pluginInfo.Name); 109 disabledPluginsNode.ContextMenuStrip = pluginContextMenuStrip; 110 disabledPluginsNode.Tag = tag; 111 disabledPluginsNode.ImageIndex = 0; 112 disabledPlugins.Nodes.Add(disabledPluginsNode); 93 113 // add to all "plugins node" 94 114 TreeNode allPluginsNode = new TreeNode(pluginInfo.Name); … … 290 310 allAvailablePlugins.ForEach(delegate(PluginDescription availablePlugin) { 291 311 List<PluginTag> oldPlugins = allTags.FindAll(delegate(PluginTag currentPlugin) { 292 return currentPlugin.PluginName == availablePlugin.Name && currentPlugin.State == PluginState.Installed;312 return currentPlugin.PluginName == availablePlugin.Name && currentPlugin.State == (PluginState.Installed | PluginState.Disabled); 293 313 }); 294 314 … … 567 587 publishButton.Enabled = (tag.State & PluginState.Installed) == PluginState.Installed; 568 588 installButton.Enabled = (tag.State & PluginState.Available) == PluginState.Available; 569 deleteButton.Enabled = (tag.State & (PluginState.Installed | PluginState.Upgradeable )) != 0;589 deleteButton.Enabled = (tag.State & (PluginState.Installed | PluginState.Upgradeable | PluginState.Disabled)) != 0; 570 590 571 591 installButton.Checked = GetAction(tag) == ManagerAction.Install; … … 605 625 private List<TreeNode> FindPluginNodes(PluginTag pluginTag) { 606 626 List<TreeNode> nodes = new List<TreeNode>(); 607 foreach(TreeNode rootNode in new TreeNode[] { installedPlugins, availablePlugins, allPlugins }) {627 foreach(TreeNode rootNode in new TreeNode[] { installedPlugins, availablePlugins, allPlugins, disabledPlugins }) { 608 628 foreach(TreeNode node in rootNode.Nodes) { 609 629 if(pluginTag.Equals(node.Tag)) { -
/trunk/sources/HeuristicLab.PluginInfrastructure.GUI/PluginTag.cs
r20 r30 31 31 Available = 2, 32 32 Upgradeable = 4, 33 Disabled = 8, 33 34 }; 34 35 … … 218 219 219 220 public override int GetHashCode() { 220 return pluginName.GetHashCode() + pluginVersion.GetHashCode(); 221 if(pluginVersion != null) { 222 return pluginName.GetHashCode() + pluginVersion.GetHashCode(); 223 } else return pluginName.GetHashCode(); 221 224 } 222 225 } -
/trunk/sources/HeuristicLab.PluginInfrastructure/DiscoveryService.cs
r20 r30 33 33 public PluginInfo[] Plugins { 34 34 get { 35 return PluginManager.Manager.LoadedPlugins; 35 PluginInfo[] plugins = new PluginInfo[PluginManager.Manager.LoadedPlugins.Count]; 36 PluginManager.Manager.LoadedPlugins.CopyTo(plugins, 0); 37 return plugins; 36 38 } 37 39 } -
/trunk/sources/HeuristicLab.PluginInfrastructure/HeuristicLab.PluginInfrastructure.csproj
r20 r30 78 78 <None Include="app.config" /> 79 79 <None Include="HeuristicLab.snk" /> 80 <None Include="Properties\AssemblyInfo.frame" /> 80 81 <None Include="Properties\Settings.settings"> 81 82 <Generator>SettingsSingleFileGenerator</Generator> … … 96 97 </Target> 97 98 --> 99 <PropertyGroup> 100 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 101 </PropertyGroup> 98 102 </Project> -
/trunk/sources/HeuristicLab.PluginInfrastructure/Loader.cs
r20 r30 33 33 public delegate void PluginLoadFailedEventHandler(string pluginName, string args); 34 34 35 private Dictionary<PluginInfo, IPlugin> activePlugins = new Dictionary<PluginInfo, IPlugin>(); 35 private Dictionary<PluginInfo, List<string>> pluginDependencies = new Dictionary<PluginInfo, List<string>>(); 36 private List<PluginInfo> preloadedPluginInfos = new List<PluginInfo>(); 37 private Dictionary<IPlugin, PluginInfo> pluginInfos = new Dictionary<IPlugin, PluginInfo>(); 36 38 private Dictionary<PluginInfo, IPlugin> allPlugins = new Dictionary<PluginInfo, IPlugin>(); 37 private Dictionary<IPlugin, PluginInfo> pluginInfos = new Dictionary<IPlugin, PluginInfo>(); 38 39 private Dictionary<string, List<string>> pluginDependencies = new Dictionary<string, List<string>>(); 40 private Dictionary<string, List<string>> pluginAssemblies = new Dictionary<string, List<string>>(); 41 42 private List<string> loadablePlugins = new List<string>(); 39 private List<PluginInfo> disabledPlugins = new List<PluginInfo>(); 43 40 private string pluginDir = Application.StartupPath + "/" + HeuristicLab.PluginInfrastructure.Properties.Settings.Default.PluginDir; 44 41 45 42 internal event PluginLoadFailedEventHandler MissingPluginFile; 46 47 43 internal event PluginManagerActionEventHandler PluginAction; 48 44 49 internal PluginInfo[]ActivePlugins {45 internal ICollection<PluginInfo> ActivePlugins { 50 46 get { 51 PluginInfo[] plugins = new PluginInfo[activePlugins.Count]; 52 activePlugins.Keys.CopyTo(plugins, 0); 53 return plugins; 54 } 55 } 56 57 internal List<PluginInfo> InstalledPlugins { 47 List<PluginInfo> list = new List<PluginInfo>(); 48 foreach(PluginInfo info in allPlugins.Keys) { 49 if(!disabledPlugins.Exists(delegate(PluginInfo disabledInfo) { return info.Name == disabledInfo.Name; })) { 50 list.Add(info); 51 } 52 } 53 return list; 54 } 55 } 56 57 internal ICollection<PluginInfo> InstalledPlugins { 58 58 get { 59 59 return new List<PluginInfo>(allPlugins.Keys); … … 61 61 } 62 62 63 private ApplicationInfo[] applications; 64 internal ApplicationInfo[] InstalledApplications { 63 internal ICollection<PluginInfo> DisabledPlugins { 64 get { 65 return disabledPlugins; 66 } 67 } 68 69 private ICollection<ApplicationInfo> applications; 70 internal ICollection<ApplicationInfo> InstalledApplications { 65 71 get { 66 72 return applications; … … 69 75 70 76 private IPlugin FindPlugin(PluginInfo plugin) { 71 return a ctivePlugins[plugin];77 return allPlugins[plugin]; 72 78 } 73 79 … … 85 91 internal void Init() { 86 92 AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += delegate(object sender, ResolveEventArgs args) { return Assembly.ReflectionOnlyLoad(args.Name); }; 87 activePlugins.Clear();88 93 allPlugins.Clear(); 94 disabledPlugins.Clear(); 89 95 pluginInfos.Clear(); 90 96 pluginsByName.Clear(); 91 loadablePlugins.Clear();92 97 pluginDependencies.Clear(); 93 pluginAssemblies.Clear();94 98 95 99 List<Assembly> assemblies = ReflectionOnlyLoadDlls(); 96 100 CheckAssemblyDependencies(assemblies); 101 CheckPluginFiles(); 102 CheckPluginDependencies(); 97 103 LoadPlugins(); 98 CheckPluginFiles();99 104 100 105 DiscoveryService service = new DiscoveryService(); 101 106 IApplication[] apps = service.GetInstances<IApplication>(); 102 applications = new ApplicationInfo[apps.Length]; 103 104 int i = 0; 107 applications = new List<ApplicationInfo>(); 108 105 109 foreach(IApplication application in apps) { 106 110 ApplicationInfo info = new ApplicationInfo(); … … 111 115 info.PluginType = application.GetType().Namespace + "." + application.GetType().Name; 112 116 113 applications [i++] = info;117 applications.Add(info); 114 118 } 115 119 } … … 129 133 130 134 private void CheckAssemblyDependencies(List<Assembly> assemblies) { 131 132 135 foreach(Assembly assembly in assemblies) { 133 134 136 // GetExportedTypes throws FileNotFoundException when a referenced assembly 135 137 // of the current assembly is missing. … … 138 140 139 141 foreach(Type t in exported) { 140 // if the typeimplements IPlugin142 // if there is a type that implements IPlugin 141 143 if(Array.Exists<Type>(t.GetInterfaces(), delegate(Type iface) { 142 144 // use AssemblyQualifiedName to compare the types because we can't directly … … 144 146 return iface.AssemblyQualifiedName == typeof(IPlugin).AssemblyQualifiedName; 145 147 })) { 148 // fetch the attributes of the IPlugin type 146 149 GetPluginAttributeData(t); 147 150 } 148 149 151 } 150 152 } catch(FileNotFoundException) { 151 153 // when a referenced assembly cannot be loaded then ignore this assembly in the plugin discovery 152 // TASK: add the assembly to some kind of unloadable assemblies list 153 // this list could be displayed to the user for diagnosis 154 } 155 } 156 157 foreach(string pluginName in this.pluginDependencies.Keys) { 158 CheckPluginDependencies(pluginName); 154 } 159 155 } 160 156 } … … 169 165 // get all attributes of that type 170 166 IList<CustomAttributeData> attributes = CustomAttributeData.GetCustomAttributes(t); 171 172 167 List<string> pluginAssemblies = new List<string>(); 173 168 List<string> pluginDependencies = new List<string>(); 169 List<string> pluginFiles = new List<string>(); 174 170 string pluginName = ""; 175 176 // extract relevant parameters177 171 // iterate through all custom attributes and search for named arguments that we are interested in 178 172 foreach(CustomAttributeData attributeData in attributes) { 179 173 List<CustomAttributeNamedArgument> namedArguments = new List<CustomAttributeNamedArgument>(attributeData.NamedArguments); 180 181 174 // if the current attribute contains a named argument with the name "Name" then extract the plugin name 182 175 CustomAttributeNamedArgument pluginNameArgument = namedArguments.Find(delegate(CustomAttributeNamedArgument arg) { … … 186 179 pluginName = (string)pluginNameArgument.TypedValue.Value; 187 180 } 188 189 181 // if the current attribute contains a named argument with the name "Dependency" then extract the dependency 190 182 // and store it in the list of all dependencies … … 192 184 return arg.MemberInfo.Name == "Dependency"; 193 185 }); 194 195 186 if(dependencyNameArgument.MemberInfo != null) { 196 187 pluginDependencies.Add((string)dependencyNameArgument.TypedValue.Value); 197 188 } 198 199 189 // if the current attribute has a named argument "Filename" then find if the argument "Filetype" is also supplied 200 190 // and if the filetype is Assembly then store the name of the assembly in the list of assemblies … … 206 196 }); 207 197 if(filenameArg.MemberInfo != null && filetypeArg.MemberInfo != null) { 198 pluginFiles.Add(pluginDir + "/" + (string)filenameArg.TypedValue.Value); 208 199 if((PluginFileType)filetypeArg.TypedValue.Value == PluginFileType.Assembly) { 209 200 pluginAssemblies.Add(pluginDir + "/" + (string)filenameArg.TypedValue.Value); … … 212 203 } 213 204 214 // m ake sure that we found reasonable values205 // minimal sanity check of the attribute values 215 206 if(pluginName != "" && pluginAssemblies.Count > 0) { 216 this.pluginDependencies[pluginName] = pluginDependencies; 217 this.pluginAssemblies[pluginName] = pluginAssemblies; 207 // create a temporary PluginInfo that contains the attribute values 208 PluginInfo info = new PluginInfo(); 209 info.Name = pluginName; 210 info.Assemblies = pluginAssemblies; 211 info.Files.AddRange(pluginFiles); 212 info.Assemblies.AddRange(pluginAssemblies); 213 this.pluginDependencies[info] = pluginDependencies; 214 preloadedPluginInfos.Add(info); 218 215 } else { 219 216 throw new InvalidPluginException(); … … 221 218 } 222 219 220 private void CheckPluginDependencies() { 221 foreach(PluginInfo pluginInfo in preloadedPluginInfos) { 222 // don't need to check plugins that are already disabled 223 if(disabledPlugins.Contains(pluginInfo)) { 224 continue; 225 } 226 visitedDependencies.Clear(); 227 if(!CheckPluginDependencies(pluginInfo.Name)) { 228 disabledPlugins.Add(pluginInfo); 229 } 230 } 231 } 232 233 private List<string> visitedDependencies = new List<string>(); 223 234 private bool CheckPluginDependencies(string pluginName) { 224 // when we already checked the dependencies of this plugin earlier then just return true 225 if(loadablePlugins.Contains(pluginName)) { 226 return true; 227 } else if(!pluginAssemblies.ContainsKey(pluginName)) { 235 if(!preloadedPluginInfos.Exists(delegate(PluginInfo info) { return pluginName == info.Name; }) || 236 disabledPlugins.Exists(delegate(PluginInfo info) { return pluginName == info.Name; }) || 237 visitedDependencies.Contains(pluginName)) { 228 238 // when the plugin is not available return false; 229 239 return false; … … 231 241 // otherwise check if all dependencies of the plugin are OK 232 242 // if yes then this plugin is also ok and we store it in the list of loadable plugins 233 foreach(string dependency in pluginDependencies[pluginName]) { 243 244 PluginInfo matchingInfo = preloadedPluginInfos.Find(delegate(PluginInfo info) { return info.Name == pluginName; }); 245 if(matchingInfo == null) throw new InvalidProgramException(); // shouldn't happen 246 foreach(string dependency in pluginDependencies[matchingInfo]) { 247 visitedDependencies.Add(pluginName); 234 248 if(CheckPluginDependencies(dependency) == false) { 235 249 // if only one dependency is not available that means that the current plugin also is unloadable 236 250 return false; 237 251 } 238 }239 // all dependencies OK -> add to loadable list and return true240 loadablePlugins.Add(pluginName);252 visitedDependencies.Remove(pluginName); 253 } 254 // all dependencies OK 241 255 return true; 242 256 } … … 245 259 246 260 private Dictionary<string, IPlugin> pluginsByName = new Dictionary<string, IPlugin>(); 247 248 261 private void LoadPlugins() { 249 262 // load all loadable plugins (all dependencies available) into the execution context 250 foreach( string plugin in loadablePlugins) {251 {252 foreach(string assembly in plugin Assemblies[plugin]) {263 foreach(PluginInfo pluginInfo in preloadedPluginInfos) { 264 if(!disabledPlugins.Contains(pluginInfo)) { 265 foreach(string assembly in pluginInfo.Assemblies) { 253 266 Assembly.LoadFrom(assembly); 254 267 } … … 263 276 continue; 264 277 Type[] availablePluginTypes = service.GetTypes(typeof(IPlugin), assembly); 265 266 267 278 foreach(Type pluginType in availablePluginTypes) { 268 279 if(!pluginType.IsAbstract && !pluginType.IsInterface && !pluginType.HasElementType) { 269 280 IPlugin plugin = (IPlugin)Activator.CreateInstance(pluginType); 270 281 PluginAction(this, new PluginManagerActionEventArgs(plugin.Name, PluginManagerAction.InitializingPlugin)); 271 272 282 pluginsByName.Add(plugin.Name, plugin); 273 PluginInfo pluginInfo = GetPluginInfo(plugin); 274 275 276 allPlugins.Add(pluginInfo, plugin); 277 PluginAction(this, new PluginManagerActionEventArgs(plugin.Name, PluginManagerAction.InitializedPlugin)); 278 } 279 } 280 } 281 } 282 283 283 } 284 } 285 } 286 287 foreach(IPlugin plugin in pluginsByName.Values) { 288 PluginInfo pluginInfo = GetPluginInfo(plugin); 289 allPlugins.Add(pluginInfo, plugin); 290 PluginAction(this, new PluginManagerActionEventArgs(plugin.Name, PluginManagerAction.InitializedPlugin)); 291 } 292 } 284 293 private PluginInfo GetPluginInfo(IPlugin plugin) { 285 294 if(pluginInfos.ContainsKey(plugin)) { 286 295 return pluginInfos[plugin]; 287 296 } 288 289 297 // store the data of the plugin in a description file which can be used without loading the plugin assemblies 290 298 PluginInfo pluginInfo = new PluginInfo(); … … 299 307 }); 300 308 301 // each plugin can have multiple assemlies associated 302 // for each assembly of the plugin find the dependencies 303 // and get the pluginDescriptions for all dependencies 304 foreach(string assembly in pluginAssemblies[plugin.Name]) { 309 PluginInfo preloadedInfo = preloadedPluginInfos.Find(delegate(PluginInfo info) { return info.Name == plugin.Name; }); 310 foreach(string assembly in preloadedInfo.Assemblies) { 305 311 // always use \ as directory separator (this is necessary for discovery of types in 306 312 // plugins see DiscoveryService.GetTypes() 307 313 pluginInfo.Assemblies.Add(assembly.Replace('/', '\\')); 308 309 } 310 foreach(string dependency in pluginDependencies[plugin.Name]) { 314 } 315 foreach(string dependency in pluginDependencies[preloadedInfo]) { 311 316 // accumulate the dependencies of each assembly into the dependencies of the whole plugin 312 317 PluginInfo dependencyInfo = GetPluginInfo(pluginsByName[dependency]); 313 318 pluginInfo.Dependencies.Add(dependencyInfo); 314 319 } 315 316 320 pluginInfos[plugin] = pluginInfo; 317 318 321 return pluginInfo; 319 322 } 320 323 321 324 private void CheckPluginFiles() { 322 foreach(PluginInfo plugin in allPlugins.Keys) { 323 CheckPluginFiles(plugin); 325 foreach(PluginInfo plugin in preloadedPluginInfos) { 326 if(!CheckPluginFiles(plugin)) { 327 disabledPlugins.Add(plugin); 328 } 324 329 } 325 330 } 326 331 327 332 private bool CheckPluginFiles(PluginInfo pluginInfo) { 328 if(activePlugins.ContainsKey(pluginInfo)) {329 return true;330 }331 foreach(PluginInfo dependency in pluginInfo.Dependencies) {332 if(!CheckPluginFiles(dependency)) {333 return false;334 }335 }336 333 foreach(string filename in pluginInfo.Files) { 337 334 if(!File.Exists(filename)) { 338 MissingPluginFile(pluginInfo.Name, filename); 335 if(MissingPluginFile != null) { 336 MissingPluginFile(pluginInfo.Name, filename); 337 } 339 338 return false; 340 339 } 341 340 } 342 343 activePlugins.Add(pluginInfo, allPlugins[pluginInfo]);344 341 return true; 345 342 } -
/trunk/sources/HeuristicLab.PluginInfrastructure/PluginInfo.cs
r20 r30 83 83 84 84 public override int GetHashCode() { 85 return name.GetHashCode() + version.GetHashCode(); 85 if(version != null) { 86 return name.GetHashCode() + version.GetHashCode(); 87 } else return name.GetHashCode(); 86 88 } 87 89 } -
/trunk/sources/HeuristicLab.PluginInfrastructure/PluginManager.cs
r20 r30 53 53 } 54 54 55 public List<PluginInfo> InstalledPlugins {55 public ICollection<PluginInfo> InstalledPlugins { 56 56 get { return remoteLoader.InstalledPlugins; } 57 57 } 58 58 59 public ApplicationInfo[] InstalledApplications { 59 public ICollection<PluginInfo> DisabledPlugins { 60 get { return remoteLoader.DisabledPlugins; } 61 } 62 63 public ICollection<PluginInfo> ActivePlugins { 64 get { return remoteLoader.ActivePlugins; } 65 } 66 67 public ICollection<ApplicationInfo> InstalledApplications { 60 68 get { return remoteLoader.InstalledApplications; } 61 69 } 62 70 63 private PluginInfo[]loadedPlugins;64 public PluginInfo[]LoadedPlugins {71 private ICollection<PluginInfo> loadedPlugins; 72 public ICollection<PluginInfo> LoadedPlugins { 65 73 get { return loadedPlugins; } 66 74 internal set { loadedPlugins = value; } … … 72 80 public void Initialize() { 73 81 NotifyListeners(PluginManagerAction.Initializing, "-"); 74 75 82 AppDomainSetup setup = AppDomain.CurrentDomain.SetupInformation; 76 83 setup.PrivateBinPath = pluginDir; 77 84 pluginDomain = AppDomain.CreateDomain("plugin domain", null, setup); 78 79 85 remoteLoader = (Loader)pluginDomain.CreateInstanceAndUnwrap("HeuristicLab.PluginInfraStructure", "HeuristicLab.PluginInfrastructure.Loader"); 80 81 86 remoteLoader.PluginAction += delegate(object sender, PluginManagerActionEventArgs args) { if(Action != null) Action(this, args); }; 82 87 remoteLoader.Init(); 83 84 88 NotifyListeners(PluginManagerAction.Initialized, "-"); 85 89 } … … 99 103 setup.PrivateBinPath = pluginDir; 100 104 AppDomain applicationDomain = AppDomain.CreateDomain(appInfo.Name + " AppDomain", null, setup); 101 105 102 106 Runner remoteRunner = (Runner)applicationDomain.CreateInstanceAndUnwrap("HeuristicLab.PluginInfrastructure", "HeuristicLab.PluginInfrastructure.Runner"); 103 107 NotifyListeners(PluginManagerAction.Initializing, "All plugins"); … … 116 120 public List<PluginInfo> GetDependentPlugins(PluginInfo pluginInfo) { 117 121 List<PluginInfo> mergedList = new List<PluginInfo>(); 118 InstalledPlugins.ForEach(delegate(PluginInfo plugin) {122 foreach(PluginInfo plugin in InstalledPlugins) { 119 123 if(plugin.Dependencies.Contains(pluginInfo)) { 120 124 if(!mergedList.Contains(plugin)) { … … 125 129 GetDependentPlugins(plugin).ForEach(delegate(PluginInfo dependentPlugin) { 126 130 if(!mergedList.Contains(dependentPlugin)) { 127 mergedList.Add(dependentPlugin); 131 mergedList.Add(dependentPlugin); 128 132 } 129 133 }); 130 134 } 131 }); 132 135 } 133 136 return mergedList; 134 137 } -
/trunk/sources/HeuristicLab.PluginInfrastructure/Runner.cs
r20 r30 28 28 internal class Runner : MarshalByRefObject { 29 29 30 public void LoadPlugins( PluginInfo[]plugins) {30 public void LoadPlugins(ICollection<PluginInfo> plugins) { 31 31 foreach(PluginInfo pluginInfo in plugins) { 32 32 foreach(string assemblyName in pluginInfo.Assemblies) { … … 34 34 } 35 35 } 36 37 36 PluginManager.Manager.LoadedPlugins = plugins; 38 37 } -
/trunk/sources/HeuristicLab.Random/HeuristicLab.Random.csproj
r20 r30 81 81 <ItemGroup> 82 82 <None Include="HeuristicLab.snk" /> 83 <None Include="Properties\AssemblyInfo.frame" /> 83 84 </ItemGroup> 84 85 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> … … 90 91 </Target> 91 92 --> 93 <PropertyGroup> 94 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 95 </PropertyGroup> 92 96 </Project> -
/trunk/sources/HeuristicLab.RealVector/HeuristicLab.RealVector.csproj
r20 r30 50 50 <ItemGroup> 51 51 <None Include="HeuristicLab.snk" /> 52 <None Include="Properties\AssemblyInfo.frame" /> 52 53 </ItemGroup> 53 54 <ItemGroup> … … 77 78 </Target> 78 79 --> 80 <PropertyGroup> 81 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 82 </PropertyGroup> 79 83 </Project> -
/trunk/sources/HeuristicLab.Routing.TSP/HeuristicLab.Routing.TSP.csproj
r20 r30 99 99 <ItemGroup> 100 100 <None Include="HeuristicLab.snk" /> 101 <None Include="Properties\AssemblyInfo.frame" /> 101 102 </ItemGroup> 102 103 <ItemGroup> … … 118 119 </Target> 119 120 --> 121 <PropertyGroup> 122 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 123 </PropertyGroup> 120 124 </Project> -
/trunk/sources/HeuristicLab.SGA/HeuristicLab.SGA.csproj
r20 r30 94 94 <ItemGroup> 95 95 <None Include="HeuristicLab.snk" /> 96 <None Include="Properties\AssemblyInfo.frame" /> 96 97 </ItemGroup> 97 98 <ItemGroup> … … 109 110 </Target> 110 111 --> 112 <PropertyGroup> 113 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 114 </PropertyGroup> 111 115 </Project> -
/trunk/sources/HeuristicLab.Scheduling.JSSP/HeuristicLab.Scheduling.JSSP.csproj
r20 r30 125 125 <ItemGroup> 126 126 <None Include="HeuristicLab.snk" /> 127 <None Include="Properties\AssemblyInfo.frame" /> 127 128 </ItemGroup> 128 129 <ItemGroup> … … 161 162 </Target> 162 163 --> 164 <PropertyGroup> 165 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 166 </PropertyGroup> 163 167 </Project> -
/trunk/sources/HeuristicLab.Selection.OffspringSelection/HeuristicLab.Selection.OffspringSelection.csproj
r20 r30 50 50 <ItemGroup> 51 51 <None Include="HeuristicLab.snk" /> 52 <None Include="Properties\AssemblyInfo.frame" /> 52 53 </ItemGroup> 53 54 <ItemGroup> … … 73 74 </Target> 74 75 --> 76 <PropertyGroup> 77 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 78 </PropertyGroup> 75 79 </Project> -
/trunk/sources/HeuristicLab.Selection/HeuristicLab.Selection.csproj
r20 r30 61 61 <ItemGroup> 62 62 <None Include="HeuristicLab.snk" /> 63 <None Include="Properties\AssemblyInfo.frame" /> 63 64 </ItemGroup> 64 65 <ItemGroup> … … 88 89 </Target> 89 90 --> 91 <PropertyGroup> 92 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 93 </PropertyGroup> 90 94 </Project> -
/trunk/sources/HeuristicLab.SequentialEngine/HeuristicLab.SequentialEngine.csproj
r20 r30 57 57 <ItemGroup> 58 58 <None Include="HeuristicLab.snk" /> 59 <None Include="Properties\AssemblyInfo.frame" /> 59 60 </ItemGroup> 60 61 <ItemGroup> … … 76 77 </Target> 77 78 --> 79 <PropertyGroup> 80 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 81 </PropertyGroup> 78 82 </Project> -
/trunk/sources/HeuristicLab.StructureIdentification/HeuristicLab.StructureIdentification.csproj
r20 r30 122 122 <ItemGroup> 123 123 <None Include="HeuristicLab.snk" /> 124 <None Include="Properties\AssemblyInfo.frame" /> 124 125 </ItemGroup> 125 126 <ItemGroup> … … 141 142 </Target> 142 143 --> 144 <PropertyGroup> 145 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 146 </PropertyGroup> 143 147 </Project> -
/trunk/sources/HeuristicLab.StructureIdentification/Manipulation/ChangeNodeTypeManipulation.cs
r20 r30 38 38 AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In)); 39 39 AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size (number of nodes) of the tree", typeof(IntData), VariableKind.In)); 40 AddVariableInfo(new VariableInfo("Balance Trees", "Determines if the trees should be balanced", typeof(BoolData), VariableKind.In));40 AddVariableInfo(new VariableInfo("BalancedTreesRate", "Determines how many trees should be balanced", typeof(DoubleData), VariableKind.In)); 41 41 AddVariableInfo(new VariableInfo("OperatorTree", "The tree to mutate", typeof(IOperator), VariableKind.In)); 42 42 AddVariableInfo(new VariableInfo("TreeSize", "The size (number of nodes) of the tree", typeof(IntData), VariableKind.In)); … … 49 49 MersenneTwister random = GetVariableValue<MersenneTwister>("Random", scope, true); 50 50 GPOperatorLibrary library = GetVariableValue<GPOperatorLibrary>("OperatorLibrary", scope, true); 51 bool balanceTrees = GetVariableValue<BoolData>("BalanceTrees", scope, true).Data;51 double balancedTreesRate = GetVariableValue<DoubleData>("BalancedTreesRate", scope, true).Data; 52 52 IntData treeSize = GetVariableValue<IntData>("TreeSize", scope, false); 53 53 IntData treeHeight = GetVariableValue<IntData>("TreeHeight", scope, false); … … 87 87 } else { 88 88 List<IOperator> uninitializedOperators; 89 IOperator newFunction = ChangeFunctionType(parent, selectedChild, selectedChildIndex, gardener, random, balance Trees, out uninitializedOperators);89 IOperator newFunction = ChangeFunctionType(parent, selectedChild, selectedChildIndex, gardener, random, balancedTreesRate, out uninitializedOperators); 90 90 91 91 if (parent == null) { … … 139 139 140 140 private IOperator ChangeFunctionType(IOperator parent, IOperator child, int childIndex, TreeGardener gardener, MersenneTwister random, 141 bool balanceTrees, out List<IOperator> uninitializedOperators) {141 double balancedTreesRate, out List<IOperator> uninitializedOperators) { 142 142 // since there are suboperators, we have to check which 143 143 // and how many of the existing suboperators we can reuse … … 197 197 availableSubOperators.Remove(selectedSubOperator); // the operator shouldn't be available for the following slots 198 198 } else { 199 IOperator freshOperatorTree = gardener.CreateRandomTree(allowedOperators, maxSubTreeSize, maxSubTreeHeight, balanceTrees); 199 IOperator freshOperatorTree; 200 if(random.NextDouble() <= balancedTreesRate) { 201 freshOperatorTree = gardener.CreateRandomTree(allowedOperators, maxSubTreeSize, maxSubTreeHeight, true); 202 } else { 203 freshOperatorTree = gardener.CreateRandomTree(allowedOperators, maxSubTreeSize, maxSubTreeHeight, false); 204 } 200 205 freshSubTrees.AddRange(gardener.GetAllOperators(freshOperatorTree)); 201 206 -
/trunk/sources/HeuristicLab.StructureIdentification/Manipulation/CutOutNodeManipulation.cs
r20 r30 52 52 AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In)); 53 53 AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size (number of nodes) of the tree", typeof(IntData), VariableKind.In)); 54 AddVariableInfo(new VariableInfo("Balance Trees", "Determines if the trees should be balanced", typeof(BoolData), VariableKind.In));54 AddVariableInfo(new VariableInfo("BalancedTreesRate", "Determines how many trees should be balanced", typeof(DoubleData), VariableKind.In)); 55 55 AddVariableInfo(new VariableInfo("OperatorTree", "The tree to mutate", typeof(IOperator), VariableKind.In)); 56 56 AddVariableInfo(new VariableInfo("TreeSize", "The size (number of nodes) of the tree", typeof(IntData), VariableKind.In)); … … 65 65 int maxTreeHeight = GetVariableValue<IntData>("MaxTreeHeight", scope, true).Data; 66 66 int maxTreeSize = GetVariableValue<IntData>("MaxTreeSize", scope, true).Data; 67 bool balanceTrees = GetVariableValue<BoolData>("BalanceTrees", scope, true).Data;67 double balancedTreesRate = GetVariableValue<DoubleData>("BalancedTreesRate", scope, true).Data; 68 68 69 69 TreeGardener gardener = new TreeGardener(random, library); … … 95 95 } else { 96 96 // create a new random tree 97 IOperator newOperator = gardener.CreateRandomTree(gardener.AllOperators, maxTreeSize, maxTreeHeight, balanceTrees); 97 IOperator newOperator; 98 if(random.NextDouble() <= balancedTreesRate) { 99 newOperator = gardener.CreateRandomTree(gardener.AllOperators, maxTreeSize, maxTreeHeight, true); 100 } else { 101 newOperator = gardener.CreateRandomTree(gardener.AllOperators, maxTreeSize, maxTreeHeight, false); 102 } 98 103 99 104 GetVariableValue<IntData>("TreeSize", scope, true).Data = gardener.GetTreeSize(newOperator); -
/trunk/sources/HeuristicLab.StructureIdentification/Manipulation/DeleteSubTreeManipulation.cs
r20 r30 42 42 AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In)); 43 43 AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size (number of nodes) of the tree", typeof(IntData), VariableKind.In)); 44 AddVariableInfo(new VariableInfo("BalanceTrees", "Determines if the trees should be balanced", typeof(BoolData), VariableKind.In));45 44 AddVariableInfo(new VariableInfo("OperatorTree", "The tree to mutate", typeof(IOperator), VariableKind.In | VariableKind.Out)); 46 45 AddVariableInfo(new VariableInfo("TreeSize", "The size (number of nodes) of the tree", typeof(IntData), VariableKind.In | VariableKind.Out)); -
/trunk/sources/HeuristicLab.StructureIdentification/Manipulation/SubstituteSubTreeManipulation.cs
r20 r30 41 41 AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In)); 42 42 AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size (number of nodes) of the tree", typeof(IntData), VariableKind.In)); 43 AddVariableInfo(new VariableInfo("Balance Trees", "Determines if the trees should be balanced", typeof(BoolData), VariableKind.In));43 AddVariableInfo(new VariableInfo("BalancedTreesRate", "Determines how many trees should be balanced", typeof(DoubleData), VariableKind.In)); 44 44 AddVariableInfo(new VariableInfo("OperatorTree", "The tree to manipulate", typeof(IOperator), VariableKind.In)); 45 45 AddVariableInfo(new VariableInfo("TreeSize", "The size (number of nodes) of the tree", typeof(IntData), VariableKind.In)); … … 54 54 int maxTreeHeight = GetVariableValue<IntData>("MaxTreeHeight", scope, true).Data; 55 55 int maxTreeSize = GetVariableValue<IntData>("MaxTreeSize", scope, true).Data; 56 bool balanceTrees = GetVariableValue<BoolData>("BalanceTrees", scope, true).Data;56 double balancedTreesRate = GetVariableValue<DoubleData>("BalancedTreesRate", scope, true).Data; 57 57 int treeSize = GetVariableValue<IntData>("TreeSize", scope, true).Data; 58 58 int treeHeight = GetVariableValue<IntData>("TreeHeight", scope, true).Data; … … 66 66 67 67 // create a new random operator tree 68 IOperator newOperatorTree = gardener.CreateRandomTree(gardener.AllOperators, maxTreeSize, maxTreeHeight, balanceTrees); 68 69 IOperator newOperatorTree; 70 if(random.NextDouble() <= balancedTreesRate) { 71 newOperatorTree = gardener.CreateRandomTree(gardener.AllOperators, maxTreeSize, maxTreeHeight, true); 72 } else { 73 newOperatorTree = gardener.CreateRandomTree(gardener.AllOperators, maxTreeSize, maxTreeHeight, false); 74 } 69 75 70 76 if(!gardener.IsValidTree(newOperatorTree)) { … … 100 106 101 107 // get a random operatorTree 102 IOperator newOperatorTree = gardener.CreateRandomTree(allowedOperators, maxSubTreeSize, maxSubTreeHeight, balanceTrees); 108 IOperator newOperatorTree; 109 if(random.NextDouble() <= balancedTreesRate) { 110 newOperatorTree = gardener.CreateRandomTree(allowedOperators, maxSubTreeSize, maxSubTreeHeight, true); 111 } else { 112 newOperatorTree = gardener.CreateRandomTree(allowedOperators, maxSubTreeSize, maxSubTreeHeight, false); 113 } 103 114 104 115 IOperator oldChild = parent.SubOperators[childIndex]; -
/trunk/sources/HeuristicLab.StructureIdentification/RandomTreeCreator.cs
r20 r30 39 39 AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In)); 40 40 AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size (number of nodes) of the tree", typeof(IntData), VariableKind.In)); 41 AddVariableInfo(new VariableInfo("Balance Trees", "Determines if the trees should be balanced", typeof(BoolData), VariableKind.In));41 AddVariableInfo(new VariableInfo("BalancedTreesRate", "Determines how many trees should be balanced", typeof(DoubleData), VariableKind.In)); 42 42 AddVariableInfo(new VariableInfo("OperatorTree", "The tree to mutate", typeof(IOperator), VariableKind.In)); 43 43 AddVariableInfo(new VariableInfo("TreeSize", "The size (number of nodes) of the tree", typeof(IntData), VariableKind.In)); … … 50 50 int maxTreeHeight = GetVariableValue<IntData>("MaxTreeHeight", scope, true).Data; 51 51 int maxTreeSize = GetVariableValue<IntData>("MaxTreeSize", scope, true).Data; 52 bool balanceTrees = GetVariableValue<BoolData>("BalanceTrees", scope, true).Data;52 double balancedTreesRate = GetVariableValue<DoubleData>("BalancedTreesRate", scope, true).Data; 53 53 54 54 TreeGardener gardener = new TreeGardener(random, opLibrary); … … 56 56 int treeHeight = random.Next(1, maxTreeHeight + 1); 57 57 int treeSize = random.Next(1, maxTreeSize + 1); 58 59 IOperator rootOperator = gardener.CreateRandomTree(treeSize, treeHeight, balanceTrees); 58 IOperator rootOperator; 59 if(random.NextDouble() <= balancedTreesRate) { 60 rootOperator = gardener.CreateRandomTree(treeSize, treeHeight, true); 61 } else { 62 rootOperator = gardener.CreateRandomTree(treeSize, treeHeight, false); 63 } 60 64 61 65 int actualTreeSize = gardener.GetTreeSize(rootOperator); -
/trunk/sources/HeuristicLab.StructureIdentification/Recombination/SinglePointCrossOver.cs
r20 r30 44 44 AddVariableInfo(new VariableInfo("MaxTreeHeight", "The maximal allowed height of the tree", typeof(IntData), VariableKind.In)); 45 45 AddVariableInfo(new VariableInfo("MaxTreeSize", "The maximal allowed size (number of nodes) of the tree", typeof(IntData), VariableKind.In)); 46 AddVariableInfo(new VariableInfo("BalanceTrees", "Determines if the trees should be balanced", typeof(BoolData), VariableKind.In));47 46 AddVariableInfo(new VariableInfo("OperatorTree", "The tree to mutate", typeof(IOperator), VariableKind.In)); 48 47 AddVariableInfo(new VariableInfo("TreeSize", "The size (number of nodes) of the tree", typeof(IntData), VariableKind.In)); -
/trunk/sources/HeuristicLab.StructureIdentification/TreeGardener.cs
r20 r30 96 96 internal IOperator CreateRandomTree(int maxTreeSize, int maxTreeHeight, bool balanceTrees) { 97 97 if (balanceTrees) { 98 if (maxTreeHeight == 1 ) {98 if (maxTreeHeight == 1 || maxTreeSize==1) { 99 99 IOperator selectedTerminal = (IOperator)terminals[random.Next(terminals.Count())].Clone(); 100 100 return selectedTerminal; -
/trunk/sources/HeuristicLab.TestFunctions/HeuristicLab.TestFunctions.csproj
r20 r30 52 52 <ItemGroup> 53 53 <None Include="HeuristicLab.snk" /> 54 <None Include="Properties\AssemblyInfo.frame" /> 54 55 </ItemGroup> 55 56 <ItemGroup> … … 79 80 </Target> 80 81 --> 82 <PropertyGroup> 83 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 84 </PropertyGroup> 81 85 </Project> -
/trunk/sources/HeuristicLab.ThreadParallelEngine/HeuristicLab.ThreadParallelEngine.csproj
r20 r30 57 57 <ItemGroup> 58 58 <None Include="HeuristicLab.snk" /> 59 <None Include="Properties\AssemblyInfo.frame" /> 59 60 </ItemGroup> 60 61 <ItemGroup> … … 76 77 </Target> 77 78 --> 79 <PropertyGroup> 80 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 81 </PropertyGroup> 78 82 </Project> -
/trunk/sources/HeuristicLab.sln
r20 r30 5 5 ProjectSection(SolutionItems) = preProject 6 6 ..\documentation\License\gpl-3.0.txt = ..\documentation\License\gpl-3.0.txt 7 PreBuildEvent.cmd = PreBuildEvent.cmd 7 8 EndProjectSection 8 9 EndProject -
/trunk/sources/HeuristicLab/HeuristicLab.csproj
r20 r30 104 104 <Content Include="Resources\HeuristicLab.ico" /> 105 105 <None Include="app.config" /> 106 <None Include="Properties\AssemblyInfo.frame" /> 106 107 <None Include="Resources\LargeIcons.gif" /> 107 108 <None Include="Resources\Details.gif" /> … … 119 120 <PropertyGroup> 120 121 <PostBuildEvent>cmd /c ..\..\UpdateAssemblies.cmd $(ConfigurationName)</PostBuildEvent> 122 <PreBuildEvent>cmd /c ..\..\..\PreBuildEvent.cmd</PreBuildEvent> 121 123 </PropertyGroup> 122 124 </Project>
Note: See TracChangeset
for help on using the changeset viewer.