Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

double indexation using SQL query

  • 1.  double indexation using SQL query

    Posted Tue March 15, 2011 08:26 AM

    Originally posted by: davidoff


    Hello

    Is it possible to query a DB to index a two-dimensional array ?

    I tried this in the .mod
    {int} points1 = ...;
    {int} points2 = ...;
    int dist[points1][points2] = ...;
    


    and this in the .dat file
    points1,points2,dist fromDBRead(db,"select id_point1,id_point2,1 from distances");
    


    This does not work but gives the picture . (Actually, points1 and points2 are the same since the table has all pairs )
    David
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: double indexation using SQL query

    Posted Tue March 15, 2011 08:45 AM

    Originally posted by: davidoff


    Here is a personal workaround

    tuple Dist
    {
            key int point1;
            key int point2;
            int dist;  
    }
     {Dist} distances= ...;
     int dist[d in distances] = d.dist;
     int z = dist[<290,467>];//direct access
    

    and the query
    distances from DBRead(db,"select id_point1,id_point2,distance as minutesTrajet from distances");
    


    i'm afraid the indexation of tuple set distances into a one dimensional "matrix" dist costs (distances contains around 600,000 tuples)
    #DecisionOptimization
    #OPLusingCPLEXOptimizer