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
The DOcplexcloud client class.
url
key
verbose
new(url, key, verbose=FALSE)
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)
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(...)
...
Extra parameters passed to httr
.
deleteAllJobs(...)
...
Extra parameters passed to httr
.
waitForCompletion(job, waittime=Inf, ...)
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, ...)
job
The DOcplexcloudJob
or a job URL.
...
Extra parameters passed to httr
.
deleteJob(job, ...)
job
The DOcplexcloudJob
or a job URL.
...
Extra parameters passed to httr
.
executeJob(job, ...)
job
The DOcplexcloudJob
or a job URL.
...
Extra parameters passed to httr
.
getJobStatus(job, ...)
job
The DOcplexcloudJob
or a job URL.
...
Extra parameters passed to httr
.
getJobLogs(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",...)
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", ...)
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, ...)
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, ...)
job
The DOcplexcloudJob
or a job URL.
...
Extra parameters passed to httr
.
copyJob(job, shallow=FALSE, overide_data="", ...)
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.
## 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") ## ---------------------------------------------