Learn R Programming

sybil (version 1.1.2)

optimizeProb-methods: Optimize Problem Object

Description

The function optimizeProb performs the optimization of a problem Object of class sysBiolAlg.

Usage

## S3 method for class 'modelorg':
optimizeProb(object,
             gene = NA,
             react = NA,
             lb = NA,
             ub = NA,
             retOptSol = FALSE,
             MoreArgs = list(),
             ...)

## S3 method for class 'sysBiolAlg': optimizeProb(object, react = NA, lb = NA, ub = NA, obj_coef = NA, lpdir = NA, resetChanges = TRUE, prCmd = NA, poCmd = NA, prCil = NA, poCil = NA)

## S3 method for class 'sysBiolAlg_room': optimizeProb(object, react = NA, lb = NA, ub = NA, prCmd = NA, poCmd = NA, prCil = NA, poCil = NA)

Arguments

object
An object of class modelorg or sysBiolAlg.
gene
A character or integer vector containing gene id's or indices of gene id's in allGenes(model). If arguments lb and/or ub are additionally used (not NA), upper
react
An object of class reactId, character or integer. Specifies the fluxes (variables) for which to change the upper and lower bound (see also arguments lb and ub). Default: NA
lb
Numeric vector, must have the same length as react. Contains the new values for the lower bounds of fluxes (variables) mentioned in react. If set to NA, lower bounds for variables in react will
ub
Same functionality as lb, but for upper bounds. Default: NA.
obj_coef
Numeric vector, must have the same length as react. Contains the new values for the objective coefficients of fluxes (variables) mentioned in react. If set to NA, objective coefficients for variables in
lpdir
Character value, direction of optimization. Can be set to "min" or "max". Default: SYBIL_SETTINGS("OPT_DIRECTION").
resetChanges
Boolean value. If set to TRUE, (default) modifications of the problem object will be reset to their original values (e.g. changing upper and lower bounds for certain reactions). If set to FALSE, modifications will sta
prCmd
A list of preprocessing commands. See Details below. Default: NA.
poCmd
A list of postprocessing commands. See Details below. Default: NA.
prCil
Can be used if optimizeProb is called several times (like in optimizer). The argument prCil gets the value of the loop variable and passes it to the preprocessing functio
poCil
Same as prCil, but for postprocessing. Default: NA.
retOptSol
Boolean. Return an object of class optsol_optimizeProb or just a list containing the results. Default: FALSE.
MoreArgs
Only for the modelorg-method: a named list containing further arguments passed to optimizeProb. See Details below.
...
Only for the modelorg-method: further arguments passed to sysBiolAlg. See Details below.

Value

  • Calls to optimizeProb returns either an object of class optsol_optimizeProb if argument retOptSol is set to TRUE, or a list containing the results of the optimization:
  • okReturn value of the optimizer (e.g. solution process was successful or time limit exceeded).
  • objValue of the objective function after optimization.
  • statStatus value of the optimization (e.g. solution is optimal or no feasible solution exists).
  • fluxesThe resulting flux distribution.
  • fldindPointers to columns (variables) representing a flux (reaction) in the original network. The variable fldind[i] in the solution object represents reaction i in the original network.
  • prePAn object of class ppProc if a preprocessing command was given.
  • postPAn object of class ppProc if a postprocessing command was given.

encoding

utf8

Details

The arguments prCmd and poCmd can be used to execute Rcommands working on the problem object. All commands in prCmd are executed immediately before solving the problem; all commands in poCmd are executed after the problem has been solved. In all other aspects, the arguments work the same. The value of prCmd or poCmd are lists of character vectors (each list element is one command). Each command is a character vector and should be built as follows:
  • The first element is the name of the function to call.
  • All other elements are arguments to the function named in the first element.
  • If any argument is character, enclose it in single quotes' '.
  • Use the keywordLP_PROBin order to refer to the variable name of the problem object (object of classoptObj).
  • If the length of the character vector is one, it is treated as a function call with the problem object (object of classoptObj) as single argument.
The result will be an object of class ppProc. A few examples for arguments prCmd or poCmd (all arguments must be lists, see examples section below): sensitivityAnalysis will be translated to the command sensitivityAnalysis(LP_PROB) with LP_PROB beeing the placeholder for the variable name of the problem object. The vector c("writeProb", "LP_PROB", "'lp'", "'Ec_core.lp'") will be translated to the command writeProb(LP_PROB, 'lp', 'Ec_core.lp') The first element will be the function name and the others the arguments to that function. The list of commands list("sensitivityAnalysis", c("getDjCPLEX", "LP_PROB@oobj$env", "LP_PROB@oobj$lp", "0", "react_num(Ec_core)-1" ) ) will be translated to the commands sensitivityAnalysis(LP_PROB) getDjCPLEX(LP_PROB@oobj$env, LP_PROB@oobj$lp, 0, react_num(Ec_core)-1) For more information on the usage of prCmd and poCmd, see the examples section below.

The method optimizeProb for class modelorg generates a subclass of class sysBiolAlg and calls optimizeProb for that object again. Argument MoreArgs is used to transport arguments to the second optimizeProb call. Argument ... instead is used to transport arguments to the constructor function sysBiolAlg, for example solver, method and solverParm.

Arguments gene, react, lb, ub and react cause changes in the problem object (object of class optObj, slot problem of class sysBiolAlg). These changes will be reset immediately after optimization.

See Also

modelorg and sysBiolAlg.

Examples

Run this code
## The examples here require the package glpkAPI to be
## installed. If that package is not available, you have to set
## the argument 'solver' (the default is: solver = SYBIL_SETTINGS("SOLVER")).

## load the example data set
data(Ec_core)

## run optimizeProb(), Ec_sf will be a list
Ec_sf <- optimizeProb(Ec_core)

## run optimizeProb(), Ec_sf will be an object of
## class optsol_optimizeProb
Ec_sf <- optimizeProb(Ec_core, retOptSol = TRUE)

## do FBA, change the upper and lower bounds for the reactions
## "ATPM" and "PFK".
optimizeProb(Ec_core, react = c("ATPM", "PFK"),
             lb = c(3, -3), ub = c(5, 6))
          
## do FBA, perform sensitivity analysis after optimization
optimizeProb(Ec_core, MoreArgs = list(poCmd = list("sensitivityAnalysis")))

## do FBA, write the problem object to file in lp-format
optimizeProb(Ec_core,
             MoreArgs = list(poCmd = list(c("writeProb", "LP_PROB",
                                            "'Ec_core.lp'", "'lp'"))))

## do FBA, use "cplexAPI" as lp solver. Get all upper bounds before
## solving the problem. After solving, perform a sensitivity
## analysis and retrieve the reduced costs
optimizeProb(Ec_core, solver = "cplexAPI", MoreArgs = list(
             prCmd = list(c("getColsUppBnds", "LP_PROB", "1:77")),
             poCmd = list("sensitivityAnalysis",
                          c("getDjCPLEX",
                            "LP_PROB@oobj@env",
                            "LP_PROB@oobj@lp",
                            "0", "react_num(Ec_core)-1"
                          )
                     )
             )
)

Run the code above in your browser using DataLab