- Timestamp:
- 07/17/11 22:51:11 (13 years ago)
- Location:
- branches/QAPAlgorithms
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/QAPAlgorithms
- Property svn:ignore
-
old new 12 12 *.psess 13 13 *.vsp 14 *.docstates
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/QAPAlgorithms/HeuristicLab.Problems.ExternalEvaluation/3.3/CachedExternalEvaluator.cs
r6189 r6569 20 20 #endregion 21 21 22 23 22 using System.Threading; 24 23 using HeuristicLab.Common; … … 27 26 using HeuristicLab.Parameters; 28 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 29 29 namespace HeuristicLab.Problems.ExternalEvaluation { 30 30 -
branches/QAPAlgorithms/HeuristicLab.Problems.ExternalEvaluation/3.3/Drivers/EvaluationProcessChannel.cs
r5445 r6569 33 33 public class EvaluationProcessChannel : EvaluationChannel { 34 34 35 #region Fields & Properties 35 36 private Process process; 36 37 [Storable] … … 40 41 set { 41 42 if (IsInitialized) throw new InvalidOperationException(Name + ": Cannot change the executable path as the process has already been started."); 42 string oldExecutable = executable;43 if (value == executable) return; 43 44 executable = value; 44 if (!oldExecutable.Equals(executable)) OnExecutableChanged(); 45 UpdateName(); 46 OnExecutableChanged(); 45 47 } 46 48 } … … 51 53 set { 52 54 if (IsInitialized) throw new InvalidOperationException(Name + ": Cannot change the arguments as the process has already been started."); 53 string oldArguments = arguments;55 if (value == arguments) return; 54 56 arguments = value; 55 if (!oldArguments.Equals(arguments)) OnArgumentsChanged(); 57 UpdateName(); 58 OnArgumentsChanged(); 56 59 } 57 60 } 58 61 private EvaluationStreamChannel streamingChannel; 62 #endregion 59 63 64 #region Construction & Cloning 60 65 [StorableConstructor] 61 66 protected EvaluationProcessChannel(bool deserializing) : base(deserializing) { } … … 64 69 executable = original.executable; 65 70 arguments = original.arguments; 71 UpdateName(); 66 72 } 67 73 public override IDeepCloneable Clone(Cloner cloner) { … … 74 80 this.executable = executable; 75 81 this.arguments = arguments; 82 UpdateName(); 76 83 } 84 [StorableHook(HookType.AfterDeserialization)] 85 private void AfterDeserialization() { 86 UpdateName(); 87 } 88 #endregion 77 89 78 90 #region IExternalEvaluationChannel Members 79 80 91 public override void Open() { 81 92 if (!String.IsNullOrEmpty(executable.Trim())) { … … 175 186 } 176 187 #endregion 188 189 #region Auxiliary Methods 190 private void UpdateName() { 191 name = string.Format("ProcessChannel {0} {1}", Path.GetFileNameWithoutExtension(executable), arguments); 192 OnNameChanged(); 193 } 194 #endregion 177 195 } 178 196 } -
branches/QAPAlgorithms/HeuristicLab.Problems.ExternalEvaluation/3.3/Drivers/EvaluationServiceClient.cs
r5445 r6569 31 31 [StorableClass] 32 32 public class EvaluationServiceClient : ParameterizedNamedItem, IEvaluationServiceClient { 33 33 34 public override bool CanChangeName { get { return false; } } 34 35 public override bool CanChangeDescription { get { return false; } } 35 36 37 #region Parameters 36 38 public IValueParameter<IEvaluationChannel> ChannelParameter { 37 39 get { return (IValueParameter<IEvaluationChannel>)Parameters["Channel"]; } … … 44 46 get { return ChannelParameter.Value; } 45 47 } 48 #endregion 46 49 47 50 51 #region Construction & Cloning 48 52 [StorableConstructor] 49 53 protected EvaluationServiceClient(bool deserializing) : base(deserializing) { } 50 protected EvaluationServiceClient(EvaluationServiceClient original, Cloner cloner) : base(original, cloner) { }51 public override IDeepCloneable Clone(Clonercloner) {52 return new EvaluationServiceClient(this, cloner);54 protected EvaluationServiceClient(EvaluationServiceClient original, Cloner cloner) 55 : base(original, cloner) { 56 RegisterEvents(); 53 57 } 54 58 public EvaluationServiceClient() … … 56 60 Parameters.Add(new ValueParameter<IEvaluationChannel>("Channel", "The channel over which to call the remote function.")); 57 61 Parameters.Add(new ValueParameter<IntValue>("Retry", "How many times the client should retry obtaining a quality in case there is an exception. Note that it immediately aborts when the channel cannot be opened.", new IntValue(10))); 62 RegisterEvents(); 58 63 } 64 public override IDeepCloneable Clone(Cloner cloner) { 65 return new EvaluationServiceClient(this, cloner); 66 } 67 [StorableHook(HookType.AfterDeserialization)] 68 private void AfterDeserialization() { 69 ChannelParameter_ValueChanged(this, EventArgs.Empty); 70 RegisterEvents(); 71 } 72 #endregion 59 73 60 74 #region IEvaluationServiceClient Members 61 62 75 public QualityMessage Evaluate(SolutionMessage solution) { 63 76 int tries = 0, maxTries = RetryParameter.Value.Value; … … 71 84 result = (QualityMessage)Channel.Receive(QualityMessage.CreateBuilder()); 72 85 success = true; 73 } 74 catch (InvalidOperationException) { 86 } catch (InvalidOperationException) { 75 87 throw; 76 } 77 catch { 88 } catch { 78 89 if (tries >= maxTries) 79 90 throw; … … 92 103 Channel.Send(solution); 93 104 success = true; 94 } 95 catch (InvalidOperationException) { 105 } catch (InvalidOperationException) { 96 106 throw; 97 } 98 catch { 107 } catch { 99 108 if (tries >= maxTries) 100 109 throw; … … 103 112 System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(ReceiveAsync), callback); 104 113 } 105 106 114 #endregion 107 115 116 #region Auxiliary Methods 108 117 private void CheckAndOpenChannel() { 109 118 if (Channel == null) throw new InvalidOperationException(Name + ": The channel is not defined."); … … 111 120 try { 112 121 Channel.Open(); 113 } 114 catch (Exception e) { 122 } catch (Exception e) { 115 123 throw new InvalidOperationException(Name + ": The channel could not be opened.", e); 116 124 } … … 122 130 try { 123 131 message = (QualityMessage)Channel.Receive(QualityMessage.CreateBuilder()); 124 } 125 catch { } 132 } catch { } 126 133 ((Action<QualityMessage>)callback).Invoke(message); 127 134 } 135 136 private void RegisterEvents() { 137 ChannelParameter.ValueChanged += new EventHandler(ChannelParameter_ValueChanged); 138 } 139 140 void ChannelParameter_ValueChanged(object sender, EventArgs e) { 141 if (ChannelParameter.Value == null) 142 name = "Empty EvaluationServiceClient"; 143 else 144 name = String.Format("{0} ServiceClient", ChannelParameter.Value.Name); 145 OnNameChanged(); 146 } 147 #endregion 128 148 } 129 149 } -
branches/QAPAlgorithms/HeuristicLab.Problems.ExternalEvaluation/3.3/Drivers/EvaluationTCPChannel.cs
r5445 r6569 32 32 [StorableClass] 33 33 public class EvaluationTCPChannel : EvaluationChannel { 34 34 35 public const int MAX_VARINT32_SIZE = 5; 35 36 37 #region Fields & Properties 36 38 [Storable] 37 39 private string ipAddress; … … 39 41 get { return ipAddress; } 40 42 set { 41 bool changed = !ipAddress.Equals(value);43 if (value == ipAddress) return; 42 44 ipAddress = value; 43 if (changed)44 45 UpdateName(); 46 OnIpAddressChanged(); 45 47 } 46 48 } … … 50 52 get { return port; } 51 53 set { 52 bool changed = port != value;54 if (value == port) return; 53 55 port = value; 54 if (changed)55 56 UpdateName(); 57 OnPortChanged(); 56 58 } 57 59 } 58 60 private Socket socket; 59 61 #endregion 62 63 #region Construction & Cloning 60 64 [StorableConstructor] 61 65 protected EvaluationTCPChannel(bool deserializing) : base(deserializing) { } … … 64 68 ipAddress = original.ipAddress; 65 69 port = original.port; 66 } 70 UpdateName(); 71 } 72 67 73 public override IDeepCloneable Clone(Cloner cloner) { 68 74 return new EvaluationTCPChannel(this, cloner); … … 74 80 this.ipAddress = ip; 75 81 this.port = port; 76 } 82 UpdateName(); 83 } 84 [StorableHook(HookType.AfterDeserialization)] 85 private void AfterDeserialization() { 86 UpdateName(); 87 } 88 #endregion 89 90 77 91 78 92 #region IExternalEvaluationChannel Members … … 183 197 #endregion 184 198 199 #region Auxiliary Methods 200 private void UpdateName() { 201 name = string.Format("TCPChannel {0}:{1}", ipAddress, port); 202 OnNameChanged(); 203 } 204 #endregion 205 185 206 #region Events 186 207 public event EventHandler IpAddressChanged; -
branches/QAPAlgorithms/HeuristicLab.Problems.ExternalEvaluation/3.3/EvaluationCache.cs
r6291 r6569 25 25 using System; 26 26 using System.Collections.Generic; 27 using System.Globalization; 28 using System.IO; 27 29 using System.Linq; 30 using System.Text.RegularExpressions; 28 31 using System.Threading; 29 32 using HeuristicLab.Common; … … 33 36 using HeuristicLab.Parameters; 34 37 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 35 using HeuristicLab.Analysis; 36 using System.IO; 37 using System.Globalization; 38 using System.Text.RegularExpressions; 38 39 39 namespace HeuristicLab.Problems.ExternalEvaluation { 40 40 … … 82 82 83 83 private HashSet<string> activeEvaluations = new HashSet<string>(); 84 private object cacheLock = new object(); 84 private object cacheLock = new object(); 85 85 #endregion 86 86 … … 126 126 127 127 #region Persistence 128 [Storable(Name ="Cache")]128 [Storable(Name = "Cache")] 129 129 private IEnumerable<KeyValuePair<string, double>> Cache_Persistence { 130 130 get { … … 194 194 bool lockTaken = false; 195 195 bool waited = false; 196 try { 196 try { 197 197 Monitor.Enter(cacheLock, ref lockTaken); 198 198 while (true) { -
branches/QAPAlgorithms/HeuristicLab.Problems.ExternalEvaluation/3.3/ExternalEvaluator.cs
r6189 r6569 60 60 protected HashSet<IEvaluationServiceClient> activeClients = new HashSet<IEvaluationServiceClient>(); 61 61 protected object clientLock = new object(); 62 protected AutoResetEvent clientAvailable = new AutoResetEvent(false);63 62 #endregion 64 63 … … 109 108 client = Clients.CheckedItems.FirstOrDefault(c => !activeClients.Contains(c)); 110 109 while (client == null && Clients.Count > 0) { 111 Monitor.Exit(clientLock); 112 clientAvailable.WaitOne(); 113 Monitor.Enter(clientLock); 110 Monitor.Wait(clientLock); 114 111 client = Clients.CheckedItems.FirstOrDefault(c => !activeClients.Contains(c)); 115 112 } … … 122 119 lock (clientLock) { 123 120 activeClients.Remove(client); 124 clientAvailable.Set();121 Monitor.PulseAll(clientLock); 125 122 } 126 123 } -
branches/QAPAlgorithms/HeuristicLab.Problems.ExternalEvaluation/3.3/HeuristicLabProblemsExternalEvaluationPlugin.cs.frame
r6099 r6569 23 23 24 24 namespace HeuristicLab.Problems.ExternalEvaluation { 25 [Plugin("HeuristicLab.Problems.ExternalEvaluation", "3.3. 4.$WCREV$")]25 [Plugin("HeuristicLab.Problems.ExternalEvaluation", "3.3.5.$WCREV$")] 26 26 [PluginFile("HeuristicLab.Problems.ExternalEvaluation-3.3.dll", PluginFileType.Assembly)] 27 27 [PluginDependency("HeuristicLab.Analysis", "3.3")] -
branches/QAPAlgorithms/HeuristicLab.Problems.ExternalEvaluation/3.3/Interfaces/IEvaluationChannel.cs
r5445 r6569 24 24 25 25 namespace HeuristicLab.Problems.ExternalEvaluation { 26 public interface IEvaluationChannel : I Item {26 public interface IEvaluationChannel : INamedItem { 27 27 /// <summary> 28 28 /// A flag that describes whether the channel has been initialized or not. -
branches/QAPAlgorithms/HeuristicLab.Problems.ExternalEvaluation/3.3/Properties/AssemblyInfo.frame
r6099 r6569 34 34 // [assembly: AssemblyVersion("1.0.*")] 35 35 [assembly: AssemblyVersion("3.3.0.0")] 36 [assembly: AssemblyFileVersion("3.3. 4.$WCREV$")]36 [assembly: AssemblyFileVersion("3.3.5.$WCREV$")]
Note: See TracChangeset
for help on using the changeset viewer.