# pwAddCS

` m = pwAddCS(m, *ID, *lhs, *operator, *rhs, lambda)`
Adds a constraint concerning system trajectory or parameter values
to the model, which will penalize the optimization function
if not fullfilled.
NEW SYNTAX SINCE PW 3.0:
Old:
` pwAddCS(m, lhs, operator, rhs, reactants, parameters, lambda)`
New:
` pwAddCS(m, ID, lhs, operator, rhs, lambda)`

ID ID of the constraint
lhs Left hand side of the constraint using IDs of
A, K, S, U, X, Y or time t.
operator '==', '<', '>'
rhs Right-hand side of the constraint using IDs of
A, K, S, U, X, Y or time t.
lambda Weighting factor. Default: 1

## Description

During optimization, all free parameters are calibrated to decrease
the distance between model trajectory and experimental
data. Lower and upper limits for the fitted parameter values can
be specified. However, sometimes more qualitative or
soft constraints exist, e.g. the maximum of player A should
not exceed 30% of the maximum of player B. These constraints
can be specified within the model definition file:
` m = pwAddCS(m, 'CS01', 'max(A)', '<', '0.3 * max(B)', 100);`
The weighting factor lambda determines how important the constraint is
compared to the residuals between data and model. If lambda is small,
the constraint may be violated in order to allow a better fit of the data.
With lambda = 1, the constraint has the same weight as a single data point.
With lambda = 100, the constraint has the same weight as 100 data points.
The chi-square value is increased by d^2, where d = constraint * lambda.
In the above example, the absolute values of max(A) and
max(B) influence the probability, that the constraint is fulfilled or
not. In order to avoid this, it is more suitable to work with fractions:
pwAddCS(m, ID, lhs, operator, rhs, lambda);
m = pwAddCS(m, 'CS01', 'max(A)/max(B)', '<', '0.3', 100);

## Time points

Please note that all time-dependent quantities are provided as column
vectors corresponding to the sampling time points of the fitted data.
In order to evaluate a quantity for a single time point you may use e.g.
` A(t==0)`
If the quantity should be evaluated at a time point which is not available
in the fitted data, just add the time point into your data set and use
NaN values for all observables.

## Example

m = pwAddCS(m, 'CS01', 'A_0', '==', 'A(t==0)', 100);
This forces A to go through A_0 at t==0.

### See also