Sandia Home Sandia Home
Main Page | Publications | Downloads | Configuration | Running the Code | Solver Parameters | FAQ | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

example2.cpp File Reference


Detailed Description

Example with bound constraints and a nonlinear constraint (handled using an extreme barrier approach).

A simple example of a function evaluation that takes its input from a text file, and it writes a single objective value or an error message to an output file.

In this case, the two-dimensional example function is:

\[ f(x) = x_1^2 + 2 x_2^2 \]

And there is also a constraint:

\[ c(x) \equiv x_1^2 + x_2^2 -1 \geq 0 \]

If the constraint is violated, then an error message is printed to the output file rather than the function value.

The input file example2.apps, to be used with example2.cpp, includes the following lower and upper bounds and initial point:

\[ \ell = \begin{bmatrix}-1\\-1\end{bmatrix}, \quad u = \begin{bmatrix}3\\3\end{bmatrix}, \quad x^{(0)} = \begin{bmatrix}0.2\\0.3\end{bmatrix} \]

See also:
example2a.cpp is a variation on this example that writes both its function value and its constraint value to the output file.

Definition in file example2.cpp.

#include <iostream>
#include <fstream>
#include <vector>

Include dependency graph for example2.cpp:

Include dependency graph

Go to the source code of this file.

Functions

double feval (const vector< double > &x)
 Function Evaluation.
bool constraint (vector< double > &x)
 Nonlinear Constraint.
int main (int argc, char *argv[])
 Main.


Function Documentation

double feval const vector< double > &  x  ) 
 

Function Evaluation.

Definition at line 81 of file example2.cpp.

bool constraint vector< double > &  x  ) 
 

Nonlinear Constraint.

Definition at line 93 of file example2.cpp.

int main int  argc,
char *  argv[]
 

Main.

Definition at line 105 of file example2.cpp.

References constraint(), and feval().

 

© Sandia Corporation | Site Contact | Privacy and Security

Generated on Fri Feb 16 10:33:35 2007 for APPSPACK 5.0.1 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2002