The client makes it easier to work with the solve service by encapsulating the connection parameters (connection URL, API key). The client also provides support for features of the DOcplexcloud solve service that are not tied to a particular job, such as listing all of the jobs for the current user or deleting all jobs.

DOcplexcloudClient

Format

The DOcplexcloud client class.

Fields

url
The DOcplexcloud URL.

key
The DOcplexcloud API key.

verbose
If TRUE, sets the verbose mode.

Methods

new(url, key, verbose=FALSE)
Initializes a new client with the specified url and key parameters.

If url is not specified, the value of environment variable DOCPLEXCLOUD_URL is used. If key is not specified, the value of the environment variable key is used.

When verbose is TRUE, extra information is printed when the client API is called.

submitJob(..., wait=TRUE)
Submits a job for execution.

This method creates the job, upoads the attachments, submits an execution request, then waits for completion of the job, unless wait is FALSE.

compression The compression algorithm used to compress data before it is send. The compression can be "none" or "gzip"

... Extra parameters passed to httr.

Returns a DOcplexcloudJob.

getAllJobs(...)
Returns all jobs for the current user.

... Extra parameters passed to httr.

deleteAllJobs(...)
Delete all jobs for the current user.

... Extra parameters passed to httr.

waitForCompletion(job, waittime=Inf, ...)
Waits for the specified job to complete.

job The DOcplexcloudJob or a job URL.

waittime The maximum time to wait, in seconds. This default is Inf if not specified.

... Extra parameters passed to httr.

Upon a time out, the last known execution status of the job is returned.

Returns the job execution status, which can be: CREATED, NOT_STARTED, RUNNING, INTERRUPTING, INTERRUPTED, FAILED, PROCESSED

abortJob(job, ...)
Aborts the specified job.

job The DOcplexcloudJob or a job URL.

... Extra parameters passed to httr.

deleteJob(job, ...)
Deletes the specified job.

job The DOcplexcloudJob or a job URL.

... Extra parameters passed to httr.

executeJob(job, ...)
Submits an execution request for a job.

job The DOcplexcloudJob or a job URL.

... Extra parameters passed to httr.

getJobStatus(job, ...)
Returns the execution status of a job.

job The DOcplexcloudJob or a job URL.

... Extra parameters passed to httr.

getJobLogs(job, ...)
Downloads the logs for the job.

job The DOcplexcloudJob or a job URL.

... Extra parameters passed to httr.

Returns a character string containing the job logs.

createJob(attachments=NULL, compression="gzip",...)
Creates a new job. The specified list of attachments is uploaded.

attachments A list of attachments.

compression The compression algorithm used to compress data before it is send. The compression can be "none" or "gzip"

... Any extra arguments of type DOcplexcloudAttachment (for instance, created with link{addAttachment}) are combined with attachments. Any other extra parameters are passed to httr.

Returns The job URL.

uploadAttachment(job, attachment, compression="gzip", ...)
Uploads the specified attachment for a job. Data are compressed using the specified compression.

job The DOcplexcloudJob or a job URL.

attachment A DOcplexcloudAttachment attachment specification. See addAttachment.

compression Specifies the compression algorithm to use. Currently, supported values are: "none" or "gzip"

... Extra parameters passed to httr.

getAttachment(job, name, convert=TRUE, ...)
Downloads the specified attachment.

Attachments are always returned as raw data, unless the attachment ends with ".json". In that case, the JSON file is downloaded, parsed, and converted from JSON, unless convert is false.

job The DOcplexcloudJob or a job URL.

name The name of the attachement.

convert If TRUE, the method tries to convert the attachment to a data structure that is ready for use (example: parse JSON).

... Extra parameters passed to httr.

getJobInfo(job, ...)
Returns job info for the specified job.

job The DOcplexcloudJob or a job URL.

... Extra parameters passed to httr.

copyJob(job, shallow=FALSE, overide_data="", ...)
Creates a new job by copying an existing job.

The existing job must not be running or waiting for execution. All creation data are copied over to the new job. By default, the input attachments and their contents are copied in the new job. If a shallow copy is requested, the new attachment will point to the existing job, and, if it is deleted, accessing the attachment wil raise an exception. Output attachments are not copied. Optionally, job creation data can be passed to override the parameters and declare additional or replacement input attachments.

job The DOcplexcloudJob or a job URL.

shallow Indicates if the copy is shallow.

override_data Data to override as a JSON formatted string.

... Extra parameters passed to httr.

Returns The job URL.

Examples

## Not run: ------------------------------------ # # Create a new client, using environment variables for URL and API key # client <- DOcplexcloudClient$new() # # # Create and execute a job to solve model.lp # job <- client$submitJob(addAttachment(file="model.lp")) # # # Create and execute a job which model is stored # # in memory # model <- "Minimize # obj: x + y # Subject To # Bounds # 3 <= x <= 17 # 2 <= y # End" # job <- client$submitJob(addAttachment(name="model.lp", # data=charToRaw(model))) # # Download solution # solution = client$getAttachment(job, "solution.json") ## ---------------------------------------------