// SAA overrides this method // here we remove scnenarios as we use them to make sure each policy is generated using its own // scenarios. // so we call getIdealBids which uses m_numScenarios most recent scenarios and then remove them so // the next call to getIdealBids gets different scenarios public ArrayList<Bid> getBids() { Misc.myassert(!(numPolicies == 1 && numEvaluations != 0)); ArrayList<Bid>[] policies = new ArrayList[numPolicies]; for (int i = 0; i < numPolicies; i++) { policies[i] = getIdealBids(); repository.removeXMostRecent(numScenarios); } if (numPolicies == 1) return policies[0]; Misc.println("Algorithm.getBids : evaluating more than 1 policies..."); // evaluation scenarios Priceline[] evaluationScenarios = repository.removeXMostRecent(numEvaluations); // evaluate policies int bestPolicy = -1; float bestEvaluation = 0; for (int i = 0; i < numPolicies; i++) { float evaluation = evaluate(policies[i], evaluationScenarios); if (bestPolicy == -1 || evaluation > bestEvaluation) { bestPolicy = i; bestEvaluation = evaluation; } } // this is to make sure we do not generate extra scenarios. // also see the comment at the top of the method: we need to generate enough scenarios otherwise // we won't have enough for all policies - vn Misc.myassert(repository.getAvailableScenarios().length == 0); Misc.println("Algorithm.getBids : best policy = " + bestPolicy); return policies[bestPolicy]; }