在我的代码中,我正在阅读一个名为$('table[id^="grid-"]').on("click", "td > input", function (e) {
var grid = "#" + $(e.target).closest("table").attr("id");
var caption = $(grid).jqGrid("getGridParam", "caption");
var checked = $(e.target).is(":checked")
var rowId = $(e.target).closest("tr").attr("id")
rowData = $(grid).getRowData(rowId);
});
的文本文件(我下载的这个文件,它放在我正在处理的项目的文件夹中),其中包含每天要读取的25个温度值。我的程序读取这些值并将它们保存到数组中。完成计算max,min和avg后,它会将这些值以及每小时温度表写入我将调用input-temps.txt
的输出文件。
我的代码问题在于,当它运行时无法找到该文件。我已尝试过其他循环,但结果相同。我出了什么问题?
谢谢。
output-temps.txt
答案 0 :(得分:0)
要检查文件是否存在,您必须使用“access()”功能。首先包括如下:
String before = "2";
String after = "11";
final StateManager stateManager = new StateManager(problem);
stateManager.addStateUpdater(new JobsInRouteMemorizer(stateManager));
ConstraintManager constraintManager = new ConstraintManager(problem, stateManager);
constraintManager.addConstraint(new OneJobBeforeAnother(stateManager, before, after));
final RewardAndPenaltiesThroughSoftConstraints contrib = new RewardAndPenaltiesThroughSoftConstraints(problem, before, after);
SolutionCostCalculator costCalculator = new SolutionCostCalculator() {
@Override
public double getCosts(VehicleRoutingProblemSolution solution) {
double costs = 0.;
List<VehicleRoute> routes = (List<VehicleRoute>) solution.getRoutes();
for(VehicleRoute route : routes){
costs+=route.getVehicle().getType().getVehicleCostParams().fix;
costs+=stateManager.getRouteState(route, InternalStates.COSTS, Double.class);
costs+=contrib.getCosts(route);
}
return costs;
}
};
VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(problem,
"algorithmConfig.xml");
vraBuilder.addCoreConstraints();
vraBuilder.setStateAndConstraintManager(stateManager, constraintManager);
vraBuilder.addDefaultCostCalculators();
vraBuilder.setObjectiveFunction(costCalculator);
algorithm = vraBuilder.build();
public class JobsInRouteMemorizer implements StateUpdater, ActivityVisitor {
private StateManager stateManager;
private VehicleRoute route;
public JobsInRouteMemorizer(StateManager stateManager) {
super();
this.stateManager = stateManager;
}
@Override
public void begin(VehicleRoute route) {
this.route=route;
}
@Override
public void visit(TourActivity activity) {
if(activity instanceof JobActivity){
String jobId = ((JobActivity) activity).getJob().getId();
StateId stateId = stateManager.createStateId(jobId);
System.out.println(stateId.getIndex());
System.out.println(stateId.toString());
stateManager.putProblemState(stateId, VehicleRoute.class, this.route);
}
}
@Override
public void finish() {}
}