Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

script : removing an element from a setof

  • 1.  script : removing an element from a setof

    Posted 03/14/09 07:25 PM

    Originally posted by: SystemAdmin


    [dgravot@noos.fr said:]

    Hello

    Is it possible to remove a given element of a collection ?

    {int} mycollection = {3,8,99};

    What if I'd like to remove the second element ?

    Thanks
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: script : removing an element from a setof

    Posted 03/16/09 07:22 PM

    Originally posted by: SystemAdmin


    [afleischer said:]

    Hi David,

    in OPL 6.1.1 you cannot do that with a direct function.
    However you can write

    {int} mycollection = {3,8,99};

    {int} temp={item(mycollection,i) | i in 0..card(mycollection)-1 : i!=1};
    execute
    {
    mycollection=temp
    writeln(mycollection);
    }

    which gives

    {3 99}

    Alex Fleischer
    #DecisionOptimization
    #OPLusingCPLEXOptimizer