Commit ade33711 authored by duanruiming's avatar duanruiming

[update] 配置优化常量参数

parent 47ffa937
......@@ -3,8 +3,6 @@ package net.wanji.opt.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Objects;
/**
* @author hfx
* @date 2023/1/12 09:11
......@@ -63,33 +61,4 @@ public class CrossTurnDataRealtimeDTO {
private Double passTime;
/**
* 计算路口各转向所需的通行时长(秒)
* 相位的通行时长需大于等于最小绿灯时长,并且小于等于最大绿灯时长
* 车头间距(米):车间据如果不在20和7之间取9(默认9)
* 车头时距(秒):车时距如果不在2和5之间取2.8(默认2.8)
* 排队车辆 = 排队长度 / 车头间距
* 通行时长 = 排队车辆 * 车头时距
*/
public Double calPassTime(CrossTurnDataRealtimeDTO entity) {
// todo 优化参数,策略场景优化需要配置参数选择优化方法,读取不同配置优化信息
Double currentVehheadDist = entity.getVehheadDist();
if (Objects.isNull(currentVehheadDist) || currentVehheadDist > 20 || currentVehheadDist < 7) {
currentVehheadDist = 9.0;
}
Double currentVehheadTime = entity.getVehheadTime();
if (Objects.isNull(currentVehheadTime) || currentVehheadTime > 5 || currentVehheadTime < 2) {
currentVehheadTime = 2.8;
}
// 排队车辆
Double queuedVehicles = null;
if (Objects.nonNull(entity.getQueueLength())) {
queuedVehicles = entity.getQueueLength() / currentVehheadDist;
}
// 通行时长
Double calPassTime = queuedVehicles * currentVehheadTime;
return calPassTime;
}
}
......@@ -27,6 +27,7 @@ import net.wanji.opt.service.CrossOptimizeService;
import net.wanji.opt.service.CrossSchedulesService;
import net.wanji.opt.service.CrossSchemeService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
......@@ -62,6 +63,19 @@ public class CrossOptimizeServiceImpl implements CrossOptimizeService {
@Resource
UtcFeignClients utcFeignClients;
@Value("${crossOptParam.maxVehheadDist}")
private Double maxVehheadDist;
@Value("${crossOptParam.minVehheadDist}")
private Double minVehheadDist;
@Value("${crossOptParam.defaultVehheadDist}")
private Double defaultVehheadDist;
@Value("${crossOptParam.maxVehheadTime}")
private Double maxVehheadTime;
@Value("${crossOptParam.minVehheadTime}")
private Double minVehheadTime;
@Value("${crossOptParam.defaultVehheadTime}")
private Double defaultVehheadTime;
static Set<String> CROSS_OPT = new HashSet<>(); // 记录已优化的路口
@Override
......@@ -158,7 +172,7 @@ public class CrossOptimizeServiceImpl implements CrossOptimizeService {
if (!congestCrossMap.containsKey(ridInfoEntity.getEndCrossId()) && Objects.equals(inDir, dir)) {
String endCrossId = ridInfoEntity.getEndCrossId();
List<CrossTurnDataRealtimeDTO> endcrossTurnDataRealtimeDTOS = turnDataRealtimeMap.get(endCrossId);
endcrossTurnDataRealtimeDTOS.forEach(item -> item.setPassTime(item.calPassTime(item)));
endcrossTurnDataRealtimeDTOS.forEach(item -> item.setPassTime(calPassTime(item)));
// 进行优化下发
doExecuteCrossOpt(crossTurnDataRealtimeDTOS, phaseMap, endCrossId, "3");
// 记录已优化的路口
......@@ -352,7 +366,7 @@ public class CrossOptimizeServiceImpl implements CrossOptimizeService {
// 计算路口各转向所需的通行时长(秒)
List<CrossTurnDataRealtimeDTO> crossTurnDataRealtimeDTOS = turnDataRealtimeMap.get(crossId);
crossTurnDataRealtimeDTOS.forEach(item -> item.setPassTime(item.calPassTime(item)));
crossTurnDataRealtimeDTOS.forEach(item -> item.setPassTime(calPassTime(item)));
// 执行路口优化
doExecuteCrossOpt(crossTurnDataRealtimeDTOS, phaseMap, crossId, "1");
......@@ -776,4 +790,33 @@ public class CrossOptimizeServiceImpl implements CrossOptimizeService {
return turnDataRealtimeDTOList;
}
/**
* 计算路口各转向所需的通行时长(秒)
* 相位的通行时长需大于等于最小绿灯时长,并且小于等于最大绿灯时长
* 车头间距(米):车间据如果不在20和7之间取9(默认9)
* 车头时距(秒):车时距如果不在2和5之间取2.8(默认2.8)
* 排队车辆 = 排队长度 / 车头间距
* 通行时长 = 排队车辆 * 车头时距
*/
public Double calPassTime(CrossTurnDataRealtimeDTO entity) {
// todo 优化参数,策略场景优化需要配置参数选择优化方法,读取不同配置优化信息
Double currentVehheadDist = entity.getVehheadDist();
if (Objects.isNull(currentVehheadDist) || currentVehheadDist > maxVehheadDist || currentVehheadDist < minVehheadDist) {
currentVehheadDist = defaultVehheadDist;
}
Double currentVehheadTime = entity.getVehheadTime();
if (Objects.isNull(currentVehheadTime) || currentVehheadTime > maxVehheadTime || currentVehheadTime < minVehheadTime) {
currentVehheadTime = defaultVehheadTime;
}
// 排队车辆
Double queuedVehicles = null;
if (Objects.nonNull(entity.getQueueLength())) {
queuedVehicles = entity.getQueueLength() / currentVehheadDist;
}
// 通行时长
Double calPassTime = queuedVehicles * currentVehheadTime;
return calPassTime;
}
}
......@@ -17,6 +17,18 @@ threadPool:
queueCapacity: 5
keepAliveTime: 60000
#优化参数配置
crossOptParam:
#车头间距
maxVehheadDist: 20.0
minVehheadDist: 7.0
defaultVehheadDist: 9.0
#车头时距
maxVehheadTime: 5.0
minVehheadTime: 2.0
defaultVehheadTime: 2.8
spring:
datasource:
dynamic:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment