Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  array assignment

    Posted 02/06/09 05:44 PM

    Originally posted by: SystemAdmin


    [shadi said:]

    hi,
    i have the following array
    isTripIncludedInDuty[nbTrips]

    i want to assign it like this:
    isTripIncludedInDuty[t] = 0     if trip t included in tripSeq[i].
                                  = 1    if trip t not included in tripSeq[i].


    please help me to write this command in the constraints section in the cp model

    i write the following command:
        forall (tr in Trips)
          isTripIncludedInDuty[table][tr][td] == sum (i in tripRng)(tripSeq[i] == tr);

    is it right?

    thanks
    kshieboun shadi
    it is not right becuase




    #DecisionOptimization
    #OPLusingCPOptimizer


  • 2.  Re: array assignment

    Posted 02/09/09 12:30 PM

    Originally posted by: SystemAdmin


    [alain.chabrier said:]

    Hi,

    it is not very clear from your post, where all elements come from.
    Can you include some more of  the model ?

    Alain
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 3.  Re: array assignment

    Posted 02/09/09 01:53 PM

    Originally posted by: SystemAdmin


    [shadi said:]

    dear Alain,
    I found another way I can achieve my goal. i dont need the isTripIncludedInDuty[t], i use the following constraint:


      cNew - sum(j in tripRng) Duals[tripSeq[j]] < 0;<br />

    buti get the following error:
    CP cannot extract expression: cNew+(sum(j in 1..20) Duals[(tripSeq[(j)])])*(-1)

    what i did wrong?


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 4.  Re: array assignment

    Posted 02/11/09 01:11 PM

    Originally posted by: SystemAdmin


    [afleischer said:]

    Hi,

    is Duals defined as an int array or as a float array?
    It should be an int array.
    Anyway, if this is not the issue, more elements about your model would be welcome

    Alex
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 5.  Re: array assignment

    Posted 02/11/09 01:45 PM

    Originally posted by: SystemAdmin


    [shadi said:]

    Dear alex,
    Duals defined as a float array, becuase the dual variables that the cp model receive from the main model is a float and not int.

    i changed the declaration to int and i get the following error:
    *** ERROR: "Duals": Cannot use type int[range] for float[range]


    im using column generation method to minimize the final cost.
    i want to write the reduced cost constraint in the cp model to add columns with negative reduced cost only.
    so i tried using two ways:

    1.  cNew - sum(j in tripRng) Duals[tripSeq[j]] < 0;<br />2.  cNew - sum (j in Trips) Duals[j]*flagTripInColumn[j] < 0;<br />      where
                  flagTripInColumn[j]=1    if trip j is covered by the new column
                                          =0    if trip j not covered by the new column    =>

    so i assigned it as following (i dont know if it is correct)     
                    forall (tr in Trips)
                              flagTripInColumn[table][tr][td] == sum (i in tripRng)(tripSeq[i] == tr);

     
    after implementation of the second option, i didnt receive runtime errors but i didnt receive to the optimum solution, i think there is an error in the
    reduced cost critirion.


    thanks in advenced
    Kshieboun Shadi

         



    #DecisionOptimization
    #OPLusingCPOptimizer


  • 6.  Re: array assignment

    Posted 02/12/09 11:33 AM

    Originally posted by: SystemAdmin


    [afleischer said:]

    Hi,

    so maybe in the declaration part you can convert the floats into ints

    int DualsI[i in tripRng]=ftoi(round(Duals[i]));

    and then your constraint

    cNew - sum(j in tripRng) DualsI[tripSeq[j]] < 0; <br />
    should work

    Alex Fleischer
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 7.  Re: array assignment

    Posted 02/12/09 01:45 PM

    Originally posted by: SystemAdmin


    [shadi said:]

    thank you Alex,
    it works, but i dont know why i still cant reach to the optimum solution using this reduced cost constraint... 






    #DecisionOptimization
    #OPLusingCPOptimizer