Example shows problem class use.
#include "shared-tests/fixture.hh"
#include <boost/mpl/vector.hpp>
#include <boost/make_shared.hpp>
using namespace roboptim;
#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)
{
ConstantFunction::vector_t v (1);
v.setZero ();
boost::shared_ptr<ConstantFunction> f = boost::make_shared<ConstantFunction> (v);
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)
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.constraintsOutputSize () == pbSrc.constraintsOutputSize ());
}
{
problemDst_t pbDst (pbSrc);
CHECK_COPY(pbSrc, pbDst);
}
{
ambiguousProblemDst_t pbDst (pbSrc);
CHECK_COPY(pbSrc, pbDst);
BOOST_CHECK(pbDst.constraintsOutputSize () == pbSrc.constraintsOutputSize ());
}
}
BOOST_AUTO_TEST_SUITE_END ()