Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Formulation on cplex of VAP

    Posted Sun May 04, 2014 10:20 AM

    Originally posted by: stathis_d


    Hello guys, 

    I'm new on cplex and I'm having the hardest  time trying to formulate a simple vehicle allocation problem. Although I have search a lot I can't find , how I can include the third location  (location k) on my model and  I get continuously errors when I'm running it . Any help at this point would be really appreciated, since I'm really desperate. I have attached the model that I'm trying to write on opl  and below is the code that i have for now (without  time, I would include it later) which is probably wrong, although the syntax is fine: 

     

    int n=...;
    range Locations=1..n; 
     
     tuple     arc     {int i; 
                              int j; }
                   
    setof(arc) Arcs       = {<i,j> | ordered i,j in Locations}; 
     
     
     
     float   Cost[Arcs]=...;          
     
     int demand[Arcs]=...;            
                                       
                                       
     float PenaltyCost[Arcs]=...;
     
     
    dvar int x[Arcs];                  
    dvar int y[Arcs];           
     
     
     minimize  sum(<i,j> in Arcs:i!=j in Locations) Cost[<i,j>]*x[<i,j>] + sum (<k,i> in Arcs)PenaltyCost [<k,i>]*y[<k,i>];
     
     
    subject to {
     
    forall (i,j,k in Locations) sum(<k,i> in Arcs:k!=i in Locations) (x[<k,i>]+y[<k,i>])+y[<i,i>]- 
                                sum (<i,j> in Arcs)(x[<i,j>]+y[<i,j>])==y[<i,i>]; 
                                                 
                                                    
     
    forall (<i,j> in Arcs) x[<i,j>]>= demand[<i,j>];
     
    forall (<i,j> in Arcs) x[<i,j>] >=0;
     
    forall (<i,j> in Arcs) y[<i,j>] >=0;
     
    forall (<i,i> in Arcs) y[<i,i>]== 0;
     
    };

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Formulation on cplex of VAP

    Posted Mon May 05, 2014 03:36 AM

    Hi,

    can you attach .mod and .dat ?

    Regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Formulation on cplex of VAP

    Posted Mon May 05, 2014 04:30 AM

    Originally posted by: stathis_d


    Hi Alex ,

    thanks a lot for your response, I have attached the two files but I have to clarify that both of them are created by me and probably the .dat  file has mistakes since i don't really know how to handle the locations, once that i have the right .mod afterwards I think will be easier to create a  right .dat . In my case cost for departing from i to j and  demand from  i to j will be known, as well as the penalty cost for ordering empty from k to i. I have tried couple of things but nothing works at this point so any help will be really appreciated. Thanks in advance. 

    Regards . 


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Formulation on cplex of VAP

    Posted Mon May 05, 2014 12:02 PM

    Hi

    with .dat:

     

    n=5;
     
     Arcs={<1,1>,<1,2>,<1,3>,<1,4>,<1,5>,
           <2,1>,<2,2>,<2,3>,<2,4>,<2,5>,
           <3,1>,<3,2>,<3,3>,<3,4>,<3,5>,
           <4,1>,<4,2>,<4,3>,<4,4>,<4,5>,
           <5,1>,<5,2>,<5,3>,<5,4>,<5,5>};
     
       
     Cost=[0, 40, 60, 70, 50,
           40, 0, 10, 80, 90,
           60, 10, 0, 130, 75,
           70, 80, 130, 0, 60,
           80, 90,75, 60, 0];
           
     demand= [ 0, 2, 0, 4, 6,
               6, 0, 10, 5, 7,
               4, 5, 0, 1, 8,
               10, 2, 11, 0, 3,
               1, 5, 8, 7, 0];
               
                        

     PenaltyCost= [ 0, 60, 80, 90, 70,
                    60, 0, 30, 100, 110,
                    80, 20, 0, 150, 95,
                    90,100, 150, 0, 80,
                    70, 110, 95, 80, 0];

     

    it will work better

     

    There was a typo in Arcs in the .dat

     

    in the .mod I changed

     

    setof(arc) Arcs       = {<i,j> | ordered i,j in Locations};

     

    into

     

    setof(arc) Arcs       = ...; //{<i,j> | ordered i,j in Locations};

     

    regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Formulation on cplex of VAP

    Posted Mon May 05, 2014 03:16 PM

    Originally posted by: stathis_d


    Hey, 

    thanks for you help but once again doesn't work. Cplex gives errors for all the data  "data item "1" unexpected for Arc" and even if i delete one line in each of them afterwards cannot extract objective and first constraint. I guess something is going wrong with the locations- arcs declaration but  i can't find what.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Formulation on cplex of VAP

    Posted Tue May 06, 2014 09:34 AM

    Hi,

    let me attach a version that does not give any error.

    Regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: Formulation on cplex of VAP

    Posted Tue May 06, 2014 11:27 AM

    Originally posted by: stathis_d


    Hi Alex , 

    thanks a lot for your help so far. It is true that the version that you attached works but doesn't give any solution and probably major transformations are needed. I created a new .mod and .dat  today with all the features ,because i had some additional information yesterday, but still there are problems and doesn't run properly i get a weird error " Exception from IBM ILOG concert: IloIntRangeI::getValue(IloInt index). 

    The problem is :  I have idle vehicles at some locations @t (yiit- inventory) and according to the demand from i to j they are moving, if not the required number of vehicles exist then  empty ones  ordered from other locations . The algorithm according to the penalty cost decide  from which location. The next period the number of idle vehicles change and the algorithm should run to find again all the above. The data again I created by myself don't know if there is a problem on them. 

    I hope that i will not sound greedy if i ask you to take a look whenever you can. My professors don't know how cplex works and this forum is my only help. Thanks in advance ! 


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: Formulation on cplex of VAP

    Posted Wed May 07, 2014 09:48 AM

    Originally posted by: stathis_d


    Hey Alex , 

    never mind ! the model doesn't work I have tried couple of stuff and the last constraint  create problems with the inventory ! If u want take a look in the 2 following the only error that i have is that  cannot extract expression on 1st constraint but don't know how to handle it . i will uploaded as a separate topic also maybe you or someone else can help. Thank u very much for your time and the help you offer me so far .. 


    #DecisionOptimization
    #OPLusingCPLEXOptimizer