4 常见错误分析
4.1 错误代码29:数组初始化个数与指定数目不一致
若提供的数据数目与集合段指定的数据长度不一致,会报如下错误:
意思是说:B变量初始化的个数少于集合段指定的数目;点击Explain按钮可以查询更详细的问题解释
You must assign a value to every element of each array in a DATA or INIT statement. LINGO keeps track of the number of values you specified and checks this against the length of each array being assigned. If the two numbers don’t agree, LINGO prints this message along with the number of values that are required.
4.2 错误代码12:缺少右括号报错
意思是:这样代码缺了一个右括号
A LINGO expression is missing at least one closing right parenthesis. LINGO will point to the end of the expression where the error occurred. Count the number of parentheses in this expression to verify if you have input the correct number, or, in Window use the Edit|Match Parenthesis command to find the unmatched parenthesis.
4.3 错误代码11:无效的输入,语法错误
模型的【model】关键字没有加【:】
This is the generic error issued by the LINGO compiler when it detects a syntax error. In Windows, when you close the error box, the cursor will be on the line where the error occurred. Other versions of LINGO will try print out the general area where the error has occurred, but LINGO cannot always pinpoint the exact line. Examine this area for any obvious syntax errors. If you are unable to find any obvious errors, a useful technique is to comment out small sections of the model until the error goes away. This should give you a good idea of exactly where the error is occurring.
Syntax errors may also occur if you are not invoking the correct compiler in LINGO. Most users will choose to build models using the native LINGO syntax, however, some users may prefer building their models using LINDO syntax. LINGO can compile models written in either native LINGO syntax or LINDO syntax. LINGO chooses the compiler based on a model's file extension. LINGO models must have an extension of lg4 (the default) or lng. LINDO models must have an ltx extension. The default model extension may be set by clicking on: LINGO | Options | Interface | File Format. Each model window's title bar displays whether it is a LINGO or LINDO model.
5 LINGO的错误列表
LINGO出错时错误代码含义:
在LINGO程序求解时,系统首先会对程序进行编译.系统在编译或执行其他命令时,会因程序中的错误或运行错误,弹出一个出错报告窗口,显示其错误代码,并简要指出错误的原因.这些错误报告信息能够提示用户发现程序中的错误,以便能尽快修改.下面我们给出出错信息的一个简要说明,仅供参考.
LINGO错误编号及原因对照表