I'm building an application that uses Spark to manage optimization models to be solved with CPLEX. I'm creating and storing a bunch of CPLEX artifacts (IloNumVar, IloRange, etc) in Spark RDDs. I'm using IloCplexModeler to create the artifacts.
I've worked out most of the bugs and I've run the application successfully using Java Streams in place of Spark RDDs.
However, when I run with Spark, I get the error
java.io.NotSerializableException: ilog.cplex.IloCplex.
I note that IloCplex implements Serializable, so I'm puzzled about why I'm getting this error. It's a show stopper.
I've done a bunch of research on the web, including checking Stack Overflow, but only a few posts address the integration of Spark with CPLEX, and I can't find any useful code.
Can anyone explain how to work through this issue? Sample code would be greatly appreciated.
BTW, I'm using Java, CPLEX Optimization Studio 12.9, and Spark 3.2.1.
Thanks.