/**
* Copyright 2012-2013 University Of Southern California
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/packageorg.workflowsim.planning;importjava.util.ArrayList;importjava.util.Collections;importjava.util.HashMap;importjava.util.List;importjava.util.Map;importorg.cloudbus.cloudsim.Consts;importorg.cloudbus.cloudsim.Log;importorg.workflowsim.CondorVM;importorg.workflowsim.FileItem;importorg.workflowsim.Task;importorg.workflowsim.utils.Parameters;/**
* The HEFT planning algorithm.
*
* @author Pedro Paulo Vezz谩 Campos
* @date Oct 12, 2013
*/publicclassHEFTPlanningAlgorithmextendsBasePlanningAlgorithm{
privateMap<Task,Map<CondorVM,Double>> computationCosts;// 任务Task在某vm上的计算代价时间privateMap<Task,Map<Task,Double>> transferCosts;// 任务与任务间的传输代价时间privateMap<Task,Double> rank;// 任务的“rank”privateMap<CondorVM,List<Event>> schedules;// vm上面的调度事件(一个一个的时间片)privateMap<Task,Double> earliestFinishTimes;// 任务的最早完成时间EFTprivatedouble averageBandwidth;// 平均带宽,此值可用于计算任务到任务的传输代价时间// vm上的一个调度事件(一个时间片)privateclassEvent{
publicdouble start;publicdouble finish;publicEvent(double start,double finish){
this.start = start;this.finish = finish;}}privateclassTaskRankimplementsComparable<TaskRank>{
publicTask task;publicDouble rank;publicTaskRank(Task task,Double rank){
this.task = task;this.rank = rank;}@OverridepublicintcompareTo(TaskRank o){
return o.rank.compareTo(rank);// o.rank比rank大时,返回值为1;等:0;小:-1.}}// 五大初始化publicHEFTPlanningAlgorithm(){
computationCosts =newHashMap<>();
transferCosts =newHashMap<>();
rank =newHashMap<>();
earliestFinishTimes =newHashMap<>();
schedules =newHashMap<>();}/**
* The main function
*/@Overridepublicvoidrun(){