Esempio n. 1
0
 public Environment(BufferedGraphics g, ImageList newEntities, int size, int newIterations, int newDuration)
 {
     rnd = new Random(System.Environment.TickCount);
       stats = new Dictionary<STATISTIC, double>();
       results = new List<string>();
       messageQueue = new MessageQueue();
       Environment a = this;
       executionTree = new ExecutionTree(ref a);
       entities = newEntities;
       device = g;
       WorkerSupportsCancellation = true;
       speed = 5;
       // Determine the percent chance that a new agent will be introduced into the environment.
       // The higher the chance the more likely the size of the population will be larger.
       if (size == 0)
     populationSize = 0.10;
       else if (size == 1)
     populationSize = 0.25;
       else if (size == 2)
     populationSize = 0.50;
       // Set the run parameters
       iterations = newIterations;
       duration = newDuration * 60;
       timer = new TimeSpan();
 }
Esempio n. 2
0
        private ExecutionTree tree; // Execution tree for the current run.

        #endregion Fields

        #region Constructors

        public Controller(ref Environment environment, ref MessageQueue messages, Image image, Graphics g)
            : base(ref environment, ref messages, new PointF(g.VisibleClipBounds.Width - 16, 0), 0, image, g)
        {
            Reset();
              // Log agent creation
              manager = this;
              // Create a new broadcast message (Inform)
              Message aMessage = new InformMessage(this);
              messageQueue.Broadcast(aMessage);
              ImageKey = "cpu.png";
              SelectedImageKey = "cpu.png";
              type = AGENT_TYPE.AGENT_CONTROLLER;
              tree = environment.Execution;
        }
Esempio n. 3
0
 public void New()
 {
     if (agents != null && agents.Count > 0) {
     while (agents.Count > 0) {
       Agent agent = agents[agents.Count - 1];
       RemoveAgent(agent);
     }
       }
       agents = new List<Agent>();
       Environment a = this;
       messageQueue = new MessageQueue();
       if (executionTree == null)
     executionTree = new ExecutionTree(ref a);
       Agent operatorAgent = AddNewAgent(AGENT_TYPE.AGENT_OPERATOR, entities.Images[(int)AGENT_TYPE.AGENT_OPERATOR]);
       operatorAgent.Name = "Operator";
       Agent controllerAgent = AddNewAgent(AGENT_TYPE.AGENT_CONTROLLER, entities.Images[(int)AGENT_TYPE.AGENT_CONTROLLER]);
       controllerAgent.Name = "Controller";
       timer = new TimeSpan();
       stats = new Dictionary<STATISTIC, double>();
       stats.Add(STATISTIC.STOCKPRODUCED, 0);
       stats.Add(STATISTIC.STOCKSENT, 0);
       stats.Add(STATISTIC.STOCKLOST, 0);
       stats.Add(STATISTIC.STOCKDELIVERED, 0);
       stats.Add(STATISTIC.STOCKDELIVEREDUSED, 0);
       stats.Add(STATISTIC.STOCKDELIVEREDLOST, 0);
       stats.Add(STATISTIC.PRODUCTPRODUCED, 0);
       stats.Add(STATISTIC.PRODUCTPRODUCEDUSED, 0);
       stats.Add(STATISTIC.PRODUCTPRODUCEDLOST, 0);
       stats.Add(STATISTIC.PRODUCTDELIVERED, 0);
       totAgents = 0;
       readings = 0;
 }