Learn R Programming

raptr (version 0.0.3)

update: Update object

Description

This function updates parameters or data stored in an existing GurobiOpts, RapUnreliableOpts, RapReliableOpts, RapData, RapUnsolved, or RapSolved object.

Usage

# S3 method for GurobiOpts
update(object, Threads = NULL, MIPGap = NULL,
  Method = NULL, Presolve = NULL, TimeLimit = NULL,
  NumberSolutions = NULL, MultipleSolutionsMethod = NULL, ...)

# S3 method for ManualOpts update(object, NumberSolutions = NULL, ...)

# S3 method for RapData update(object, species = NULL, space = NULL, name = NULL, amount.target = NULL, space.target = NULL, pu = NULL, cost = NULL, status = NULL, ...)

# S3 method for RapReliableOpts update(object, BLM = NULL, failure.multiplier = NULL, max.r.level = NULL, ...)

# S3 method for RapUnreliableOpts update(object, BLM = NULL, ...)

# S3 method for RapUnsolOrSol update(object, ..., formulation = NULL, solve = TRUE)

Arguments

object

GurobiOpts, RapUnreliableOpts, RapReliableOpts, RapData, RapUnsolved, or RapSolved object.

Threads

integer number of cores to use for processing.

MIPGap

numeric MIP gap specifying minimum solution quality.

Method

integer Algorithm to use for solving model.

Presolve

integer code for level of computation in presolve.

TimeLimit

integer number of seconds to allow for solving.

NumberSolutions

integer number of solutions to generate.

MultipleSolutionsMethod

character name of method to obtain multiple solutions NumberSolutions > 1. Available options are 'benders.cuts' and 'solution.pool'. Defaults to 'benders.cuts'. Note that the rgurobi package must be to use the 'solution.pool' method.

...

parameters passed to update.RapReliableOpts, update.RapUnreliableOpts, or update.RapData.

species

integer or character denoting species for which targets or name should be updated.

space

integer denoting space for which targets should be updated.

name

character to rename species.

amount.target

numeric vector for new area targets (%) for the specified species.

space.target

numeric vector for new attribute space targets (%) for the specified species and attribute spaces.

pu

integer planning unit indices that need to be updated.

cost

numeric new costs for specified planning units.

status

integer new statuses for specified planning units.

BLM

numeric boundary length modifier.

failure.multiplier

numeric multiplier for failure planning unit.

max.r.level

numeric maximum R failure level for approximation.

formulation

character indicating new problem formulation to use. This can be either 'unreliable' or 'reliable'. The default is NULL so that formulation in object is used.

solve

logical should the problem be solved? This argument is only valid for RapUnsolved and RapSolved objects. Defaults to TRUE.

Value

GurobiOpts-class, RapUnreliableOpts-class, RapReliableOpts-class, RapData-class, RapUnsolved-class, or RapSolved-class object depending on x.

See Also

GurobiOpts-class, RapUnreliableOpts-class, RapReliableOpts-class, RapData-class, RapUnsolved-class, RapSolved-class.

Examples

Run this code
# NOT RUN {
# load data
data(sim_ru, sim_rs)

# GurobiOpts
x <- GurobiOpts(MIPGap=0.7)
y <- update(x, MIPGap=0.1)
print(x)
print(y)

# RapUnreliableOpts
x <- RapUnreliableOpts(BLM=10)
y <- update(x, BLM=2)
print(x)
print(y)

# RapReliableOpts
x <- RapReliableOpts(failure.multiplier=2)
y <- update(x, failure.multiplier=4)
print(x)
print(y)

# RapData
x <- sim_ru@data
y <- update(x, space.target=c(0.4, 0.7, 0.1))
print(space.target(x))
print(space.target(y))

## RapUnsolved
x <- sim_ru
y <- update(x, amount.target=c(0.1, 0.2, 0.3), BLM=3, solve=FALSE)
# print x parameters
print(x@opts@BLM); print(amount.target(x))
# print y parameters
print(y@opts@BLM); print(space.target(y))

## RapSolved
x <- sim_rs
y <- update(x, space.target=c(0.4, 0.6, 0.9), BLM=100, Presolve=1L, solve=FALSE)
# print x parameters
print(x@opts@BLM); print(amount.target(x))
# print y parameters
print(y@opts@BLM); print(space.target(y))
# }

Run the code above in your browser using DataLab