You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AMPL建模报错:"d is not defined"问题求助

AMPL建模错误修复:d未定义

错误原因

加载giap.mod时出现d is not defined错误,根源是集合All_destination的构造语法不符合AMPL规范。AMPL中构造集合时,需用竖线|分隔元素变量和筛选条件,你误用了冒号:,导致解析器无法识别变量d的作用域。

修正方案

将All_destination定义中的所有冒号:替换为竖线|,修正后的代码片段如下:

# 定义All_destination集合为所有相关关系的并集
set All_destination :=
    {(d, b) | d in Donors_Deliver, b in All_FoodBank}    # 捐赠者至食品仓库
    union {(d, b) | d in Collection_Donors union Financial_Donors, b in All_FoodBank}    # 取货/资金捐赠者至食品仓库
    union {(b, c) | b in All_FoodBank, c in Served_Charities};

验证说明

修正后,AMPL能正确识别每个集合构造中的变量(d、b、c),并根据指定的集合范围生成笛卡尔积的子集,解决未定义变量的错误。

内容的提问来源于stack exchange,提问作者nisanur azizah

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 09:38:11