DO for WML with Java in one line

AlainChabrier
3 min readDec 9, 2020

--

Some code to control Watson Machine Learning (WML) models, deployments and jobs that can be used with Decision Optimization (DO) models was commented in a previous post.

The referenced github repository provided classes and methods to deploy and run models with some fine control, for example to create and monitor different jobs of the same model with different data.

On the other hand, this fine control API may not be so easy to use for someone who is starting from an existing Java CPLEX code creating and solving an optimization model. So a simpler to setup alternative has been implemented which is now available which allows to run the optimization on WML from within an existing Java code with almost a single line of code changed.

Why use it?

Cloud Pak for Data (CP4D) is a complete platform for Data and AI. It packs together lots of useful technology, including Machine Learning and Decision Optimization. All these technologies can be used together to develop new AI based solutions.

But what benefits would an existing application of DO, developed years ago and which is working fine, gain by moving to CP4D?

CP4D is based on a modern service oriented architecture. It allows to factorize hardware and software resources and we all know how DO can be resource consuming for production usages. Some models might require multiple cores and important amount of memory to solve models optimally in the required amount of time. And many times, these cores and memory are not be used all the time. A centralized hardware with service architecture allows to share the resources among several processes and applications.

Imagine you have some optimization based application running at different places which requires to solve huge problems a few days each month, and hence requires important hardware resources to be set up and maintained in each place for only a few hours of usage each month.

Imagine now that you can easily have the workload be moved to a central place and shared by all these applications…

This sounds attractive but the main opposition would be about the time and cost required to execute this modernization. The initial fear is to need to re-architecture the applications and involve lots of new development.

This is why DO for WML with Java has been improved with an alternative approach which allows to have some existing Java code being able to delegate the optimization of the model to a remote WML service, and with only a few lines of code changed.

How to use it?

From an existing Java code starting with:

IloCplex cplex = new IloCplex();

You can get the model to be solved in WML by simply using:

IloCplex cplex = new WmlCplex(credentials, runtime, size, numNodes);

For example,

IloCplex cplex = new WmlCplex(
Credentials.getCredentials(ConfigFactory.parseResources("wml.public.conf").resolve()),
Connector.Runtime.DO_12_10,
Connector.TShirtSize.M,
1)

Where to get the code?

The https://github.com/IBMDecisionOptimization/DOforWMLwithJava repository has been updated. The former fine control classes still exist and have also been polished. The new set of WMLCplex and WMLCP classes are now also available.

Please refer to the README for documentation.

This code is currently provided as a contribution. It has some obvious limitations due to the architecture where the modeling is occurring locally and the optimization within WML (e.g. control callbacks cannot be implemented efficiently). In some cases, these limitations will have no impact at all (when control callbacks are not required and the time to transfer the model is low with respect to the time to solve it). In some other cases, these limitations might result in this approach being invalid.

Anyway, the cost to try is really small! We would be happy to hear your feedback on this new mechanism.

--

--

AlainChabrier

Former Decision Optimization Senior Technical Staff Member at IBM Opinions are my own and I do not work for any company anymore.