Originally posted by: EdKlotz
>
> Dear EdKlotz,
>
> thanks a lot for your help! You're right, by "command line" I meant the interactive optimizer, so it is very good to know that it doesn't read .mod or .dat files! Basically, the problem I'd like to solve is as follows:
>
> - I have a MILP formulated in OPL
> - The input data for the MILP is generated in a MATLAB model
> - I want to solve the MILP problem, then I want to fix all integers at the optimal solution of the MILP problem and solve the remaining LP (in order to get duals)
> - I want to have the optimal solutions and the duals read into MATLAB
> - Generally, I would like to be able to execute everything just by running a MATLAB script; thus, I could either use the CPLEX toolbox or call the interactive CPLEX optimizer or OPLRUN by command line
> - And.. I would like to be able to also set parameters, e.g., for probing.
>
> At the moment I see two alternatives:
> Alternative A)
> - Write my input data from MATLAB to a .dat-file
> - In the OPL model (*.mod), I could include scripting ("main"-command) and solve first the MILP, write all results to output files, then solve the fixed MILP, write optimal solution and duals to output files.
> - Read in the output files in MATLAB
>
> Alternative B) which I just figured by your help:
> - Export my OPL model to LP file
> - Use the CPLEX class in MATLAB: read in the model, use directly data existing in MATLAB, perform the two optimizations, and the optimal solutions and dual can be retrieved directly by in MATLAB
>
>
> So you would recommend alternative B? And can I do everything I mentioned above with the MATLAB toolbox? Then I will try this out, unfortunately, I can't access the IBM servers containing the references for CPLEX in MATLAB and CPLEX class API. It has been a couple of days and I hope I will be able to access them soon and to try out alternative B)!
>
I agree with you that both A) and B) are viable options for you to consider.
I think you could also consider making use of MATLAB's ability to call external
programs. So, you could use MATLAB to generate the data for the mod file, then
have it call a program written in C++ or Java that calls the OPL API to solve
the model. This requires more programming, but it results in a more integrated
application with much less passing of data through files.
Overall, I think B) works a little better than A). However, A) has one advantage in that it involves writing the data to disk instead of the LP
or MPS file. That LP or MPS file is much larger, so potentially the
file I/O time is greater. Or, if your models can get really big, you have
the potential to consume significant disk space. However, if the models
are modest in size, this really should make much of a difference.
In general, you want to try to keep the file I/O in an application to a minimum,
which is why I mentioned a third option that potential has no file I/O at all.
However, the importance of minimizing file I/O depends on what you are trying
to do. If your work is primarily for research, proof of concept, or prototyping, it's not very important. But, if you plan to create an application that will be run in an industrial setting, then it becomes more
significant.
#CPLEXOptimizers#DecisionOptimization