Example shows problem class use.
Example shows problem class use.
#include "shared-tests/fixture.hh"
#include <boost/mpl/vector.hpp>
#define CHECK_COPY(A, B) \
assert (&(A).function () == &(B).function ()); \
assert ((A).constraints ().size () == (B).constraints ().size ()); \
assert ((A).argumentNames ().size () == (B).argumentNames ().size ());
BOOST_FIXTURE_TEST_SUITE (core, TestSuiteConfiguration)
BOOST_AUTO_TEST_CASE (problem_copy_constructor)
{
boost::mpl::vector<LinearFunction, DifferentiableFunction> >
problemSrc_t;
boost::mpl::vector<QuadraticFunction, DifferentiableFunction> >
ambiguousProblemDst_t;
ConstantFunction::vector_t v (1);
v.setZero ();
problemSrc_t pbSrc (f);
names[0] = "x";
pbSrc.argumentNames () = names;
boost::shared_ptr<ConstantFunction>
cstr = boost::make_shared<ConstantFunction> (v);
problemSrc_t::intervals_t intervals (1);
problemSrc_t::scaling_t scaling (1, 1);
for (size_t i = 0; i < intervals.size (); ++i)
intervals[i] = Function::makeInfiniteInterval ();
pbSrc.addConstraint (cstr, intervals, scaling);
pbSrc.addConstraint (boost::static_pointer_cast<DifferentiableFunction> (cstr),
intervals, scaling);
{
problemSrc_t pbDst (pbSrc);
CHECK_COPY(pbSrc, pbDst);
BOOST_CHECK(pbDst.constraints ()[0].which () == 0);
BOOST_CHECK(pbDst.constraints ()[1].which () == 1);
}
{
problemDst_t pbDst (pbSrc);
CHECK_COPY(pbSrc, pbDst);
}
{
ambiguousProblemDst_t pbDst (pbSrc);
CHECK_COPY(pbSrc, pbDst);
BOOST_CHECK(pbDst.constraints ()[0].which () == 0);
BOOST_CHECK(pbDst.constraints ()[1].which () == 1);
}
}
BOOST_AUTO_TEST_SUITE_END ()
defined(EIGEN_RUNTIME_NO_MALLOC) && !defined(ROBOPTIM_DO_NOT_CHECK_ALLOCATION)
Definition: alloc.hh:33
Define an abstract derivable function ( ).
Definition: differentiable-function.hh:80
Define an abstract mathematical function ( ).
Definition: function.hh:161
std::vector< name_t > names_t
Type of a vector of function argument names.
Definition: function.hh:216
Constant function.
Definition: constant.hh:36
Definition: problem.hh:261