Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Writing a .sol file with specific variables

    Posted 04/23/17 10:19 AM

    Originally posted by: story_


    Hi,

    I am solving two MIPs using CPLEX 12.7, where one provides a starting solution to another. I am using the methods writeMIPStarts and readMIPstarts to define the starting solutions. Some of the variables used in these problems are different, thus I would like to exclude them from the .sol file. I have considered changing the parameter "WriteLevel" for this purpose, however some of the variables I need to store are continuous, where the rest are discrete variables.

    I was wondering if there is a way to write a .sol file that only includes the values of a specific set of variables to overcome this issue. Many thanks for your help in advance.


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Writing a .sol file with specific variables

    Posted 04/23/17 04:20 PM

    It would help to know how you are solving the models: interactively; via OPL models and scripts; or using a programming API (in which case, which API).

    Paul

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Writing a .sol file with specific variables

    Posted 04/24/17 03:05 AM

    The only way to control which variables are written to a SOL file is the write level. However, there are two other easy options for you:

    1. Write out the SOL file with all variables then filter out the variables you don't want before reading the SOL file.
    2. Create an MST file manually by grabbing the x vector and write out only the variables you need.

    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Writing a .sol file with specific variables

    Posted 04/24/17 10:21 AM

    Originally posted by: story_


    Many thanks for your response.

    I am using Java API. The problem that provides the starting solution is simply the relaxation of the binary variables in the main problem.

    I have tried to manually create .sol files using Java, however I am getting the error: "CPLEX Error  1425: XML parsing error at line 6: junk after document element."

    I am guessing that I might have missed some main elements or made a mistake regarding the formatting of the .sol file. 


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Writing a .sol file with specific variables

    Posted 04/24/17 05:40 PM

    If you are doing all this within one Java program (solve auxiliary problem, torture result to get a starting solution, feed it to main problem, solve main problem), you can bypass writing and reading of files entirely. Just use the IloCplex.addMIPStart method on the main problem, feeding it the variables and values you would have set in the solution file.

    If there are two separate programs involved, then I second Daniel's response. You can write the full solution with a single call to IloCplex.writeSolution (and avoid having to screw with manually creating an XML file). Creating an MST file is more work, but I think the file format is pretty simple.

    Paul

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Writing a .sol file with specific variables

    Posted 04/25/17 03:39 AM

    The CPLEX installation has a schema file here: cplex/include/ilcplex/solution.xsd. If you create the solution file manually and experience problems then you should validate your file against that schema. The file format is actually pretty simple, so you probably made a mistake that is easy to fix.


    #CPLEXOptimizers
    #DecisionOptimization