This project demonstrates the development, testing, deployment and verification of a Decision Optimization Java worker in Watson Machine Learning in the following products:
- Cloud Pak for Data as a Service,
- Watsonx.ai,
- Cloud Pak for Data 4.8.x or later.
- Install JAVA 17 JDK.
- Install Apache Maven for mvn command.
- Install Conda or any Python and add the Python executable file name to your PATH.
- Install IBM watsonx.ai Python client with
pip install ibm-watsonx-ai
. - Install IBM ILOG CPLEX Optimization Studio (The compilation and modeling can be done with the Community Edition of CPLEX that is freely available.)
This section describes how you will configure your maven pom.xml and settings.
- Set up the cplex_version property that you target in the pom.xml file and install the corresponding CPLEX or CP jar in your local maven repository. For example, if you target
cplex_version=22.1
, to install the cplex-jar in your maven local repository, use the following command:
mvn install:install-file "-Dfile=%CPLEX_STUDIO_DIR%\cplex\lib\cplex.jar" -DgroupId=com.ibm.ilog.optim -DartifactId=cplex-jar -Dversion=22.1 -Dpackaging=jar
and to install the cpo-jar in your maven local repository:
mvn install:install-file "-Dfile=%CPLEX_STUDIO_DIR%\cpoptimizer\lib\ILOG.CP.jar" -DgroupId=com.ibm.ilog.optim -DartifactId=cpo-jar -Dversion=22.1 -Dpackaging=jar
- Accordingly, set up the cplex_library_path property to target the CPLEX or CPO native library for your OS.
- Now you can execute the commands
mvn compile
ormvn test
in your project directory.
If you want to verify the deployment to a Watson Machine Learning cluster, you must specify the Watson Machine Learning environment that you want to target during your tests.
- Update the profiles in your pom.xml or settings.xml file for your needs (environment authentication details):
<profiles>
<profile>
<id>wml_test_environment_cloud</id>
<properties>
<wml_location>CLOUD_WML_CLUSTER</wml_location>
<wml_api_key>MY_APY_KEY</wml_api_key>
<wml_space_id>MY_SPACE_ID</wml_space_id>
<wml_deployment_size>S</wml_deployment_size>
</properties>
</profile>
<profile>
<id>wml_test_environment_cp4d</id>
<properties>
<wml_location>CP4D_WML_CLUSTER</wml_location>
<wml_username>MY_USERNAME</wml_username>
<wml_password>MY_PASSOWRD</wml_password>
<wml_space_id>MY_SPACE_ID</wml_space_id>
<wml_deployment_size>S</wml_deployment_size>
</properties>
</profile>
</profiles>
- Now you can execute the commands
mvn -P <profile_name> verify
ormvn -P <profile_name> install
in your project, where<profile_name>
iswml_test_environment_cloud
orwml_test_environment_cp4d
.