Last data update: 2014.03.03

R: Creates linear inverse matrices
SetupR Documentation

Creates linear inverse matrices

Description

Creates the linear problem with equality and inequality equations.

Takes as input either a liminput list, as generated by Read or a filename with the linear inverse model specifications. Creates:

  • inverse matrices and vectors A, b, G, h of the equalities/inequalities:

    Ax=b

    Gx>=h

  • if present, also generates the cost/profit function which is used as:

    min(cost)

    or

    max(profit)

  • if the input was a flow network, Setup will also create the flow matrix (see details).

Usage

Setup(...)
## S3 method for class 'limfile'
Setup(file, verbose = TRUE, ...)
## S3 method for class 'character'
Setup(...)
## S3 method for class 'liminput'
Setup(liminput,...)

Arguments

file

name of the inverse input file.

verbose

if TRUE: prints warnings and messages to the screen.

liminput

list of elements, as returned by Read.

...

extra parameters allowing this to be a generic function.

Value

a list containing:

file

name of the inverse input file.

NUnknowns

number of unknowns.

NEquations

number of equations.

NConstraints

number of constraints.

NComponents

number of components.

NExternal

number of externals.

NVariables

number of variables.

A

matrix A of equalities Ax=B.

B

vector B of equalities Ax=B.

G

matrix G of inequalities Gx>h.

H

vector H of inequalities Gx=h.

Cost

cost vector (to minimise), the weight of each unknown; if not specified; 1 for all unknowns.

Profit

profit vector (to maximise).

Flowmatrix

matrix where element ij denotes flow from compartment i to j.

VarA

matrix VarA of variable equation VarA*x=VarB.

VarB

vector VarB of variable equation VarA*x=VarB.

Flows

a vector with flow names.

Parameters

a data.frame with parameter names and values.

Components

a data.frame with state names and values.

Externals

a data.frame with external names and values.

rates

a data.frame with rate names and values.

markers

a data.frame with marker names and values.

Variables

a vector with variable names.

Unknowns

a vector with names of unknowns (either states or flows).

Weight

a vector with the weights of unknowns- default is 1.

Author(s)

Karline Soetaert <karline.soetaert@nioz.nl>

See Also

Read function that reads inverse input files and produces the input list used by Setup

Lsei, Ldei, Linp functions to solve inverse problem, based on output generated by setup.limfile

Examples

   LIMinputBlending
   Setup(LIMinputBlending )

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(LIM)
Loading required package: limSolve
Loading required package: diagram
Loading required package: shape
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/LIM/Setup.Rd_%03d_medium.png", width=480, height=480)
> ### Name: Setup
> ### Title: Creates linear inverse matrices
> ### Aliases: Setup Setup.limfile Setup.liminput Setup.character
> ### Keywords: IO utilities
> 
> ### ** Examples
> 
>    LIMinputBlending
$file
[1] "blending.input"

$pars
          name nr val par1 par2 par3 par4 var flow comp external reaction
1 MinNutrientA  1  80   NA   NA   NA   NA  NA   NA   NA       NA       NA
2 MinNutrientB  2  50   NA   NA   NA   NA  NA   NA   NA       NA       NA
3 MinNutrientC  3  25   NA   NA   NA   NA  NA   NA   NA       NA       NA
4 MinNutrientD  4   5   NA   NA   NA   NA  NA   NA   NA       NA       NA

$comp
          name nr val par1 par2 par3 par4 var flow comp external reaction
1 pIngredient1  1  NA   NA   NA   NA   NA  NA   NA   NA       NA       NA
2 pIngredient2  2  NA   NA   NA   NA   NA  NA   NA   NA       NA       NA
3      pFiller  3  NA   NA   NA   NA   NA  NA   NA   NA       NA       NA

$rate
NULL

$extern
NULL

$flows
NULL

$vars
NULL

$cost
   name nr val par1 par2 par3 par4 var flow comp external reaction
1 cost1  1  40   NA   NA   NA   NA  NA   NA    1       NA       NA
2 cost1  1  60   NA   NA   NA   NA  NA   NA    2       NA       NA

$profit
NULL

$equations
         name nr val par1 par2 par3 par4 var flow comp external reaction
left  Balance  1  -1   NA   NA   NA   NA  NA   NA    1       NA       NA
left1 Balance  1  -1   NA   NA   NA   NA  NA   NA    2       NA       NA
left2 Balance  1  -1   NA   NA   NA   NA  NA   NA    3       NA       NA
left3 Balance  1   1   NA   NA   NA   NA  NA   NA   NA       NA       NA

$constraints
        name nr val par1 par2 par3 par4 var flow comp external reaction
1  NutrientA  1 100   NA   NA   NA   NA  NA   NA    1       NA       NA
2  NutrientA  1 200   NA   NA   NA   NA  NA   NA    2       NA       NA
3  NutrientA  1  -1    1   NA   NA   NA  NA   NA   NA       NA       NA
4  NutrientB  2  50   NA   NA   NA   NA  NA   NA    1       NA       NA
5  NutrientB  2 150   NA   NA   NA   NA  NA   NA    2       NA       NA
6  NutrientB  2  -1    2   NA   NA   NA  NA   NA   NA       NA       NA
7  NutrientC  3  40   NA   NA   NA   NA  NA   NA    1       NA       NA
8  NutrientC  3  10   NA   NA   NA   NA  NA   NA    2       NA       NA
9  NutrientC  3  -1    3   NA   NA   NA  NA   NA   NA       NA       NA
10 NutrientD  4  10   NA   NA   NA   NA  NA   NA    1       NA       NA
11 NutrientD  4  -1    4   NA   NA   NA  NA   NA   NA       NA       NA

$reactions
NULL

$posreac
NULL

$marker
NULL

$parnames
[1] "MinNutrientA" "MinNutrientB" "MinNutrientC" "MinNutrientD"

$varnames
NULL

$compnames
[1] "PINGREDIENT1" "PINGREDIENT2" "PFILLER"     

$externnames
NULL

$Type
[1] "simple"

attr(,"class")
[1] "liminput"
>    Setup(LIMinputBlending )
$file
[1] "blending.input"

$NUnknowns
[1] 3

$NEquations
[1] 1

$NConstraints
[1] 4

$NComponents
[1] 3

$NExternal
NULL

$NVariables
[1] 0

$A
     [,1] [,2] [,3]
[1,]   -1   -1   -1

$B
[1] -1

$G
     [,1] [,2] [,3]
[1,]  100  200    0
[2,]   50  150    0
[3,]   40   10    0
[4,]   10    0    0

$H
[1] 80 50 25  5

$Cost
[1] 40 60  0

$Profit
NULL

$Flowmatrix
NULL

$VarA
NULL

$VarB
NULL

$Parameters
          name val
1 MinNutrientA  80
2 MinNutrientB  50
3 MinNutrientC  25
4 MinNutrientD   5

$Components
          name val
1 PINGREDIENT1   1
2 PINGREDIENT2   1
3      PFILLER   1

$Externals
data frame with 0 columns and 0 rows

$rates
          name val
1 PINGREDIENT1   0
2 PINGREDIENT2   0
3      PFILLER   0

$markers
NULL

$Variables
NULL

$costnames
[1] cost1
Levels: cost1

$profitnames
NULL

$eqnames
[1] Balance
Levels: Balance

$ineqnames
[1] NutrientA NutrientB NutrientC NutrientD
Levels: NutrientA NutrientB NutrientC NutrientD

$Unknowns
[1] "PINGREDIENT1" "PINGREDIENT2" "PFILLER"     

$ispos
[1] TRUE

attr(,"class")
[1] "lim"
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>