On fixing CPLEX variable names generated by OPL

You wrote your OPL model for your important mathematical programming problem. But the result looks weird: the model just cannot produce such solution. The most desperate approach consists in diving though the mathematical programming model generated by OPL, checking each (in)equation one by one.

Here I describe some issues that happened while using the OPL Java interface to create the CPLEX model and to print out the mathematical programming model as a .lp file. And after days of frustration with this .lp printout, I found myself writing my own Java class that renames all CPLEX variables generated by OPL…

Read more of this post

Java: Class.forName() to retrieve inner class

Sounds trivial, but was not obvious because Eclipse IDE mislead me: How do I get a reference to a inner class by calling Class.forName() ?

package a.b.c;
public class Outer {
   ...
   public static class Inner {
      ...
   }
   ...
}

I first tried to call Class.forName() passing as parameter the fully qualified name generated by Eclipse:

Class innerClass = Class.forName("a.b.c.Outer.Inner");

But that was wrong! After wondering for some time, I found the (obvious solution):

Class innerClass = Class.forName("a.b.c.Outer$Inner");

Looks like as Eclipse “fully qualified” name is not exactly the same fully qualified name that the Java compiler uses to identify inner classes.