Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想问在 GnuMathprog 模型中是否可以有两个嵌套的 if以及我如何在代码中编写类似的东西。例如:
if a<>0 a*x=y if b<>0 b*c=d else 0 else 0 ;
非常感谢
首先是坏消息:GPL 不支持 If-Then-Else 语句。
但是您可以在可以嵌套的 for 循环中使用条件。这是一个小的工作非嵌套示例:
for{a in {1..2}} { for {{0}: a == 1} { printf "First\n"; } for {{0}: a != 1} { printf "Second\n"; } } end;
这在对模型结果/数据进行后处理时效果很好。