\section{Constraints}

A constraint is a numerical value that is determined during optimization.
Pyomo variables are managed with the \code{Var} class, which can denote
a single, independent value, or an array of values.  Variables define
the search space for optimization.  Variables can have initial values,
and the value of variable can be retrieved and set.


\subsection{Var Declarations}

A simple instance of \code{Var} declares a single variable:
\begin{lstlisting}
model.x = Var()
\end{lstlisting}
A variable array can also be specified by providing sets as options
to the \code{Var} object.  Multi-dimensional variable arrays can be declared by simply including a list of sets as options to the \code{Var} object:
\begin{lstlisting}
model.A = Set()
model.Y = Var(model.A)
model.B = Set()
model.X = Var(model.A, model.B)
\end{lstlisting}


\subsection{Variable Initialization}

By default, a \code{Var} object refers to one or more abstract variables in a model.  However,
a \code{Var} object can be initialized with data by using the \code{initialize} option, which is a function 
that accepts the variable indices and model and returns the value of that variable element:
\begin{lstlisting}
def f(i,model):
    return 3*i
model.x = Var(model.A,initialize=f)
\end{lstlisting}
Additionally, the \code{initialize} option can specify a numerical value used to 
initialize a variable or variable array:
\begin{lstlisting}
model.x = Var(initialize=9)
model.x = Var(model.A,initialize={1:1, 2:4, 3:9})
model.x = Var(model.A,initialize=2)
\end{lstlisting}


\subsection{Data Validation}

Validation of variable data is supported in two different ways.  First, 
the domain of feasible variable values can be specified with the \code{within}
option:
\begin{lstlisting}
model.x = Var(within=model.A)
\end{lstlisting}
Note that the default domain for variables is \code{Reals}, the set of floating
point values. Validation of variable data can also be performed with the \code{validate} option, which is a function that returns \code{True} if a variable value is valid:
\begin{lstlisting}
def S_validate(value,model):
    return value in model.A
model.S = Var(validate=S_validate)
\end{lstlisting}


\subsection{Variable Options}

The option \code{bounds} specifies upper and lower bounds for variables.
Simple bounds can be specified, or a function that defines bounds for
different variables.
\begin{lstlisting}
model.x = Var(bounds=(0.0,1.0))
def f(i,model):
  return (model.x_low[i], model._x_high[i])
model.x = Var(bounds=f)
\end{lstlisting}


\subsection{Class Attributes}

\if 0
Pyomo set objects have the following attributes:

\begin{itemize}

\item \code{name}\\
    The set name.

\item validate\\
    A function that a user can specify to define set membership.

\item ordered\\
    A boolean value that indicates whether this set is ordered.

\item domain\\
    A super-set of this set, which is used to define set membership.

\item dimen\\
    The ''dimension'' of the data in this set.  Each set member is either a singleton, or a tuple with length `dimen`.

\item virtual\\
    A boolean value that indicates whether this set is virtual.

\item doc\\
    A string describing this set.
\end{itemize}
\fi


