Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  How to modify elements of a tuple?

    Posted 11/12/13 12:16 PM

    Originally posted by: ikucukkoc


     

    Dear SystemAdmin

    I am using CPLEX and I need to preprocess data before the optimisation.

    In simplified version, I have a tuple "TaskTimes" as below and l need to modify the last column of every row by multiplying with a constant value, say 5.

     

    Sample.mod file

    tuple task { 
      int h; 
      string j; 
      int i; //
      string x; 
      float pt; 
    }

    {task} TaskTimes = ...;

     

    Sample.dat file:

    TaskTimes = {

    <1 A 1 L 3>,
    <1 A 2 R 3>,
    <1 A 3 E 0>,
    <1 A 4 L 2>,
    <1 A 5 E 2>,
    };

     

    Consequently; I should obtain following tuple:

     

    TaskTimes = {

    <1 A 1 L 15>,
    <1 A 2 R 15>,
    <1 A 3 E 0>,
    <1 A 4 L 10>,
    <1 A 5 E 10>,
    };

     

    Your prompt help and support is highly acknowledged.

    Many thanks.

    Best Regards

    Ibrahim

        

    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: How to modify elements of a tuple? Urgent help needed please?

    Posted 11/12/13 02:48 PM

    Hi,

     

    could

    {task} TaskTimes2 = {<e.h,e.j,e.i,e.x,5*e.pt> | e in TaskTimes};
    execute
    {
     
      TaskTimes2;
     
     
    }

     

    help ?

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: How to modify elements of a tuple? Urgent help needed please?

    Posted 11/12/13 03:37 PM

    Originally posted by: ikucukkoc


     

    Really appreciate for your quick response. But what about if I would like to edit/modify only a specific element of the tuple.

     

    For example in the following tuple:

     

    TaskTimes = {

    <1 A 1 L 3>,
    <1 A 2 R 3>,
    <1 A 3 E 0>,
    <1 A 4 L 2>,
    <1 A 5 E 2>,
    };

     

    I would like to change "0" at "row 3 column 5" to "8". So, the tuple would be:

     

    TaskTimes = {

    <1 A 1 L 3>,
    <1 A 2 R 3>,
    <1 A 3 E 8>,
    <1 A 4 L 2>,
    <1 A 5 E 2>,
    };

     

    Is that possible? Many thanks in advance.

     

    Best Regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: How to modify elements of a tuple? Urgent help needed please?

    Posted 11/12/13 04:10 PM

    Hi,

     

    yes you can:

     

    execute
    {
     Opl.item(TaskTimes,2).pt=8;
    }

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: How to modify elements of a tuple? Urgent help needed please?

    Posted 11/12/13 04:33 PM

    Originally posted by: ikucukkoc


    That is very helpful. Thank you very much.

    Lastly, is it possible to delete/remove ith row or ith column from the table?

    Regarda


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: How to modify elements of a tuple? Urgent help needed please?

    Posted 11/13/13 02:24 AM

    Hi,

    to remove a row:

    execute
    {
     TaskTimes.remove(Opl.item(TaskTimes,0));
     writeln(TaskTimes);
    }

     

    removing a column is not possible but you can set the column to zero for each row with what I sent you yesterday.

     

    Regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: How to modify elements of a tuple? Urgent help needed please?

    Posted 11/13/13 02:29 AM

    Originally posted by: ikucukkoc


    My thanks!

    Kind Regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: How to modify elements of a tuple? Urgent help needed please?

    Posted 11/13/13 06:04 AM

    Originally posted by: ikucukkoc


     

    Hello again. I have another question about filtering. 

     

    Regarding the code in your answer:

    {task} TaskTimes2 = {<e.h,e.j,e.i,e.x,5*e.pt> | e in TaskTimes};

    What about if it is subject to a condition. For example I have a tuple like:

     

    TaskTimes = {

    <1 A 1 L 3>,
    <1 A 2 R 3>,
    <1 A 3 E 0>,
    <2 A 4 L 2>,
    <2 A 5 E 1>,
    };

     

    And I want to obtain following tuple:

     

    TaskTimes = {

    <1 A 1 L 15>,
    <1 A 2 R 15>,
    <1 A 3 E 0>,
    <2 A 4 L 6>,
    <2 A 5 E 3>,
    };

     

    I want to multiply the "pt" column with "5" if "h=1"; multiply with "3" if "h=2".

     

    I can do that using for and if loops but it is not good for large sized tuples in terms of computation time. I am sure that there should be an easier way. 

     

    Appreciate for your help egain.

     

    Kind Regards.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 9.  Re: How to modify elements of a tuple? Urgent help needed please?

    Posted 11/13/13 10:03 AM

    Hi,

    you could write

    {task} TaskTimes2 = {<e.h,e.j,e.i,e.x,((e.h==2)?(5*e.pt):(3*e.pt))> | e in TaskTimes};

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 10.  Re: How to modify elements of a tuple? Urgent help needed please?

    Posted 11/13/13 10:13 AM

    Originally posted by: ikucukkoc


    Very helpful. Many thanks!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer