Originally posted by: AsToN
Ok, I have prepared a little example using parts of my code and based on a test dataset which I also provide. The m-file 'crashtestCplex' runs the code and the relevant function called is 'crashtestCplexSolve'. The rest just builds/finishes the data. Note that it is not the full code but it includes the relevant parts. Plus it behaves exactly like the full version, I have checked that. So it does show the same weird behaviour throwing fatal erros in an irregular manner. But remember, I also provided a little example once, based on one of CPLEX' very own examples (blend.m) and this also crashed on my system but apparantly not on yours. However, this is the best I can do, and if you don't get this to crash then I guess it is specific to certain system setups.
A few notes on what I have observed so far:
First, the error is not dependent on running the code in parallel (parfor loop for example) or if you run it in a standard sequential loop. Probably you don't need to loop at all, I just do it because it maximizes the chances of a crash (since the error is irregular).
Second, the error seems to involve the building of the object class 'cplex'. It usually does not immediately crash when invoking model = Cplex(); but rather a few moments later. From what I observe when I debug the code step by step the cplexlink-mex file doesn't properly build the object structure. That means it does build the upper levels of the structure but it fails to create the structure fields on the lowest of levels, specifically of the 'Params'-substructure (e.g. the field 'Cur' where you alter the parameter values). Those fields are either not created at all or they are created but not filled with values (i.e. they are completely empty).
Now this failure of creating the object's structue of the 'cplex' class seems to cause the crash. Now usually Matlab would simply throw an ordinary error when trying to access fields which are not existing. However, even though that happens sometimes (namely whenever the procedure survives long enough to allow Matlab to throw this error), the usual behaviour is that Matlab simply terminates with a fatal crash. So summing up, Matlab orders to builds the cplex object, the mex funtion fails to so properly (it builds an incomplete structure), Matlab (or if no further parameters are changed, Cplex itself when trying to start its solving procedure) tries to access fields which don't exist. But Matlab usually doesn't even get to throwing an eception since the cplex-mex function terminates with an error causing Matlab to crash.
Note also that it doesn't help to pause a while after invoking the cplex-object in order to allow the mex-function some more time. I've tried and it does not seem to change anything.
Third, whenever the structure is build properly the whole procedure is fine. It never crashed during an active Cplex solving procedure.
Forth, the error is happening on different operating systems. I personally tried RedHat Linux and Windows 7 both with Matlab R2017a and CPLEX 12.7.1 (both are academic versions).
I hope this helps!
Best, AsToN
#CPLEXOptimizers#DecisionOptimization