Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

OPL General Questions & syntax error issues

  • 1.  OPL General Questions & syntax error issues

    Posted Tue June 05, 2012 03:57 AM

    Originally posted by: SystemAdmin


    Hi,

    I have following errors and questions to be asked.
    First, I have few questions about OPL.

    Using OPL, is it possible to extract a complete output?
    Does OPL support graphical output like plotting charts by extracting information from the output?
    How to save the OPL model to LP format in the same code?
    I would like to put a question on comparison between OPL and MATLAB here....From all my previous questions which one do you suggest me the best and easy option to formulate my model?
    I also noticed the difference between CPLEX C++ concert and MATLAB....because using C++ I could able to read my LP model and display a complete output list for my model. But in MATLAB if I read in a LP model file, then I could get a output just the objective value being written to a file since writeSolutions method doesn't support in MATLAB.

    I am confused please kindly suggest me here....

    Now I have few errors to sort out....
    float LinkPowerLinks = (CapacityLinks<1000) ? 60 : (CapacityLinks<2000) ? 100 : (CapacityLinks<4000) ? 140 : (CapacityLinks<10000) ? 174 : 0 ;

    The above line throws the error as "Cannot use type range for int" in my OPL model

    next error here below,

    *fs, d, l == sum (i in MaxPath) (Pathsi, s, d, l * Demands, d * ai, s, d);*

    the above line throws an error as "Not an array type" in my OPL model

    I kindly request you to help me as soon as possible since I am struck and need an urgency to finish my task.
    Thanks a lot!!!
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: OPL General Questions & syntax error issues

    Posted Wed June 06, 2012 05:11 AM
    Hi,

    which version do you use?

    float CapacityLinks=1;
     
    float LinkPowerLinks = (CapacityLinks<1000) ? 60 : (CapacityLinks<2000) ? 100 : (CapacityLinks<4000) ? 140 : (CapacityLinks<10000) ? 174 : 0 ; 
     
    execute
    {
      LinkPowerLinks;
    }
    


    works fine

    Regards
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: OPL General Questions & syntax error issues

    Posted Wed June 06, 2012 05:53 AM

    Originally posted by: SystemAdmin


    Hi,

    Thanks for the reply. I am using Academic 12.4 version.
    I am facing a strange error now but for a constraint here shown below,
    forall ((i in MaxPath*,* s in Nodes, d in Nodes) and (sum(l in Links)(Paths[i][s][d][l] == 0)))

    It throws an error "syntax error unexpected ',' " . I have highlighted as bold exactly in the for loop where does this error occur. I am unable to debug this Kindly help me.
    Thanks
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: OPL General Questions & syntax error issues

    Posted Wed June 06, 2012 05:59 AM

    Originally posted by: SystemAdmin


    Hi,

    Please kindly respond to my general questions as well, which I raised in the first post of this thread. It would be of great help for me to understand.
    Thanks
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: OPL General Questions & syntax error issues

    Posted Wed June 06, 2012 06:43 AM
    Hi,

    if you want to post some code, please use {code}.

    Some answers for your questions:

    Using OPL, is it possible to extract a complete output?

    --> yes with the function writeSolution in the class IloOplModel

    Does OPL support graphical output like plotting charts by extracting information from the output?

    --> No but with an external java call you can do any charts you want. If you use ODME then you have access to graphical views.

    How to save the OPL model to LP format in the same code?

    --> In a main block, you can do exportModel on the Cplex object

    Regards
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: OPL General Questions & syntax error issues

    Posted Wed June 06, 2012 07:44 AM

    Originally posted by: SystemAdmin


    Hi,

    Thanks for the info. I will use the markup hereafter properly.
    Is IDME possible to interface with the existing IBM ILOG Academic version???
    I have one more question. In my model, I am actually using a boolean parameter which is an input to my optimization model. But it says only for decision variables boolean type supports. But my plan is to use that boolean parameter in the data model file. How can I initialize my parameter as boolean in the OPL model?
    Kindly help me

    Thanks
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: OPL General Questions & syntax error issues

    Posted Wed June 06, 2012 09:25 AM
    Hi,

    ODME is not available in academic initiative.

    The boolean type does not exist as data in OPL but you can use int.

    int booleanValue=1;
    


    regards
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: OPL General Questions & syntax error issues

    Posted Mon June 11, 2012 03:18 AM

    Originally posted by: SystemAdmin


    Hi,

    I have a data file in which I have two parameters Demand and Paths.

    Look at my data_model.dat file in attachment
    Demand

    I have declared the value for each source and destination nodes in an array. I want to represent in the same way. In order to represent in the same approach how should I declare and initialize in the OPL(.mod) model file?
    Paths

    Parameter Paths is a boolean type shown. This also forms an array type. Where you could see one example,

    i,s,d,l where l is an array denoted with * and it has a value followed with boolean 1 since it is declared as binary. If you look at the file you will get an idea about my data model.

    I dont want to disturb my data model file as I have worked in other open source solvers and it works perfectly fine. I would like to use the same data file and model it accordingly in OPL.
    I am facing a problem to adopt my model as per the data model I have. Kindly help me as it will help me a lot to sort out my problem.
    Thanks!!!!
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 9.  Re: OPL General Questions & syntax error issues

    Posted Mon June 11, 2012 03:58 AM
    Hi,

    maybe you could have a look at

    IDE and OPL > Optimization Programming Language (OPL) > Language Reference Manual > OPL, the modeling language > Data sources > Data initialization

    where you can see

    An array can also be initialized by specifying pairs (index, value), as in the declaration:

    /* .mod file */
    int a[Days] = ...;
    /* .dat file */
    a = #[
    “Monday”: 1,
    ”Tuesday”: 2,
    ”Wednesday”: 3,
    ”Thursday”: 4,
    ”Friday”: 5,
    ”Saturday”: 6,
    ”Sunday”: 7
    ]; #
    


    which is similar to the way you use data.

    Regards
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 10.  Re: OPL General Questions & syntax error issues

    Posted Mon June 11, 2012 04:11 AM

    Originally posted by: SystemAdmin


    Hi,

    Thanks. But what about Parameter Paths in my data model file. Since it is declared as binary for the last argument l which is represented as * (array) in my data model file will represent the value one(1) as boolean as you could see in my data model file. How can I represent this ans make use of in OPL model file?
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 11.  Re: OPL General Questions & syntax error issues

    Posted Mon June 11, 2012 05:50 AM

    Originally posted by: SystemAdmin


    Hi,

    Kindly help for my previous question in this thread. As I dont have a clue how to approach....I am in need of help urgently....
    Thanks in Advance!!!
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 12.  Re: OPL General Questions & syntax error issues

    Posted Mon June 11, 2012 07:41 AM

    Originally posted by: SystemAdmin


    Hi,

    I have a following problem in my model. I have a parameter Paths which is a binary type. It's notation is,
    {*Pathsi,s,d,l* }

    i - index of path
    s - source node
    d - destination node
    l - link occurs in that path
    In my data model, I have represented as,
    {Paths1,2,9,* 2 1 3 1 4 1 5 1 6 1 }
    Here in the above example, for index i, source node 2 and destination node 9, the links such as 2,3,4,5,6 forms a path, where it is said as 1 since this parameter checks if the link is available or not and then returns the boolean value. Here, those links mentioned will return 1 since it contains the links in that path.
    I would like to represent in dat and OPL model for this approach. I am struck and dont have any clue. Kindly help me as soon as possible.
    Thanks!!!
    #DecisionOptimization
    #OPLusingCPLEXOptimizer