zoukankan      html  css  js  c++  java
  • LINGO的集循环函数

    Set Looping Functions
    We have mentionedthe power of set-based modeling comes from the ability to apply an operation to
    all members of a set using a single statement. The functions in LINGO thatallow you to do this are
    called set looping functions. If your models don’t make use of one ormore set looping function, then
    you are missing out on the power of set-based modeling and, even worse, you’reprobably working too
    hard!

    集循环函数

    我们提到过集建模的效率来自于能够操作单个语句集的所有成员。LINGO中的函数,使你可以使用集循环函数。如果你的模型没有使用一个或多个集循环函数,那么你就失去了集建模的效率,更糟糕的是,你可能会为此做更多效率低下的工作!



    Set looping functions allow you to iterate through all the members of a set toperform some operation.
    There are currently four set looping functions in LINGO.

    集循环函数遍历整个集进行操作。LINGO 目前有四个集循环函数。


    Thesyntax for a set looping function is:
    @function(setname [ (set_index_list) [|conditional_qualifier]]: expression_list);

    其语法为:

             @function(setname[(set_index_list)[|conditional_qualifier]]:expression_list);



    where @function corresponds to one of the four set looping functionslisted in the table above. setname
    is the name of the set you want to loop over.

    @function相应于上面罗列的四个集循环函数之一(@FOR,@SUM,@MIN或@MAX,@PROD)。setname是要遍历的集。


    set_index_list is optional. It is used to create a list of indices. Eachindex corresponds to one of the
    parent, primitive sets that form the set specified by setname. As LINGOloops through the members of
    the set setname, it will set the values of the indices in the set_index_listto correspond to the current
    member of the set setname.

    set_index_list是可选的。它用于创建索引列表。每个索引对应于形成集合名称的指定集的父集、原始集之一。随着LINGO遍历该集的成员,它将对应集合当前成员在set_index_list中设定值。


    The conditional_qualifier is optional, and may be used to limit thescope of the set looping function.
    When LINGO is looping over each member of setname, it evaluates the conditional_qualifier.If the
    conditional_qualifier evaluates to true, then the @function isperformed for the set member.
    Otherwise, it is skipped.

    conditional_qualifier是可选的,并且可用于限制集循环函数的范围。当集循环函数遍历集的每个成员时,LINGO都要对conditional_qualifier进行评价。如果结果为真,则对该成员执行@function操作。否则跳过。


    The expression_listis a list of expressions that are to be applied to each member of the set setname.
    When using the @FOR function, the expression list may contain multipleexpressions, separated by
    semicolons. These expressions will be added as constraints to the model. Whenusing the remaining set
    looping functions (@SUM, @MAX, @MIN and @PROD), theexpression list must contain one
    expression only. If the set_index_list is omitted, all attributes referencedin the expression_list must be
    defined on the set setname.


    expression_list是应用到每个集成员的表达式列表。当使用@FOR函数时,expression_list可能包含多个表达式,其间用分号分隔。这些表达式将作为约束添加到模型。当使用其余集循环函数时 (@SUM、 @MAX、 @MIN和@PROD),表达式列表必须只包含一个表达式。如果省略了set_index_list,那么在expression_list中引用的所有属性的类型都是setname集。

     

  • 相关阅读:
    遇到shell重定向的一个奇怪问题:'消失'的标准输入!
    步步深入:MySQL架构总览->查询执行流程->SQL解析顺序
    [来自妹纸的挑战]-展开/还原多层链表
    【Shell】Linux 一行 多命令
    【Shell】通配符与特殊符号
    【Shell】变量的取用、删除、取代与替换
    【LeetCode】Find Minimum in Rotated Sorted Array 在旋转数组中找最小数
    【LeetCode】Maximum Product Subarray 求连续子数组使其乘积最大
    【LeetCode】Reverse Words in a String 反转字符串中的单词
    【面试题】比给定数大的最小数
  • 原文地址:https://www.cnblogs.com/Genesis2018/p/8304755.html
Copyright © 2011-2022 走看看