package paysim; import java.util.ArrayList; public class CurrentStepHandler { private ArrayList stepHandler = new ArrayList<>(); private ArrayList stepCountCombination = new ArrayList<>(); private ArrayList fileContents = new ArrayList(); private ArrayList stepsThatAreNotAllowed = new ArrayList(); private ArrayList aggrRecordList = new ArrayList(); private double multiplier = 0; public CurrentStepHandler(ArrayList fileContents, double mult){ setFileContents(fileContents); for(int i=0; i<744; i++){ CurrentStepContainer container = new CurrentStepContainer(); container.setCounter(0); container.setCurrentStep(i); stepHandler.add(container); } //initStepsNotAllowed(); initStepCountCombination(); modifyWithMultiplier(mult); this.initAggregateRecordList(); } private void initAggregateRecordList(){ for(String s: this.fileContents){ String splitted[] = s.split(","); AggregateTransactionRecord record = new AggregateTransactionRecord(); record.setType(splitted[0]); record.setMonth(splitted[1]); record.settDay(splitted[2]); record.settHour(splitted[3]); record.settCount(splitted[4]); record.settSum(splitted[5]); record.settAvg(splitted[6]); record.settStd(splitted[7]); this.aggrRecordList.add(record); } } public AggregateTransactionRecord getRecord(String type, int day, int hour){ for(AggregateTransactionRecord t: this.aggrRecordList){ if(t.getType().equals(type) && t.gettDay().equals(String.valueOf(day)) && t.gettHour().equals(String.valueOf(hour))){ return t; } } return null; } private void modifyWithMultiplier(double mult){ for(int i=0; i origCount){ stepsThatAreNotAllowed.add((int) step); ////sytemout.println("Size of steps not allowed:\t" + stepsThatAreNotAllowed.size() + "Adding: " + step + "\n"); return true; }else{ return false; } } public void setFileContents(ArrayList contents){ this.fileContents = contents; } private boolean isInParamFile(long day, long hour){ for(int i=1; i getSteps(long currentStep, long nrOfSteps){ ArrayList stepsToBeRepeated = new ArrayList(); int stepsGathered = 0; long index = 0; while(stepsGathered < nrOfSteps){ index = index % this.stepHandler.size(); if(index == 0){ if(this.isFull(currentStep)){ return null; } } ////sytemout.println(index + "\n"); CurrentStepContainer gottenOne = this.stepHandler.get((int) index); if(gottenOne.canBeReduced() && gottenOne.getCurrentStep()>= currentStep) { this.stepHandler.get((int) index).increment(); stepsToBeRepeated.add(gottenOne.getCurrentStep()); stepsGathered++; } index++; } return stepsToBeRepeated; } //Modify is full public boolean isFull(long currentStep){ for(int i=0; i= currentStep){ if(this.stepHandler.get(i).canBeReduced()){ ////sytemout.println("False because:\t" + this.stepHandler.get(i).toString() + "\n"); return false; }else{ ////sytemout.println("Cant be reduced because:\t" + this.stepHandler.get(i).toString() + "\n"); } }else{ ////sytemout.println("CurrentStepNotGreater:\t" + "CurrStep:\t" + currentStep + "\t" + this.stepHandler.get(i).getCurrentStep() + "\n"); } } return true; } //New functionality public void printInfo2(){ long totalCount = 0; for(int i=0; i