Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  How to read parentheses or brackets using CPLEX

    Posted 04/03/17 08:07 PM

    Originally posted by: ddoc


    I am trying to read a .lp file using CPLEX, and it is giving me an error 1615, which is not being able to read "(" or even "[". I am not happy with it because what I have needs to be read must have parentheses in it. Here is what I have:

    [num1 + num2 + num3 + num4 + num5] * 1/12

    First of all, I don't know how CPLEX would take in the multiplication sign. So, instead I have:

    [num1 + num2 + num3 + num4 + num5] 1/12

    And, then it may not be able to read fractions or the division sign. I am not even sure how to write this, so that it reads it. I can't solve the problem unless CPLEX reads the file successfully.


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: How to read parentheses or brackets using CPLEX

    Posted 04/04/17 02:45 AM

    What exactly are you doing? What is the function you are using? What do you mean by "reading a text file"? CPLEX does not read arbitrary text files. It reads model and/or data files. These files must follow a specific format. The supported file formats can be found here.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: How to read parentheses or brackets using CPLEX

    Posted 04/04/17 07:13 AM

    Originally posted by: ddoc


    I have a MIP problem formulation with over 4000 constraints. All those constraints are in a .lp file. I am sorry I said text file. And, there are about 400 of those constraints in that format of parentheses or brackets. Neither works anyways.


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: How to read parentheses or brackets using CPLEX

    Posted 04/04/17 08:01 AM

    As you can see here, the LP file format does not support parenthesis or brackets in the way you used them. Nor does it support quotients specified using a '/'.

    Square brackets and a "/2" term are exclusively supported in quadratic objectives or constraints. Something like

    [num1 + num2 + num3] * 1/12

    has to be written as

    0.083333 num1 + 0.083333 num2 + 0.083333 num3

    I wonder how you ended up with that LP file? If you created this LP yourself you will have to change the way you create it. If someone else created the file you will have to ask them to give you a file that conforms to the LP format.

    Since 1/12 is not exactly representable as a double precision floating point number you may want to consider scaling your expression by 12 in order to avoid numerical issues.

    You may also want to take a look at OPL. This is a higher level modeling language that allows stating constraints in a more flexible way. Using Python or C++ to state your model may be another option.


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: How to read parentheses or brackets using CPLEX

    Posted 04/04/17 09:54 AM

    Originally posted by: ddoc


    I am generating a output text file using Python, and then copying and pasting the content from that text file into LPsolve and from there saving it as a .lp file, and then reading it using CPLEX. I even changed the Python code so that it is compatible with LPsolve, but LPsolve also is not able to read parentheses, etc. I don't know how accurate it would be to use 0.08333, but it can certainly be done that way. 

     

    I looked at OPL, and I am not very clear about what it's purpose is. Do you think you could possibly guide on how I am use OPL for my problem?


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: How to read parentheses or brackets using CPLEX

    Posted 04/04/17 11:00 AM

    Are you aware that CPLEX has a Python interface? So you can directly create your model in Python and then solve in Python as well. Wouldn't that solve all your issues? If need be you can also export the CPLEX model as LP file after construction it in Python.


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: How to read parentheses or brackets using CPLEX

    Posted 04/04/17 11:02 AM

    Originally posted by: ddoc


    I don't know how to do any of that. If you could just tell me how to do it step by step then that will help me.


    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: How to read parentheses or brackets using CPLEX

    Posted 04/04/17 11:19 AM

    You should take a look at the many examples that ship with CPLEX. There are examples for all the APIs that CPLEX supports. For Python examples look at cplex/examples/src/python in your installation folder. Also have a look at the CPLEX Python reference manual and the installation instructions for CPLEX Python.


    #CPLEXOptimizers
    #DecisionOptimization