public void run() { double budget = 50; Optimiser optimiser = new Optimiser(); // Instantiate optimiser class ScenarioGenerator scenGen = new ScenarioGenerator(5, 20); // Instantiate ScenarioGenerator class OptimisedBidder OptimisedBidder = new OptimisedBidder("OptimisedBidder", budget); // Instantiate OptimisedBidder class scenGen.createItemAndAuction(); // Create items and auctions scenGen.createBidders(); // Create bidders scenGen.passAuctionsToBidders(); // Pass list of generated auctions to all simulated bidders OptimisedBidder.setAuctions( scenGen.getAuctions()); // Pass list of generated auctions to OptimisedBidder OptimisedBidder.setOptimiser(optimiser); // Pass optimiser to OptimisedBidder OptimisedBidder.setScenarioGenerator(scenGen); // Pass scenGen to OptimisedBidder scenGen .printItemsUtility(); // Prints a list of all items created by the scenario generator, the // current high bid on that item and it's resultant utility System.out.println("Simulation started at: " + time()); try { OptimisedBidder.activate(); // Activate OptimisedBidder thread for (int i = 0; i < scenGen.getBidders().size(); i++) { // Activate bidder threads (i.e. set them to active, wakeup now and add them to the // queue Bidder bidder = scenGen.getBidders().get(i); bidder.activate(); } Scheduler.startSimulation(); // Start simulation hold(50); SimulationProcess.mainResume(); // Resume main thread } catch (SimulationException e) { e.printStackTrace(); } catch (RestartException e) { e.printStackTrace(); } System.out.println("Simulation ended at: " + time()); printResults(scenGen.getBidders(), scenGen.getAuctions(), OptimisedBidder); System.exit(0); }
public void await() { this.resumeProcess(); SimulationProcess.mainSuspend(); }