IBM Decision Optimization for Bluemix (DOcplexcloud) allows to solve optimization problems on the cloud.
This sample shows how you can build a simple Node.js application that use the Decision Optimization for Bluemix. It demonstrates how to use the Node.js Client to submit a problem to the optimization solver engine (CPLEX) , get the results and monitor your jobs.
There are two ways to deploy the sample to Bluemix, automatically in one click or by cloning the sample to your local environment
Note that you need to have a Bluemix account. Sign up for Bluemix, or use an existing account.
Click the button below:
Then just follow Bluemix instruction during & after deployment
Note that you need to have a Bluemix account. Sign up for Bluemix, or use an existing account.
-
Download and install the Cloud-foundry CLI tool
-
Clone the app to your local environment from your terminal using the following command
git clone https://github.com/IBM-Bluemix/docplexcloud-helloworld-nodejs.git
-
cd into this newly created directory
-
Edit the
manifest.yml
file and change the<application-name>
and<application-host>
fromDOcplexcloud-app
to something unique.applications: - name: DOcplexcloud-app host: DOcplexcloud-app memory: 256M - services: - DOcplexcloud-service
The host you use will determinate your application url initially, e.g. <application-host>.mybluemix.net
.
Note: If you use a name other than DOcplexcloud-service
for the service name, you need to update this in the app.js
file.
-
Connect to Bluemix in the command line tool and follow the prompts to log in.
cf api https://api.ng.bluemix.net cf login
-
Create the Decision Optimization for IBM Bluemix service.
cf create-service docplexcloud ODSTRIAL DOcplexcloud-service
-
Push the application to Bluemix.
cf push
-
To work locally on your machine, copy the file
vcap-local.template.json
tovcap-local.json
:cp vcap-local.template.json vcap-local.json
-
Replace the credentials with values from your service
{ "docplexcloud" : [ { "name" : "DOcplexcloud-service", "label" : "docplexcloud", "plan" : "ODSTRIAL", "credentials" : { "url" : "YOUR_BASE_URL", "client_id" : "XXX", "subscriptionId" : "YYY" } } ] }
-
Install the server dependencies
npm install
-
Start the server
node app.js
The server starts locally, for instance on
http://localhost:6002
This sample is delivered under the Apache License Version 2.0. See License.txt.
The DOcplexcloud NodeJS Sample web application includes code to track deployments to Bluemix and other Cloud Foundry platforms. The following information is sent to a Deployment Tracker service on each deployment:
Application Name (application_name)
Space ID (space_id)
Application Version (application_version)
Application URIs (application_uris)
This data is collected from the VCAP_APPLICATION environment variable in IBM Bluemix and other Cloud Foundry platforms. This data is used by IBM to track metrics around deployments of sample applications to IBM Bluemix. Only deployments of sample applications that include code to ping the Deployment Tracker service will be tracked.
Deployment tracking can be disabled by removing require("cf-deployment-tracker-client").track(); from the beginning of the app.js file.