public MainWindow() { InitializeComponent(); _agents = new Agents(); _agents.Add(new Agent("001", "Tom", "Street", "Guns", "Die")); _agents.Add(new Agent("002", "Anni", "Street", "Fly", "Die")); _agents.Add(new Agent("003", "Nian", "Street", "Swim", "Win In Life")); DataContext = _agents; }
public MainWindow() { InitializeComponent(); agents.Add(new Agent() { ID = "001", CodeName = "Nina", Speciality = "Assassination", Assignment = "UpperVolta" }); agents.Add(new Agent("007", "James Bond", "Martinis", "North Korea")); agentGrid.DataContext = agents; }
public MainWindow() { InitializeComponent(); Agent james = new Agent("007", "James Bond", "Spyville 20", "Seducing women", "Halle Barry"); Agent simon = new Agent("8210", "Simon Vu", "DK", "Reading Chinese letters", "procrastination"); _data.Add(james); _data.Add(simon); DataContext = _data; }
public void AgentConnect(string name) { if (ChatSessions == null) { ChatSessions = new ConcurrentDictionary <string, string>(); } var agent = new Agent() { Id = Context.ConnectionId, Name = name, IsOnline = true }; if (!Agents.ContainsKey(agent.Id)) { Agents.Add(agent.Id, agent); } else { Agents[agent.Id] = agent; } Clients.Caller.loginResult(true, agent.Id, agent.Name); Clients.All.onlineStatus(Agents.Values.Count(x => x.IsOnline) > 0); }
public void Initialize(FitnessFunction func, int dim = 2, int iterations = 100000, int scoutsCount = 10, int bestAgentsCount = 5, int eliteAgentsCount = 2, int bestPatchesCount = 3, int elitePatchesCount = 2, double patchSize = 1) { PatchSize = patchSize; Size = scoutsCount + bestAgentsCount * bestPatchesCount + eliteAgentsCount * elitePatchesCount; Iterations = iterations; BestAgentsCount = bestAgentsCount; EliteAgentsCount = eliteAgentsCount; BestPatchesCount = bestPatchesCount; ElitePatchesCount = elitePatchesCount; FitFunction = FitnessFunctions.RosenbrocsSaddle; Dimension = dim; CurrentIteration = 0; Fitness = Double.MaxValue; Position = new Point(dim); PrevAverageFitness = double.MaxValue; // first agents initialization for (int i = 0; i < scoutsCount; i++) { Agents.Add(new Agent(Agent.RoleTypes.Scout)); } for (int i = 0; i < bestAgentsCount * bestPatchesCount; i++) { Agents.Add(new Agent(Agent.RoleTypes.Employed)); } for (int i = 0; i < eliteAgentsCount * elitePatchesCount; i++) { Agents.Add(new Agent(Agent.RoleTypes.Onlooker)); } AverageFitness = Agents.Where(a => a.Role != Agent.RoleTypes.Scout).Sum(a => a.Fitness) / (Size - BestAgentsCount); }
public DifferentialEvolution(int dimensions, int numberOfAgents, double[] upperBounds, double[] lowerBounds, Func <double[], double> FitnessCalculator, Func <double, bool> TargetReached, double CrossoverProbablity = 0.9, double DifferentialWeight = 0.8) { if (dimensions < 1) { throw new ArgumentException("You should at least have 1 dimension"); } if (numberOfAgents < 4) { throw new ArgumentException("Number of agents should be at least 4."); throw new ArgumentException("Number of agents should be at least 4."); } if (DifferentialWeight > 2 || DifferentialWeight < 0) { throw new ArgumentException("Differential weight should be between 0 and 2"); } if (CrossoverProbablity > 1 || CrossoverProbablity < 0) { throw new ArgumentException("Crossover Probability should be between 0 and 1"); } this.dimensions = dimensions; for (int i = 0; i < numberOfAgents; i++) { Agents.Add(new Agent(dimensions, random, upperBounds, lowerBounds)); } this.FitnessCalculator = FitnessCalculator; this.TargetReached = TargetReached; this.DifferentialWeight = DifferentialWeight; this.CrossoverProbablity = CrossoverProbablity; }
private void PopulateAgentsAndParticipants() { foreach (agentType agent in _monitoringChannel.Agents) { MonitoredAgentViewModel avm = CreateAgentViewModel(agent); Agents.Add(avm); } foreach (participantType participant in _monitoringChannel.Participants) { ParticipantViewModel pvm = CreateParticipantViewModel(participant); Participants.Add(pvm); } foreach (participantType customer in _monitoringChannel.Customers) { ParticipantViewModel pvm = CreateParticipantViewModel(customer); Customers.Add(pvm); } if (Agents.Count > 0 || Customers.Count > 0 || Participants.Count > 0) { IsMonitoringReady = true; } }
// Creates the agents of the game. public void CreateAgents() { GameObject piece = null; Rendezvous = Children.First().Value.Location; Instantiate(rendezvousPrefab, Rendezvous.ToVector(), Quaternion.identity); int i = 0; foreach (ChildAgent agt in Children.Values) { piece = Instantiate(childPrefabs[i], agt.Location.ToVector(), Quaternion.identity); agt.Piece = piece.GetComponent <AgentPiece>(); AgentPieces.Add(agt.ID, piece); Agents.Add(agt.ID, agt); i++; } if (!ReferenceEquals(Cat, null)) { piece = Instantiate(catPrefab, Cat.Location.ToVector(), Quaternion.identity); Cat.Piece = piece.GetComponent <AgentPiece>(); Cat.Piece.clothsRnderer.color = Color.black; AgentPieces.Add(Cat.ID, piece); Agents.Add(Cat.ID, Cat); } }
public ServerAgent(Uri uri, Gateway gateway, int maxConnections = 100) { Uri = uri; UriKey = uri.ToString(); ServerName = uri.ToString(); ServerID = GetServerID(); Host = uri.Host; Port = uri.Port; Available = false; MaxConnections = maxConnections; Gateway = gateway; requestAgentsPool = new ConcurrentQueue <TcpClientAgent>(); mWaitQueue = new ConcurrentQueue <TaskCompletionSource <TcpClientAgent> >(); for (int i = 0; i < 10; i++) { var item = new TcpClientAgent(Host, Port); requestAgentsPool.Enqueue(item); Agents.Add(item); } mConnections = 10; mCount = 10; Statistics.Server = ServerName; this.Available = false; mQueueWaitMaxLength = gateway.AgentRequestQueueSize; }
public MainWindowViewModel() { Agents.Add(new Agent("0022", "Kusken", "KBU", "Herning")); Agents.Add(new Agent("0028", "Fisken", "Studere", "Aarhus")); //DataContext = Agents; }
public ServerAgent(Uri uri, Gateway gateway, int maxConnections = 100) { Uri = uri; UriKey = uri.ToString(); ServerName = uri.ToString(); ServerID = GetServerID(); Host = uri.Host; Port = uri.Port; Available = false; MaxConnections = maxConnections; Gateway = gateway; requestAgentsPool = new ConcurrentQueue <TcpClientAgent>(); mWaitQueue = new ConcurrentQueue <TaskCompletionSource <TcpClientAgent> >(); for (int i = 0; i < 10; i++) { var item = new TcpClientAgent(Host, Port); requestAgentsPool.Enqueue(item); Agents.Add(item); } mConnections = 10; mCount = 10; Statistics.Server = ServerName; this.Available = false; mQueueWaitMaxLength = gateway.AgentRequestQueueSize; string protocol = Uri.Scheme.ToLower(); WebSocket = (protocol == "ws" || protocol == "wss"); mWSClient = GetWSClient(); AddressHeader = Encoding.ASCII.GetBytes("Logic-Server: " + ServerName + "\r\n"); }
private async void MainViewModel_AgentsChanged(object sender, EventArgs e) { var response = await client.GetAsync($"{serverUrl}api/Agent"); if (!response.IsSuccessStatusCode) { MessageBox.Show(response.StatusCode.ToString()); return; } string responseBody = await response.Content.ReadAsStringAsync(); foreach (var item in JsonConvert.DeserializeObject <AgentsList>(responseBody).Agents) { Agents.Add(new Agent() { Id = item.Id, Endpoint = item.Endpoint, OsType = item.OsType, AgentVersion = item.AgentVersion, IsEnabled = item.IsEnabled }); } if (Agents.Any()) { SelectedAgent = Agents.First(); } }
internal Task <TcpClientAgent> PopClient() { TcpClientAgent tcpClientAgent; TaskCompletionSource <TcpClientAgent> result = new TaskCompletionSource <TcpClientAgent>(); if (requestAgentsPool.TryDequeue(out tcpClientAgent)) { result.SetResult(tcpClientAgent); } else { if (mConnections > MaxConnections) { if (mWaitLength < mQueueWaitMaxLength) { System.Threading.Interlocked.Increment(ref mWaitLength); mWaitQueue.Enqueue(result); } else { result.SetResult(null); } } else { System.Threading.Interlocked.Increment(ref mConnections); tcpClientAgent = new TcpClientAgent(Host, Port); lock (Agents) Agents.Add(tcpClientAgent); result.SetResult(tcpClientAgent); } } return(result.Task); }
private async void GetAgentData() { var agentData = await AgentAPI.GetAgentData(); if (agentData != null) { foreach (var agent in agentData) { if (!Agents.Any(a => a.AgentId.Equals(agent.Metadata.AgentID, StringComparison.OrdinalIgnoreCase))) { Agents.Add(new Agent { AgentId = agent.Metadata.AgentID, Hostname = agent.Metadata.Hostname, IpAddress = agent.Metadata.IPAddress, Identity = agent.Metadata.Identity, ProcessName = agent.Metadata.ProcessName, ProcessId = agent.Metadata.ProcessID, Arch = agent.Metadata.Arch.ToString(), CLR = agent.Metadata.CLR, Integrity = agent.Metadata.Integrity.ToString(), AgentModules = agent.LoadModules, LastSeen = Helpers.CalculateTimeDiff(agent.LastSeen) }); } else { Agents.FirstOrDefault(a => a.AgentId.Equals(agent.Metadata.AgentID, StringComparison.OrdinalIgnoreCase)) .Hostname = agent.Metadata.Hostname; Agents.FirstOrDefault(a => a.AgentId.Equals(agent.Metadata.AgentID, StringComparison.OrdinalIgnoreCase)) .IpAddress = agent.Metadata.IPAddress; Agents.FirstOrDefault(a => a.AgentId.Equals(agent.Metadata.AgentID, StringComparison.OrdinalIgnoreCase)) .Identity = agent.Metadata.Identity; Agents.FirstOrDefault(a => a.AgentId.Equals(agent.Metadata.AgentID, StringComparison.OrdinalIgnoreCase)) .ProcessName = agent.Metadata.ProcessName; Agents.FirstOrDefault(a => a.AgentId.Equals(agent.Metadata.AgentID, StringComparison.OrdinalIgnoreCase)) .ProcessId = agent.Metadata.ProcessID; Agents.FirstOrDefault(a => a.AgentId.Equals(agent.Metadata.AgentID, StringComparison.OrdinalIgnoreCase)) .Arch = agent.Metadata.Arch.ToString(); Agents.FirstOrDefault(a => a.AgentId.Equals(agent.Metadata.AgentID, StringComparison.OrdinalIgnoreCase)) .CLR = agent.Metadata.CLR; Agents.FirstOrDefault(a => a.AgentId.Equals(agent.Metadata.AgentID, StringComparison.OrdinalIgnoreCase)) .Integrity = agent.Metadata.Integrity.ToString(); Agents.FirstOrDefault(a => a.AgentId.Equals(agent.Metadata.AgentID, StringComparison.OrdinalIgnoreCase)) .AgentModules = agent.LoadModules; Agents.FirstOrDefault(a => a.AgentId.Equals(agent.Metadata.AgentID, StringComparison.OrdinalIgnoreCase)) .LastSeen = Helpers.CalculateTimeDiff(agent.LastSeen); } } } }
private void btnAddNew_Click(object sender, RoutedEventArgs e) { Agents agents = (Agents)this.FindResource("agents"); agents.Add(new Agent(null, "New Agent", null, null, null)); lstAgents.SelectedIndex = lstAgents.Items.Count - 1; tbxId.Focus(); }
/// <summary> /// Clear agents between two iterations /// </summary> public void Clear() { State = AgentState.Starting; Agents.Clear(); StoppedAgents.Clear(); _agentsReference.ForEach(x => Agents.Add(x)); //todo => _agentsReference.ForEach(x => Agents.Add(x.Clone())); and change SetAGents }
/// <summary> /// Default Constructors. Registers to the <see cref="EventAggregator"/> for the appropriate events. /// </summary> public AgentViewModel() { _eventAggregator = EventAggregatorSingleton.Instance; _eventAggregator.GetEvent <RequestAgentsListEvent>().Subscribe(RespondToAgentsListRequest); _eventAggregator.GetEvent <RequestCurrentAgentEvent>().Subscribe(RespondToCurrentAgentRequest); _eventAggregator.GetEvent <UpdateAgentsListsEvent>().Subscribe(a => Agents = a); _eventAggregator.GetEvent <ResetAgentsEvent>().Subscribe(ResetAgents); _eventAggregator.GetEvent <AddAgentCommand>().Subscribe(a => Agents.Add(a)); }
private void SpawnFarmer() { AgentEntity farmer = new AgentEntity("Farmer" + String.Format("{0:D3}", AgentTypeCount[AgentEntity.EntityType.farmer]), AgentEntity.EntityType.farmer); farmer.Town = this; farmer.AddResource(ResourceUtil.Wheat, InventoryItem.ActionType.sell, 10, 0); farmer.AddResource(ResourceUtil.Wood, InventoryItem.ActionType.buy, 10, 5, 2); farmer.AddResource(ResourceUtil.Tools, InventoryItem.ActionType.buy, 10, 2, 1); Agents.Add(farmer); }
private void Init(Encoding encoding) { for (var i = 1; i < EngineCnt; i++) { var agt = new EngineAgent(); agt.Initialise(i, TgtLoc, encoding); Agents.Add(agt); } _init = true; }
public void load() { foreach (var item in Useful.PricingOptions) { Useful2 newo = new Useful2(); newo.Price = $"{item.Price} $"; newo.DeeplinkUrl = item.DeeplinkUrl; newo.Agent = ag.First(itemm => itemm.Id == item.Agents[0]); Agents.Add(newo); } }
public static void CreateCollection() { using (Context db = new Context()) { var result = db.Agents.Where(c => !c.isDeleted); foreach (var c in result) { Agents.Add(c); } } }
private void SpawnWoodcutter() { AgentEntity woodcutter = new AgentEntity("Woodcutter" + String.Format("{0:D3}", AgentTypeCount[AgentEntity.EntityType.woodcutter]), AgentEntity.EntityType.woodcutter); woodcutter.Town = this; woodcutter.AddResource(ResourceUtil.Wood, InventoryItem.ActionType.sell, 10, 0); woodcutter.AddResource(ResourceUtil.Wheat, InventoryItem.ActionType.buy, 10, 4, 1); woodcutter.AddResource(ResourceUtil.Tools, InventoryItem.ActionType.buy, 10, 2, 1); Agents.Add(woodcutter); }
/// <summary> /// Add a agent to the data set. /// </summary> /// <param name="agent">The agent to be added.</param> public void AddAgent(Gx.Agent.Agent agent) { if (agent != null) { if (Agents == null) { Agents = new List <Gx.Agent.Agent>(); } Agents.Add(agent); } }
private void SpawnBlacksmith() { AgentEntity blacksmith = new AgentEntity("Blacksmith" + String.Format("{0:D3}", AgentTypeCount[AgentEntity.EntityType.blacksmith]), AgentEntity.EntityType.blacksmith); blacksmith.Town = this; blacksmith.AddResource(ResourceUtil.Tools, InventoryItem.ActionType.sell, 10, 0); blacksmith.AddResource(ResourceUtil.Wheat, InventoryItem.ActionType.buy, 10, 4, 2); blacksmith.AddResource(ResourceUtil.Metal, InventoryItem.ActionType.buy, 10, 4, 4); Agents.Add(blacksmith); }
private void Init(Encoding encoding) { for (var i = 1; i < EngineCnt; i++) { var agt = new EngineAgent <LocationAgent <TS, TE, TV> >(); agt.Initialise(i, encoding, GetGeoLocatedOnly); Agents.Add(agt); } _init = true; }
private void PopulateAgents() { foreach (agentType agent in Model.Agents) { SupervisedAgentViewModel avm = CreateAgentViewModel(agent); avm.PropertyChanged += AvmPropertyChanged; avm.Monitored += AvmMonitored; Agents.Add(avm); } }
public void RegisterClientAsAgent(ulong clientId, string message) { var client = JoiningAgents.Where(q => q.ID == clientId).FirstOrDefault(); JoiningAgents.Remove(client); client.MessageInterpreter = new AgentInterpreter(this); var agent = new AGENT(client); Agents.Add(agent); client.BeginSend(message); }
private void SpawnSmelter() { AgentEntity smelter = new AgentEntity("Smelter" + String.Format("{0:D3}", AgentTypeCount[AgentEntity.EntityType.smelter]), AgentEntity.EntityType.smelter); smelter.Town = this; smelter.AddResource(ResourceUtil.Metal, InventoryItem.ActionType.sell, 10, 0); smelter.AddResource(ResourceUtil.Ore, InventoryItem.ActionType.buy, 10, 4, 4); smelter.AddResource(ResourceUtil.Wheat, InventoryItem.ActionType.buy, 10, 4, 2); smelter.AddResource(ResourceUtil.Tools, InventoryItem.ActionType.buy, 10, 2, 1); Agents.Add(smelter); }
public void AddAgent(AgentConnection agent) { agent.Session = this; agent.OnOpen += () => ConnectionOpen(agent); agent.OnClose += () => ConnectionClose(agent); agent.OnConnectionError += (message) => ConnectionError(agent, message); agent.OnMessage += (payload) => MessageReceived(agent, payload); if (!Agents.ContainsKey(agent.Address)) { Agents.Add(agent.Address, agent); } }
public void AddOrUpdateAgent(Agent agent) { var existingAgent = Agents.FirstOrDefault(r => r.Id == agent.Id); if (existingAgent != null) { existingAgent.Status = agent.Status; } else { Agents.Add(agent); } }