Solving OPL models on the cloud
IBM Decision Optimization for Watson Machine Learning makes it possible to solve OPL models on the cloud.
Models available for the cloud
Some of the OPL models can be run on the cloud from the IDE. In the New Example wizard, most of the models are "cloud ready". To work with an example that has been adapted for the cloud, select File > Import > Example, and then IBM ILOG OPL Examples. Click the tab Sorted by Feature, and expand the Watson Machine Learning ready list.

The run configuration of a model can contain zero or any number of plain
.dat files (that is, a .dat file with no Excel statement, or no DB
Link statement). The code in a standalone .mod file must be cloud compliant (it
does not require access to your disk).
Setup for Watson Machine Learning
You need to register for an IBM Cloud account before completing these steps.
Create an IBM Cloud API key.
- Log in to https://cloud.ibm.com.
- Click Manage in the IBM Cloud menu and select Access (IAM).
- On the Access (IAM) page, click API keys then Create an IBM Cloud API key.
- Download your new API key to your local machine.
Create a WML service instance to deploy models
- When logged into IBM Cloud, click Catalog in the menu.
- In the search field, type Machine Learning and press Enter.
Click the Watson Machine Learning tile in your search results.

- Create an instance of the Machine Learning service using the plan of your choice. For example, create a Lite plan in the Dallas region.
Keep your web browser open and logged into https://cloud.ibm.com.
Create a Cloud Object Storage instance and a bucket
- Still logged into https://cloud.ibm.com, click Catalog.
- Type Object Storage in the search field and press Enter.
Click the Object Storage tile in your search results.

- Create an instance of Cloud Object Storage using the plan of your choice.
- Once it's created, click Buckets and select Custom Bucket. Enter a name for your bucket and select a Location, for example us-south.
- Once you’ve created the bucket, click Service credentials.
- On the Service credentials page, click New credential with the Role Manager.
- Click the Advanced options and choose the option Include HMAC Credential, then click Add.
Keep your web browser open and logged into https://cloud.ibm.com.
Create a deployment space to host your WML service
- Still logged into https://cloud.ibm.com, select Resource list.
- In your list of resources, click the name of your WML instance in the Services section.
- On the Watson Machine Learning page, click Access in Watson Studio. This opens Watson Studio in a new browser tab.
- On the Watson Studio home page, click New deployment space and select Create an empty space.
- Enter a name for your deployment space.
The Cloud Object Storage instance that you created should be identified.
Select the WML service instance that you created earlier.
- Click Create.
- Once the deployment space is ready, click View new space.
Set your preferences in CPLEX Optimization Studio
To connect the CPLEX Optimization Studio IDE to Watson Machine Learning you need the following information:
- The IBM Cloud API key you created as part of this procedure: Create an IBM Cloud API key.
- The base URL of your Watson Machine Learning service. This URL depends on the region you selected for your service. For example, the base URL for the Dallas region is https://us-south.ml.cloud.ibm.com. You can find a list of these URLs here: https://cloud.ibm.com/apidocs/machine-learning#endpoint-url
- The instance ID of your WML service. You can access this in IBM Cloud by navigating to your
Resource List and highlighting the WML service instance in the list. This
opens a summary details pane from where you can copy the service GUID.Note: Don't click the name of your WML service, as this will open the Details page. Click elsewhere in the same row of your Resource List.
- The Space ID of your deployment space. You can access this in Watson Studio by navigating to your deployment space and selecting the Settings tab.
To use Cloud Object Storage to keep a copy of your models, results, and logs, you need to specify the information listed here.
It's not essential to use Cloud Object Storage if, for example, you're working on a new model and you don't need to keep copies on the cloud.
- The Endpoint URL of the bucket you will use. This depends on the location you selected for your bucket. For example, if you selected us-south, the URL is https://s3.us-south.cloud-object-storage.appdomain.cloud. You can consult the list of Endpoints in the IDE Preferences panel.
- The name of the bucket that you specified earlier in Create a Cloud Object Storage instance and a bucket.
- The service credentials of your Cloud Object Storage instance. You can copy these in IBM Cloud
by clicking the Copy icon
beside the Service credentials that you created. Once
they're copied, you can paste them directly into the IDE Preferences panel by clicking the
underlined link in the sentence “Click here to paste WML or COS JSON credentials”.
Once you've collected all the information you need, you can enter it in the CPLEX Optimization Studio IDE.
- Launch the CPLEX Optimization Studio IDE and select .
- In the Edit Watson Machine Learning preferences section of the dialog:
- enter your IBM Cloud API key in the API Key field.
- enter the base URL for your WML service instance in the Base URL field.
- enter the ID of your WML service instance in the Instance Id field.
- enter the ID of your Watson Studio deployment space in the Space Id field.
- In IBM Cloud, in your Cloud Object Storage instance, click View credentials beside the service credentials that you created earlier.
- Click the Copy icon
to copy the credentials to the
clipboard. - In the CPLEX Optimization Studio IDE, click the underlined link in the sentence “Click here to paste WML or COS JSON credentials” to paste your Object Storage credentials. Your Access Key and Secret Key are added to the Preferences dialog.
- Click the underlined link in the sentence “Click here to select Endpoint” and select, for
example, the second us-south option from the list then click OK.

- Click Apply and Close.
Running a model in cloud mode
If you select Cloud mode in a settings file, and run a model in your local IDE, all non compliant cloud features will raise an error. This setting helps you develop a model for the cloud on your local machine by checking the local solve more thoroughly. When you run a model with the Watson Machine Learning option, this setting detects OPL statements that are not supported on the cloud although they are supported on premises.

To run a model on the cloud, select the run configuration and right-click to display the menu. Select the option Run this on Watson Machine Learning.

Monitoring jobs in the IDE
The Watson Machine Learning tab in the IDE displays the status of an executed run configuration. Only a run configuration containing a tuple set as a post processing structure will provide a report.

You may need to refresh the Watson Machine Learning view to see the status of your job.
Accessing results or logs
Once you've run a job in the IDE, you can import results or logs by right-clicking the job name in the Watson Machine Learning tab and selecting the appropriate option.
