You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
operator :=if invert ==NBSolve.RelationInversion.TRUE then Operator.invert(condition.operator) else condition.operator;
685
686
686
687
// if its solvable, get the corresponding iterator range and adapt it with the information of the if-condition
687
688
if status ==NBSolve.Status.EXPLICITand invert <>NBSolve.RelationInversion.UNKNOWN then
688
689
range :=UnorderedMap.getSafe(cref, iter_map, sourceInfo());
689
-
(range, status) := match range
690
-
caseExpression.RANGE() algorithm
691
-
operator :=if invert ==NBSolve.RelationInversion.TRUE then Operator.invert(condition.operator) else condition.operator;
692
-
then (adaptRange(UnorderedMap.getSafe(cref, iter_map, sourceInfo()), Equation.getRHS(tmpEqn), operator.op), status);
690
+
try
691
+
(range, status) := match range
692
+
caseExpression.RANGE() then (adaptRange(UnorderedMap.getSafe(cref, iter_map, sourceInfo()), Equation.getRHS(tmpEqn), operator), status);
693
693
694
-
// ToDo: intercepting this
695
-
caseExpression.ARRAY() then (range, status);
694
+
// ToDo: intercepting this
695
+
caseExpression.ARRAY() then (adaptArray(UnorderedMap.getSafe(cref, iter_map, sourceInfo()), Equation.getRHS(tmpEqn), operator), status);
696
696
697
-
// can't do anything here
698
-
else (range, NBSolve.Status.UNSOLVABLE);
699
-
end match;
697
+
// can't do anything here
698
+
else (range, NBSolve.Status.UNSOLVABLE);
699
+
end match;
700
+
else
701
+
Error.addMessage(Error.INTERNAL_ERROR,{getInstanceName() +" failed to combine iterator: "+ toString(iter) +" with condition "+Expression.toString(condition) +"."});
702
+
fail();
703
+
end try;
700
704
701
705
UnorderedMap.add(cref, range, iter_map);
702
706
else
@@ -717,47 +721,47 @@ public
717
721
function adaptRange
718
722
input output Expression range;
719
723
input Expression rhs;
720
-
input Operator.Op op;
724
+
input Operator operator;
721
725
protected
722
726
Integer thresh, start, step, stop;
723
-
Type ty;
724
727
Boolean within_range;
725
728
algorithm
726
-
(thresh, start, step, stop, ty) := match (rhs, range)
727
-
case (Expression.INTEGER(thresh), range as Expression.RANGE(start =Expression.INTEGER(start), step =SOME(Expression.INTEGER(step)), stop =Expression.INTEGER(stop))) then (thresh, start, step, stop, range.ty);
728
-
case (Expression.INTEGER(thresh), range as Expression.RANGE(start =Expression.INTEGER(start), stop =Expression.INTEGER(stop))) then (thresh, start, 1, stop, range.ty);
729
-
else (0, 0, 0, 0, Type.UNKNOWN());
729
+
// extract the primitive type representation
730
+
(thresh, start, step, stop) := match (rhs, range)
731
+
case (Expression.INTEGER(thresh), range as Expression.RANGE(start =Expression.INTEGER(start), step =SOME(Expression.INTEGER(step)), stop =Expression.INTEGER(stop))) then (thresh, start, step, stop);
732
+
case (Expression.INTEGER(thresh), range as Expression.RANGE(start =Expression.INTEGER(start), stop =Expression.INTEGER(stop))) then (thresh, start, 1, stop);
733
+
else algorithm
734
+
Error.addMessage(Error.INTERNAL_ERROR,{getInstanceName() +" failed because range could not be evaluated: "+Expression.toString(range)});
if within_range then Expression.makeExpArray(listArray(list(Expression.INTEGER(i) for i guard(i <> thresh) inList.intRange3(start, step, stop))), Type.INTEGER(), true)
747
-
// this element is not in the range >>> original range not changed
if within_range then Expression.makeExpArray(listArray(list(Expression.INTEGER(i) for i guard(i <> thresh) inList.intRange3(start, step, stop))), Type.INTEGER(), true)
752
+
// this element is not in the range >>> original range not changed
caseNFOperator.Op.NEQUAL then Expression.makeExpArray(listArray(list(Expression.INTEGER(i) for i guard(i <> thresh) in elems)), Type.INTEGER(), true);
824
+
caseNFOperator.Op.LESS then Expression.makeExpArray(listArray(list(Expression.INTEGER(i) for i guard(i < thresh) in elems)), Type.INTEGER(), true);
825
+
caseNFOperator.Op.LESSEQ then Expression.makeExpArray(listArray(list(Expression.INTEGER(i) for i guard(i <= thresh) in elems)), Type.INTEGER(), true);
826
+
caseNFOperator.Op.GREATER then Expression.makeExpArray(listArray(list(Expression.INTEGER(i) for i guard(i > thresh) in elems)), Type.INTEGER(), true);
827
+
caseNFOperator.Op.GREATEREQ then Expression.makeExpArray(listArray(list(Expression.INTEGER(i) for i guard(i >= thresh) in elems)), Type.INTEGER(), true);
828
+
829
+
else algorithm
830
+
Error.addMessage(Error.INTERNAL_ERROR,{getInstanceName() +" failed for operator: "+Operator.toDebugString(operator)});
0 commit comments