Commit a3ac4374 authored by Christoph Richter's avatar Christoph Richter
Browse files

ProblemAssignmentHandler: Avoid possible npe

parent c89f13f0
......@@ -124,13 +124,15 @@ public class ProblemAssignmentHandler {
private void addConstraintsOnObjectiveVariable(MathOptimizationStatementSymbol symbol, Vector<String> g, Vector<String> gL, Vector<String> gU) {
if (symbol.hasReturnValue()) {
MathValueSymbol objval = getVariableWithTypeInformations(symbol.getObjectiveValue());
Optional<ASTRange> rangeOpt = objval.getType().getType().getRangeOpt();
if (rangeOpt.isPresent() && rangeOpt.get().getMin().getNumber().isPresent() && rangeOpt.get().getMax().getNumber().isPresent()) {
Double min = rangeOpt.get().getMin().getNumber().get();
Double max = rangeOpt.get().getMax().getNumber().get();
gL.add(min.toString());
gU.add(max.toString());
g.add(getObjectiveFunctionAsCode(symbol));
if (objval.getType() != null) {
Optional<ASTRange> rangeOpt = objval.getType().getType().getRangeOpt();
if (rangeOpt.isPresent() && rangeOpt.get().getMin().getNumber().isPresent() && rangeOpt.get().getMax().getNumber().isPresent()) {
Double min = rangeOpt.get().getMin().getNumber().get();
Double max = rangeOpt.get().getMax().getNumber().get();
gL.add(min.toString());
gU.add(max.toString());
g.add(getObjectiveFunctionAsCode(symbol));
}
}
}
}
......
Supports Markdown
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