diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Stand.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Stand.java index 4a39d92ef..5b1cb93c5 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Stand.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Stand.java @@ -287,6 +287,11 @@ public class Stand extends MayOutOfOrderDevice { this.isRight()?"右行":"左行", this.getName(), this.getCode()); } + public String showStr() { + return String.format("%s-%s站台", this.station.getName(), + this.isRight() ? "上行" : "下行"); + } + /** * 站台折返类型策略 */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/Config.java b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/Config.java index c13144875..726f41618 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/Config.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/Config.java @@ -6,13 +6,13 @@ public final class Config { /** 策略向后推算的时间,单位 - 分钟 */ public static final int STRATEGY_CAL_TIME = 30; /** 站台大客流判断基准值 */ - public static final int STAND_LPF_TRIGGER = 800; + public static final int STAND_LPF_TRIGGER = 600; /** 站台可跳停的最大客流数 */ public static final int STAND_JUMP_MAX = 50; /** 站台最大停站时间:单位 - 秒 */ public static final int STAND_MAX_STOP_TIME = 90; /** 列车最大容量 */ - public static final int TRAIN_CAPACITY = 1500; + public static final int TRAIN_CAPACITY = 1400; /** 站台无效的上车时间(开关门6s+下车4s+发车前确认5s) */ public static final int INVALID_BOARD_TIME = 15; /** 乘客下车速度:人/秒 */ @@ -20,5 +20,5 @@ public final class Config { /** 站台乘客上列车速度: 人/秒 */ public static final int PASSENGER_BOARD_SPEED = 20; /** 列车跳停节省时间,单位 - 秒 */ - public static final int TRAIN_PASS_SAVE_TIME = 60; + public static final int TRAIN_PASS_SAVE_TIME = 50; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/LargePassengerFlowStrategyService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/LargePassengerFlowStrategyService.java index 57d307630..06d19835f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/LargePassengerFlowStrategyService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/LargePassengerFlowStrategyService.java @@ -49,10 +49,10 @@ public class LargePassengerFlowStrategyService { } for (PassengerFlowSimulationData passengerFlowSimulationData : pfSimulationList) { Simulation simulation = this.passengerFlowSimulateService.getSimulationByGroup(passengerFlowSimulationData.getGroup()); - if (passengerFlowSimulationData.getNextRecommendTime() != null && - simulation.getSystemTime().isBefore(passengerFlowSimulationData.getNextRecommendTime())) { - continue; - } +// if (passengerFlowSimulationData.getNextRecommendTime() != null && +// simulation.getSystemTime().isBefore(passengerFlowSimulationData.getNextRecommendTime())) { +// continue; +// } // 查询大客流站台 List standPassengerFlowList = passengerFlowSimulationData.getAllStandPassengerFlow(); List lpfList = new ArrayList<>(); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/StrategyCalculateAndRecommendService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/StrategyCalculateAndRecommendService.java index 9833fade5..185d01756 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/StrategyCalculateAndRecommendService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/StrategyCalculateAndRecommendService.java @@ -11,6 +11,7 @@ import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import java.util.Map; @@ -45,7 +46,7 @@ public class StrategyCalculateAndRecommendService implements ApplicationContextA for (Strategy strategy : list) { strategyService.calculate(data.clone(), strategy); strategy.buildDescription(); - strategy.handleTarget(); +// strategy.handleTarget(); log.info(String.format("策略[%s]计算指标为:%s", strategy.getDescription(), strategy.targetDebugStr())); strategyList.add(strategy); @@ -58,6 +59,7 @@ public class StrategyCalculateAndRecommendService implements ApplicationContextA List recommendList = new ArrayList<>(); if (!CollectionUtils.isEmpty(strategyList)) { recommendList.addAll(strategyList); + recommendList.sort(Comparator.comparing(Strategy::getExtraNum).reversed()); } return recommendList; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/data/JumpAndParkTimeStrategy.java b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/data/JumpAndParkTimeStrategy.java index 016f25a00..19601369a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/data/JumpAndParkTimeStrategy.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/data/JumpAndParkTimeStrategy.java @@ -47,9 +47,9 @@ public class JumpAndParkTimeStrategy extends Strategy { @Override public String buildDescription() { - this.description = String.format("为列车[%s-%s|%s],设置站台%s跳停", - groupNumber, serviceNumber, tripNumber, - jumpStand.debugStr()); + this.description = String.format("为列车[%s%s],设置[%s]跳停;为[%s]设置停站时间[%s]", + serviceNumber, tripNumber, jumpStand.showStr(), + this.parkStand.showStr(), this.time); return this.description; } @@ -59,4 +59,8 @@ public class JumpAndParkTimeStrategy extends Strategy { this.serviceNumber = tripPlan.getServiceNumber(); this.tripNumber = tripPlan.getTripNumber(); } + + public void setJumpStand(Stand jumpStand) { + this.jumpStand = jumpStand; + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/data/JumpStrategy.java b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/data/JumpStrategy.java index 6a52354fb..d500a69fd 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/data/JumpStrategy.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/data/JumpStrategy.java @@ -34,9 +34,8 @@ public class JumpStrategy extends Strategy { @Override public String buildDescription() { - this.description = String.format("为列车[%s-%s|%s],设置站台%s跳停", - groupNumber, serviceNumber, tripNumber, - stand.debugStr()); + this.description = String.format("为列车[%s%s],设置[%s]跳停", + serviceNumber, tripNumber, stand.showStr()); return this.description; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/data/LpfStrategyRecommend.java b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/data/LpfStrategyRecommend.java index c4801e004..cfb666721 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/data/LpfStrategyRecommend.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/data/LpfStrategyRecommend.java @@ -1,17 +1,21 @@ package club.joylink.rtss.simulation.cbtc.passenger.strategy.data; +import club.joylink.rtss.simulation.cbtc.passenger.strategy.Config; import lombok.Getter; import java.util.List; @Getter public class LpfStrategyRecommend { + /** 预测时长,单位:分钟 */ + int duration; List lpfList; List recommendList; public LpfStrategyRecommend(StrategyCalculateData data, List recommendList) { + this.duration = Config.STRATEGY_CAL_TIME; this.lpfList = data.getLpfStandList(); this.recommendList = recommendList; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/data/ParkTimeStrategy.java b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/data/ParkTimeStrategy.java index 08d1950f0..1555f884a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/data/ParkTimeStrategy.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/data/ParkTimeStrategy.java @@ -26,7 +26,7 @@ public class ParkTimeStrategy extends Strategy { @Override public String buildDescription() { - this.description = String.format("站台%s设置停站时间[%s]", stand.debugStr(), time); + this.description = String.format("[%s]设置停站时间[%s]", stand.showStr(), time); return this.description; } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/data/Strategy.java b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/data/Strategy.java index 7e3fd4246..b67570eaa 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/data/Strategy.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/data/Strategy.java @@ -2,10 +2,17 @@ package club.joylink.rtss.simulation.cbtc.passenger.strategy.data; import lombok.Getter; +import java.util.HashSet; +import java.util.Set; + @Getter public abstract class Strategy { public enum Type { + /** + * 无策略 + */ + NON, /** * 增加停站时间 */ @@ -17,59 +24,93 @@ public abstract class Strategy { /** * 跳停+增加停站时间 */ - J_P, + J_P; + + } - Type type; - String description; - /** 指标1:时刻表偏差 */ - int target1; - /** - * 权重1 - */ - int w1 = 1; - /** 指标2:乘客等待时间 */ - int target2; - /** - * 权重2 - */ - int w2 = 1; - /** 综合指标:对指标1,2加权求和 */ - int coTarget; + Set effectTrainSet = new HashSet<>(); + /** + * 几趟车受影响 + */ + int effectTrainNum; + + /** + * 总时刻表偏移 + */ + int scheduleOffset; + + /** + * 可多载离的乘客数 + */ + int extraNum; + +// /** 指标1:时刻表偏差 */ +// int target1; +// /** +// * 权重1 +// */ +// int w1 = 1; +// +// /** 指标2:乘客等待时间 */ +// int target2; +// +// /** +// * 权重2 +// */ +// int w2 = 1; +// /** 综合指标:对指标1,2加权求和 */ +// int coTarget; public Strategy(Type type) { this.type = type; } - public abstract String buildDescription(); - public void setTarget1(int target1) { - this.target1 = target1; + public void addEffectTrain(String groupNumber) { + if (groupNumber == null) { + return; + } + this.effectTrainSet.add(groupNumber); + this.effectTrainNum = this.effectTrainSet.size(); } - public void setTarget2(int target2) { - this.target2 = target2; + public void addOffset(int offset) { + this.scheduleOffset += offset; } - public void setCoTarget(int target) { - this.coTarget = target; - } - - public void addTarget1(int i) { - this.target1 += i; - } - - public void addTarget2(int wait) { - this.target2 += wait; + public void addExtraNum(int extra) { + this.extraNum += extra; } +// public void setTarget1(int target1) { +// this.target1 = target1; +// } +// +// public void setTarget2(int target2) { +// this.target2 = target2; +// } +// +// public void setCoTarget(int target) { +// this.coTarget = target; +// } +// +// public void addTarget1(int i) { +// this.target1 += i; +// } +// +// public void addTarget2(int wait) { +// this.target2 += wait; +// } +// public String targetDebugStr() { - return String.format("指标1-时刻表偏差为:[%s],指标2-等待乘客数为:[%s],综合指标为:[%s]",this.target1, this.target2, this.coTarget); + return String.format("影响列车数量:[%s],总时刻表偏移:[%s],可多载人数:[%s]", + this.effectTrainNum, this.scheduleOffset, this.extraNum); } - public void handleTarget() { - this.coTarget = this.target1 * this.w1 + this.target2 * this.w2; - } +// public void handleTarget() { +// this.coTarget = this.target1 * this.w1 + this.target2 * this.w2; +// } } \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/service/JumpAndParkTimeStrategyServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/service/JumpAndParkTimeStrategyServiceImpl.java new file mode 100644 index 000000000..269d357ae --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/service/JumpAndParkTimeStrategyServiceImpl.java @@ -0,0 +1,356 @@ +//package club.joylink.rtss.simulation.cbtc.passenger.strategy.service; +// +//import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +//import club.joylink.rtss.simulation.cbtc.data.map.Stand; +//import club.joylink.rtss.simulation.cbtc.data.plan.RealRun; +//import club.joylink.rtss.simulation.cbtc.data.plan.StationPlan; +//import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan; +//import club.joylink.rtss.simulation.cbtc.passenger.strategy.Config; +//import club.joylink.rtss.simulation.cbtc.passenger.strategy.data.*; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.stereotype.Component; +//import org.springframework.util.CollectionUtils; +// +//import java.time.LocalDateTime; +//import java.time.LocalTime; +//import java.util.*; +// +//@Slf4j +//@Component +//public class JumpAndParkTimeStrategyServiceImpl implements StrategyService { +// +// @Override +// public List generateStrategy(StrategyCalculateData data) { +// List list = new ArrayList<>(); +// List lpfList = data.queryLpfList(); +// if (CollectionUtils.isEmpty(lpfList)) { +// return null; +// } +// // 暂时按一个站大客流处理 +// StandPassenger standPassenger = lpfList.get(0); +// Stand stand = standPassenger.getStand(); +// Map> planMap = data.getPlanMap(); +// int planParkTime = 0; // 计划停站时间 +// for (List planList : planMap.values()) { +// for (TripPlan tripPlan : planList) { +// List stationPlanList = tripPlan.getPlanList(); +// for (StationPlan stationPlan : stationPlanList) { +// if (Objects.equals(stationPlan.getSection(), stand.getSection()) && +// stationPlan.getParkTime() > 0) { +// planParkTime = stationPlan.getParkTime(); +// break; +// } +// } +// } +// if (planParkTime > 0) { +// break; +// } +// } +// if (planParkTime <= 0) { +// throw new IllegalArgumentException(String.format("计划或站台[%s]数据异常,找到的计划停站时间异常:为[%s]", stand.debugStr(), planParkTime)); +// } +// // 最大停站时间内每隔5秒生成一个策略(策略的停站时间为计划停站时间+5*i) +// int iter = (Config.STAND_MAX_STOP_TIME - planParkTime) / 5; +// for (int i = 1; i <= iter; i++) { +// list.add(new JumpAndParkTimeStrategy(stand, planParkTime + i * 5)); +// } +// List leftStandList = data.getLeftStandList(); +// List rightStandList = data.getRightStandList(); +// boolean right = false; +// int index = leftStandList.indexOf(stand); +// if (index < 0) { +// // 不是左向站台 +// right = true; +// index = rightStandList.indexOf(stand); +// } +// BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(index >= 0, String.format("未找到站台[%s]", stand.debugStr())); +// log.debug(String.format("[%s]第[%s]个站台大客流", right?"右向":"左向", (index+1))); +// +// boolean hasJump = false; +// if (index == 0) { +// // 第一站,不生成跳停策略 +// log.debug(String.format("第一个站,不生成跳停策略")); +// } +// List jumpableStandList; +// if (right) { +// jumpableStandList = rightStandList.subList(0, index); +// } else { +// jumpableStandList = leftStandList.subList(0, index); +// } +// List trainPassengerList = data.getTrainPassengerList(); +// for (int i = jumpableStandList.size()-1; i > 0; i--) { // 起始站不跳停 +// Stand s = jumpableStandList.get(i); +// // 该站台人数是否支持跳停 +// StandPassenger sp = data.getStandPassengerByStand(s); +// if (sp.getWait() >= Config.STAND_JUMP_MAX) { +// log.debug(String.format("站台[%s]客流数[%s]>=站台跳停最大客流量[%s],不能跳停", +// s.debugStr(), sp.getWait(), Config.STAND_JUMP_MAX)); +// continue; +// } +// // 该站是否被前列车跳过 +// RealRun jumpRun = this.isJustJumped(data, s); +// if (jumpRun != null) { +// log.debug(String.format("站台[%s]刚被跳停,不生成", s.debugStr())); +// continue; +// } +// // 前一站是否刚跳停 +// if (i - 1 > 0) { +// Stand pre = jumpableStandList.get(i - 1); +// jumpRun = this.isJustJumped(data, pre); +// if (jumpRun != null) { +// boolean jump = false; +// List realRuns = data.queryRealRuns(jumpRun.getGroupNumber()); +// int i1 = realRuns.indexOf(jumpRun); +// for (int j = i1; j < realRuns.size(); j++) { +// RealRun realRun = realRuns.get(j); +// if (Objects.equals(realRun.getSectionCode(), s.getSection().getCode())) { +// if (!realRun.isArrive()) { +// jump = true; +// } +// break; +// } +// } +// if (jump) { +// log.debug(String.format("站台[%s]的前一站台[%s]刚被跳停,不生成", s.debugStr(), pre.debugStr())); +// continue; +// } +// } +// } +// hasJump = true; +// for (JumpAndParkTimeStrategy jumpAndParkTimeStrategy : list) { +// jumpAndParkTimeStrategy.setJumpStand(s); +// } +// } +// if (!hasJump) { +// list.clear(); +// } +// log.debug(String.format("生成跳停+停站时间策略[%s]个", list.size())); +// return list; +// } +// +// private RealRun isJustJumped(StrategyCalculateData data, Stand stand) { +// List trainPassengerList = data.getTrainPassengerList(); +// StationPlan plan = null; +// boolean jump = false; +// RealRun standLastRun = null; +// for (TrainPassenger trainPassenger : trainPassengerList) { +// String groupNumber = trainPassenger.getGroupNumber(); +// TripPlan tripPlan = data.queryTripPlan(trainPassenger.getServiceNumber(), trainPassenger.getTripNumber()); +// if (tripPlan == null) { +// log.warn(String.format("列车[%s-%s|%s]没有找到车次计划", +// groupNumber, trainPassenger.getServiceNumber(), trainPassenger.getTripNumber())); +// continue; +// } +// int index = tripPlan.getPlanIndex(stand.getSection()); +// if (index < 0) { // 没有对应站台计划,无需判断跳停 +// continue; +// } +// List realRunList = data.queryRealRuns(groupNumber); +// if (!CollectionUtils.isEmpty(realRunList)) { +// realRunList.sort(Comparator.comparing(RealRun::getTime)); +// RealRun last = realRunList.get(realRunList.size() - 1); +// int lastRunIndex = tripPlan.getPlanIndex(last.getSectionCode()); +// if (lastRunIndex < index) { // 列车实际运行未过站台 +// StationPlan stationPlan = tripPlan.getPlanList().get(index); +// if (plan == null || plan.getArriveTime().isAfter(stationPlan.getArriveTime())) { +// plan = stationPlan; +// } +// continue; +// } +// for (int i = realRunList.size() - 1; i >= 0; i--) { +// RealRun realRun = realRunList.get(i); +// if (!Objects.equals(realRun.getServiceNumber(), trainPassenger.getServiceNumber()) || +// !Objects.equals(realRun.getTripNumber(), trainPassenger.getTripNumber())) { +// break; +// } +// if (Objects.equals(realRun.getSectionCode(), stand.getSection().getCode())) { +// if (!realRun.isArrive() && i > 0) { +// RealRun pre = realRunList.get(i - 1); +// if (pre.isArrive() && +// Objects.equals(pre.getSectionCode(), stand.getSection().getCode())) { +// if (standLastRun == null || standLastRun.getTime().isAfter(pre.getTime())) { +// jump = false; +// standLastRun = pre; +// } +// } else { +// if (standLastRun == null || standLastRun.getTime().isAfter(realRun.getTime())) { +// jump = true; +// standLastRun = realRun; +// } +// } +// } +// } +// } +// } +// } +// if (jump) { +// return standLastRun; +// } +// return null; +// } +// +// @Override +// public void calculate(StrategyCalculateData data, JumpAndParkTimeStrategy strategy) { +// List trainPassengerList = data.getTrainPassengerList(); +// LocalDateTime systemTime = data.getSystemTime(); +// LocalDateTime startTime = systemTime; +// LocalDateTime endTime = systemTime.plusMinutes(Config.STRATEGY_CAL_TIME); +// boolean jump = false; +// int i = 0; +// while (startTime.isBefore(endTime) && i < 1000) { +// ++i; +// LocalDateTime nextTime = null; +// for (TrainPassenger trainPassenger : trainPassengerList) { +// String groupNumber = trainPassenger.getGroupNumber(); +// List realRunList = data.queryRealRuns(groupNumber); +// if (CollectionUtils.isEmpty(realRunList)) { +// TripPlan tripPlan = data.queryTripPlan(trainPassenger.getServiceNumber(), trainPassenger.getTripNumber()); +// if (tripPlan == null) { +// log.warn(String.format("列车[%s-%s|%s]没有找到车次计划", +// groupNumber, trainPassenger.getServiceNumber(), trainPassenger.getTripNumber())); +// continue; +// } +// if (tripPlan.isBackup()) { +// continue; +// } +// List planList = tripPlan.getPlanList(); +// for (StationPlan stationPlan : planList) { +// if (stationPlan.getArriveTime().compareTo(systemTime.toLocalTime()) >= 0) { +// this.handleTrainRun(data, strategy, trainPassenger, tripPlan, stationPlan); +// break; +// } +// } +// realRunList = data.queryRealRuns(groupNumber); +// if (CollectionUtils.isEmpty(realRunList)) { +// log.error(String.format("列车[%s-%s|%s],车次[%s],时间[%s]", +// groupNumber, trainPassenger.getServiceNumber(), trainPassenger.getTripNumber(), +// tripPlan.debugStr(), systemTime.toString())); +// } +// } else { +// RealRun lastRun = realRunList.get(realRunList.size() - 1); +// TripPlan tripPlan = data.queryTripPlan(lastRun.getServiceNumber(), lastRun.getTripNumber()); +// StationPlan stationPlan = tripPlan.queryStationPlanByStationCode(lastRun.getStationCode()); +// BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(stationPlan); +// if (lastRun.isArrive()) { +// this.handleTrainRun(data, strategy, trainPassenger, tripPlan, stationPlan); +// } else { +// if (tripPlan.isLastPlan(stationPlan)) { +// TripPlan nextTripPlan = data.queryNextTripPlan(tripPlan); +// if (nextTripPlan != null) { +// StationPlan nextStationPlan = nextTripPlan.getFirstStationPlan(); +// this.handleTrainRun(data, strategy, trainPassenger, nextTripPlan, nextStationPlan); +// } +// } else { +// StationPlan nextStationPlan = tripPlan.queryNextStationPlan(stationPlan.getStation()); +// this.handleTrainRun(data, strategy, trainPassenger, tripPlan, nextStationPlan); +// } +// } +// } +// // 更新nextTime +// if (!CollectionUtils.isEmpty(realRunList)) { +// RealRun last = realRunList.get(realRunList.size() - 1); +// if (nextTime == null || nextTime.isAfter(last.getTime())) { +// nextTime = last.getTime(); +// } +// } +// } +// systemTime = nextTime; +// } +// } +// +// private void handleTrainRun(StrategyCalculateData data, +// JumpAndParkTimeStrategy strategy, +// TrainPassenger trainPassenger, +// TripPlan tripPlan, StationPlan stationPlan) { +// Stand stand = strategy.getJumpStand(); +// String groupNumber = trainPassenger.getGroupNumber(); +// List realRunList = data.queryRealRuns(groupNumber); +// RealRun lastRun = null; +// int offset = 0; +// if (!CollectionUtils.isEmpty(realRunList)) { +// // 获取上一个实际运行,并计算时间偏移 +// lastRun = realRunList.get(realRunList.size() - 1); +// TripPlan lastTripPlan = data.queryTripPlan(lastRun.getServiceNumber(), lastRun.getTripNumber()); +// StationPlan lastStationPlan = lastTripPlan.queryStationPlanByStationCode(lastRun.getStationCode()); +// if (lastRun.isArrive()) { +// offset = lastRun.getTime().toLocalTime().toSecondOfDay() - lastStationPlan.getArriveTime().toSecondOfDay(); +// } else { +// offset = lastRun.getTime().toLocalTime().toSecondOfDay() - lastStationPlan.getLeaveTime().toSecondOfDay(); +// } +// } +// if (Objects.equals(stand.getSection(), stationPlan.getSection()) && !strategy.isJumped()) { // 跳停站台计划 +// // 跳停策略指定的跳停站台,构建跳停运行,并更新策略 +// RealRun passing = this.buildRealRun(groupNumber, tripPlan, stationPlan, false, +// stationPlan.getArriveTime(), offset, data.getSystemTime()); +// data.addRealRun(passing); +// strategy.jumpedByTrain(groupNumber, tripPlan); +// strategy.addOffset(-Config.TRAIN_PASS_SAVE_TIME); +// StandPassenger standPassenger = data.getStandPassengerByStand(stand); +// strategy.addEffectTrain(groupNumber); +// strategy.addExtraNum(standPassenger.getWait()); +// return; +// } +// // 非跳停,根据计划更新预测运行 +// if (lastRun == null || +// !Objects.equals(stationPlan.getStation().getCode(), lastRun.getStationCode())) { +// RealRun arrive = this.buildRealRun(groupNumber, tripPlan, stationPlan, true, +// stationPlan.getArriveTime(), offset, data.getSystemTime()); +// data.addRealRun(arrive); +// } +// int parkTime = stationPlan.getParkTime(); +// // 列车到站乘客上车,更新列车上人数 +// if (stationPlan.getSection().getStandList().size() == 0) { +// return; +// } +// Stand parkStand = strategy.getParkStand(); +// LocalTime arriveTime = stationPlan.getArriveTime(); +// LocalTime leaveTime = stationPlan.getLeaveTime(); +// // 列车到站乘客上车,更新列车上人数 +// StandPassenger standPassenger = data.getStandPassengerByStand(stationPlan.getSection().getStandList().get(0)); +// int wait = standPassenger.getWait(); // 站台等待乘客数 +// int normal = (parkTime - Config.INVALID_BOARD_TIME) * Config.PASSENGER_BOARD_SPEED; // 根据停站预测的可上车人数 +// int remain = Config.TRAIN_CAPACITY - trainPassenger.getNum(); // 列车上剩余可载人数 +// // 大客流站计算指标 +// if (Objects.equals(stationPlan.getSection(), parkStand.getSection())) { +// // 时刻表偏差 +// parkTime = strategy.getTime(); +// leaveTime = arriveTime.plusSeconds(parkTime); +//// strategy.addTarget1(parkTime - stationPlan.getParkTime()); +//// // 乘客等待时间(按人数统计,不考虑时间) +//// strategy.addTarget2(standPassenger.getWait()); +// // +// strategy.addEffectTrain(groupNumber); +// int extraTime = strategy.getTime() - stationPlan.getParkTime(); +// strategy.addOffset(extraTime); +// int extraNum = extraTime * Config.PASSENGER_BOARD_SPEED; +// int extra = extraNum; +// if (normal + extraNum > remain) { +// if (normal < remain) { +// extra = remain - normal; +// } else { +// extra = 0; +// } +// } +// strategy.addExtraNum(extra); +// normal += extraNum; +// } +// float min = Math.min(Math.min(wait, normal), remain); // 实际上车人数 +// standPassenger.minus(min); +// trainPassenger.plus(min); +//// // 大客流站计算指标 +//// if (data.isLpfStand(stationPlan.getSection())) { +//// // 乘客等待时间(按人数统计,不考虑时间) +//// strategy.addTarget2(standPassenger.getWait()); +//// } +// // 生成预测实际运行图 +// RealRun leave = this.buildRealRun(trainPassenger.getGroupNumber(), tripPlan, stationPlan, false, +// leaveTime, offset, data.getSystemTime()); +// data.addRealRun(leave); +// } +// +// @Override +// public String getName() { +// return "跳停策略服务"; +// } +// +//} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/service/JumpStrategyServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/service/JumpStrategyServiceImpl.java index ecfd0a433..241386f23 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/service/JumpStrategyServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/service/JumpStrategyServiceImpl.java @@ -258,9 +258,10 @@ public class JumpStrategyServiceImpl implements StrategyService { stationPlan.getArriveTime(), offset, data.getSystemTime()); data.addRealRun(passing); strategy.jumpedByTrain(groupNumber, tripPlan); - strategy.addTarget1(-Config.TRAIN_PASS_SAVE_TIME); + strategy.addOffset(-Config.TRAIN_PASS_SAVE_TIME); StandPassenger standPassenger = data.getStandPassengerByStand(stand); - strategy.addTarget2(standPassenger.getWait()); + strategy.addEffectTrain(groupNumber); + strategy.addExtraNum(standPassenger.getWait()); return; } // 非跳停,根据计划更新预测运行 @@ -282,11 +283,11 @@ public class JumpStrategyServiceImpl implements StrategyService { float min = Math.min(Math.min(wait, predict), remain); // 实际上车人数 standPassenger.minus(min); trainPassenger.plus(min); - // 大客流站计算指标 - if (data.isLpfStand(stationPlan.getSection())) { - // 乘客等待时间(按人数统计,不考虑时间) - strategy.addTarget2(standPassenger.getWait()); - } +// // 大客流站计算指标 +// if (data.isLpfStand(stationPlan.getSection())) { +// // 乘客等待时间(按人数统计,不考虑时间) +// strategy.addTarget2(standPassenger.getWait()); +// } // 生成预测实际运行图 RealRun leave = this.buildRealRun(trainPassenger.getGroupNumber(), tripPlan, stationPlan, false, stationPlan.getLeaveTime(), offset, data.getSystemTime()); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/service/ParkTimeStrategyServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/service/ParkTimeStrategyServiceImpl.java index 1b80e0dbd..b6eb83f2b 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/service/ParkTimeStrategyServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/strategy/service/ParkTimeStrategyServiceImpl.java @@ -83,6 +83,9 @@ public class ParkTimeStrategyServiceImpl implements StrategyService remain) { + if (normal < remain) { + extra = remain - normal; + } else { + extra = 0; + } + } + strategy.addExtraNum(extra); + normal += extraNum; } + float min = Math.min(Math.min(wait, normal), remain); // 实际上车人数 + standPassenger.minus(min); + trainPassenger.plus(min); // 生成预测实际运行图 RealRun leave = this.buildRealRun(trainPassenger.getGroupNumber(), tripPlan, stationPlan, false, leaveTime, offsetTime, data.getSystemTime()); data.addRealRun(leave);