Last data update: 2014.03.03

R: Reads an inverse input file
ReadR Documentation

Reads an inverse input file

Description

Reads an inverse input file and creates the inverse problem as a list, of type "liminput"

Usage

Read(file, verbose = FALSE, checkLinear = TRUE, remtabs = TRUE)

Arguments

file

name of inverse input file.

verbose

if TRUE: prints warnings and messages to the screen.

checkLinear

if FALSE: does not check for linearity

remtabs

remove tabs.

Details

The structure of an inverse input file is explained in vignette("LIM") which should be consulted.

In short the inverse input file contains the declaration sections enclosed inbetween two lines starting with a ##.

For instance, the following section declares two components

# COMP

State1

State2

# END COMP

Only the first 4 characters of the section names are read

The following sections are allowed:

  • Parameters - ## PARAMETERS

  • Components - ## STOCKS or ## DECISION VARIABLES or ## STATES or ## UNKNOWNS

  • Externals - ## EXTERNALS

  • Rates - ## RATES

  • Flows - ## FLOWS

  • Variables - ## VARIABLES

  • Cost - ## COST or ## MINIMISE

  • Profit - ## PROFIT or ## MAXIMISE

  • Equalities - ## EQUALITIES

  • InEqualities - ## INEQUALITIES or ## CONSTRAINTS

Any (part of a) line starting with a "!" is considered a comment.

Input is NOT case sensitive

The output of this function is used as input in function Setup which creates the inverse matrices

By default, only linear problems can be solved, and the function checks whether the input is linear. To toggle off this check, set checkLinear to FALSE.

Some input files contain tabs, which are converted to spaces, unless this logical is set to FALSE.

Value

a list containing :

file

name of the inverse input file.

pars

a data.frame with parameter declarations.

comp

a data.frame with compartments (or states, stocks).

rate

a data.frame with rate declarations.

extern

a data.frame with external declarations.

flows

a data.frame with flow declarations.

vars

a data.frame with variable declarations.

cost

a data.frame with cost declarations.

profit

a data.frame with profit declarations.

equations

a data.frame with equality declarations.

constraints

a data.frame with constraint declarations.

reactions

a data.frame with reaction declarations.

posreac

a vector with TRUE values if reaction or flow is unidirectional (and the unknown x is thus positive), FALSE if it is two-way reaction or flow, and x can be positive or negative.

marker

a data.frame with marker declarations - see vignette("LIM").

parnames

a vector with parameter names.

varnames

a vector with variable names.

compnames

a vector with compartment names.

externnames

a vector with names of externals.

Type

a string; one of "web" (flows are unknowns), "reaction" (reaction rates unknown) and "simple" (compartments are unknowns).

Author(s)

Karline Soetaert <karline.soetaert@nioz.nl>

See Also

Setup the function to create inverse matrices, based on output of Read.

Examples

# this input has been created with function Read:
  LIMinputBlending

## Not run: 
  wd <- getwd()
  setwd(paste(system.file(package = "LIM"), "/doc/examples/Foodweb", sep = ""))
  Read("RigaAutumn.input")
  setwd(wd)

## End(Not run)

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/Read.Rd_%03d_medium.png", width=480, height=480)
> ### Name: Read
> ### Title: Reads an inverse input file
> ### Aliases: Read
> ### Keywords: IO
> 
> ### ** Examples
> 
> # this input has been created with function Read:
>   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"
> 
> ## Not run: 
> ##D   wd <- getwd()
> ##D   setwd(paste(system.file(package = "LIM"), "/doc/examples/Foodweb", sep = ""))
> ##D   Read("RigaAutumn.input")
> ##D   setwd(wd)
> ## End(Not run)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>