Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  connection failure

    Posted 06/16/21 08:57 AM

    Hi everyone,

    I am trying to solve an optimization problem using cplex. I am using "MS ACCESS" as my DB. I have defined all the variables required, but I am not sure why I am getting the following error in .mode

    "Data element "nodes" not defined."

    "Invalid initialization expression for element "A"."

    And I am getting the following error in my .dat file:

    I am not really sure which part is the mistake I am doing.... Any hint/help is highly appreciated.

    Here's part of my .mod file codes:

    ===========================

    {string} nodes =...;

    {string} vnr =...;

    tuple NodeProp{

    string node_id;

    int xaxis;

    int yaxis;

    int capacity;

    float energy;

    int type;

    }

    {NodeProp} PNodes=...;

    NodeProp Node[nodes]=[i.node_id: i|i in PNodes];

    tuple edge{

    string FromNode;

    string ToNode;

    }

    setof(edge) edges=...;

    tuple vnrProp{

    int xaxis;

    int yaxis;

    string vnr_id;

    }

    {vnrProp} VNodes=...;

    vnrProp VNR[vnr]=[j.vnr_id: j|j in VNodes];

    tuple vnr_edge{

    string FromVnr;

    string ToVnr;

    float VnrDelay;

    }

    setof(vnr_edge) vnr_edges=...;

    //constants

    float e_tr = 0.000017;

    float e_ov = 0.000005;

    float e_link = 0.0002;

    float maxDist = 30;

    float distance_sensor_vnr;

    int L[nodes][vnr];

    execute{

    function distance(xsen,ysen,xvn,yvn){

    return Opl.sqrt(Opl.pow(xsen-xvn,2)+Opl.pow(ysen-yvn,2));

    }

    for(y in nodes){

    for(z in vnr){

    distance_sensor_vnr = distance(Node[y].xaxis,Node[y].yaxis,VNR[z].xaxis,VNR[z].yaxis);

    if (distance_sensor_vnr<=maxDist){

    L[y][z] = 1;

    }

    else{

    L[y][z] = 0;

    }

    }

    }

    }

    //decision variables

    dvar boolean x[nodes][vnr];

    dvar boolean u[edges][vnr_edges];

    //expressions

    dexpr float A = sum(i in nodes: Node[i].type==1, j in vnr) L[i][j]*x[i][j]*(e_tr );

    dexpr float B = e_tr + sum(i in nodes: Node[i].type==2, j in vnr) L[i][j]*x[i][j]*(e_ov );

    dexpr float C = e_link * sum(p in edges, q in vnr_edges) u[p][q];

    dexpr float D = A + B + C;

    minimize D;

    subject to {

    ....

    }

    =========================

    .dat file:

    DBConnection db("access","Database1.mdb");

    nodes from DBRead(db,"SELECT node_id FROM PNodes");

    PNodes from DBRead(db,"SELECT node_id, xaxis, yaxis, capacity, energy, type, nodes FROM PNodes");

    edges from DBRead(db,"SELECT ID, FromNode, ToNode, PLDelay FROM PLinks");

    vnr from DBRead(db,"SELECT vnr_id FROM VNodes");

    VNodes from DBRead(db,"SELECT vnr_id, xaxis, yaxis FROM VNodes");

    vnr_edges from DBRead(db,"SELECT FromVnr, ToVnr, VnrDelay FROM VLinks");






    #DecisionOptimization
    #Support
    #SupportMigration


  • 2.  RE: connection failure

    Posted 06/16/21 04:51 PM

    OPL database connectivity has evolved a lot. Can you confirm the version of OPL you are using?






    #DecisionOptimization
    #Support
    #SupportMigration


  • 3.  RE: connection failure

    Posted 06/16/21 09:22 PM


  • 4.  RE: connection failure

    Posted 06/17/21 09:31 PM

    I am not seeing a very easy option to let version 12.8 connect to ODBC data sources, including Access. If you can use Excel files as data sources, SheetConnection should work with all versions of OPL. If you can upgrade to CPLEX Optimization Studio 20.1, you can use ODBCConnection https://www.ibm.com/docs/en/icos/20.1.0?topic=support-prebuilt-database-connection-types


    If you need further discussion, please open a case if you are entitled. Otherwise, please discuss your question in Data Science Community https://community.ibm.com/community/user/datascience/communities/community-home/digestviewer?communitykey=ab7de0fd-6f43-47a9-8261-33578a231bb7&tab=digestviewer






    #DecisionOptimization
    #Support
    #SupportMigration


  • 5.  RE: connection failure

    Posted 06/19/21 05:09 AM

    I tried with 4 different versions now (12.8, 12.9, 20.10 and 12.6)

    12.6 is the ONLY version that worked on a colleague machine (not mine yet, still trying to figure out a way on that)

    ===

    I found this link today:

    https://www.ibm.com/support/pages/connecting-data-cplex-optimization-studio-v127It seems that there is NO WAY that we can have ANY type of DB in CPLEX IDE for any version starting from 12.7. Although the description of version 20.10 has mentioned that it supports the DBs, but it is not...

    ============

    I am now have installed a 32 bit win 7 on a VMWare workstation on my machine and installed the 32 bit 12.6 CPLEX on it with the Visual C++ redistribution 10 (for 32 bit) and its driver: AccessDatabaseEngine

    Still failed...

    Getting the following error now:

    Database error (state=22005 code=-6): Value accessor mismatch

    ================

    I am not sure why I am getting this error...









    #DecisionOptimization
    #Support
    #SupportMigration


  • 6.  RE: connection failure

    Posted 06/21/21 11:44 PM

    Version 12.6, 32-bit binaries or Windows 7 are no longer supported. Version 20.1 now supports ODBC connections, which can be used to connect to Access files. Note that you also need to install 64-bit Access (runtime or full product) and write connection strings properly.






    #DecisionOptimization
    #Support
    #SupportMigration