Go back to the old wiki

We revise and update this wiki. We apologize for the inconvenience this may cause you.

Random variables can be adjusted to satisfy a specific constraint.

For example we might adjust the variable x to be always greater than the variable y.

The command \randadjustIf has the syntax \randadjustIf{[varlist]}{[relation]} .

• varlist comma separated list of variables to be adjusted
• relation a relation that defines an avoidance condition under which the variables in varlist should be adjusted
123456789101112\begin{question}     \begin{variables}        \randint[Z]{x}{-10}{10}        \randint[Z]{y}{-10}{10}        \drawFromSet{a}{1,2,3}        \drawFromSet{b}{1,2,3}        \randadjustIf{x,y}{x <= y} %adjust x and y if x is not greater than y        \randadjustIf{b}{a = b}    %adjust b if b equals a    \end{variables} \end{question} 
\randadjustIf on a variable defined by \drawFromSet only works for (the default) type _number_

You may call randadjustIf multiple times to adjust disjoint lists of variables as in the following example:

1234567891011\begin{question}    \begin{variables}        \randint[Z]{x}{-10}{10}        \randint[Z]{y}{-10}{10}        \randint[Z]{c}{-10}{10}        \randint[Z]{d}{-10}{10}        \randadjustIf{x,y}{x <= y} %adjust x and y if x is not greater than y        \randadjustIf{c,d}{c = d OR c = x}    \end{variables} \end{question} 
You should *NEVER* adjust the same variable twice. The following example might lead to problems:
12345678910111213\begin{question}     \begin{variables}        \randint[Z]{x}{-10}{10}        \randint[Z]{y}{-10}{10}        \randint[Z]{c}{-10}{10}        \randint[Z]{d}{-10}{10}        \randadjustIf{x,y}{x <= y} %adjust x and y if x is not greater than y        \randadjustIf{c,x}{c = d OR c = x} % here the variable x will be re-adjusted                                            % and the constraint from previous randadjustIf might be broken.    \end{variables} \end{question} 

You may use \randadjustIf in the same