void Simulator::execute() {
  Job job1[100] [1000];
  Task task1[100];
  config = readSimulatorConfig();
  Scheduler *scheduler = new Scheduler(config->scheduler_mode,
                                       config->scheduling_interval,
                                       config->scheduling_interval_for_clock,
				       config->percentage_waste
				       );
  //modified Nov-8
  int total_input = 0;
  string strings;
  fstream file("config/input.conf");
  getline(file, strings);
  
  while (file){
    total_input++;
    getline(file, strings);
  }

  
  file.close();
  //modified Nov-8
  
  // set task generator
  Taskgen task_generator = Taskgen(scheduler); 
  
  // read list of workers
  readWorkers(scheduler);
  runWorkers(); // tmp

  scheduler->submitWorkers(workers);

  tasklist = task_generator.create_task(task1, job1, total_input); 
  
  list<Task >::iterator current_task;
  current_task=tasklist.begin();
  
  bool task_generator_stop = false;

  while (true) {
    if (scheduler->areAllJobsCompleted() && task_generator_stop) {
      break;
    }

    // run task generator
    if (currentTime % 1000 == 0) {
      if(task_generator_stop == false) {
	start_pos = task_generator.add_job_list(&(*current_task), 
						current_task->job_rate, 
						start_pos);
	task_generator.send_task();

	if (start_pos == 0)
	  ++current_task;

	if(current_task==tasklist.end())
	  task_generator_stop = true;

      }

    }

    runWorkers();            
    scheduler->runScheduler();
    
    // store values for moving average
    if ((currentTime % 1000) == 0) {
      if ((int)slidingWindow.size() == config->sliding_window) {
        slidingWindow.pop_front();
        slidingWindow.push_back(getWorkerAverages());
      } else {
        slidingWindow.push_back(getWorkerAverages());
      }
    }

    // output values to log
    if ((currentTime % (config->polling_interval*1000)) == 0) {
      logRunningAverage();
    }

    currentTime++;
  }

  scheduler->print();   
  scheduler->gatherStatisticsFromAllWorkers();
  cleanUp();
}