Beispiel #1
0
int
SET_OF_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
                  asn_app_constraint_failed_f *ctfailcb, void *app_key) {
    const asn_TYPE_member_t *elm = td->elements;
	asn_constr_check_f *constr;
	const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr);
	int i;

	if(!sptr) {
		ASN__CTFAIL(app_key, td, sptr,
			"%s: value not given (%s:%d)",
			td->name, __FILE__, __LINE__);
		return -1;
	}

	constr = elm->encoding_constraints.general_constraints;
	if(!constr) constr = elm->type->encoding_constraints.general_constraints;

	/*
	 * Iterate over the members of an array.
	 * Validate each in turn, until one fails.
	 */
	for(i = 0; i < list->count; i++) {
		const void *memb_ptr = list->array[i];
		int ret;

		if(!memb_ptr) continue;

		ret = constr(elm->type, memb_ptr, ctfailcb, app_key);
		if(ret) return ret;
	}

	return 0;
}
Beispiel #2
0
void mexFunction1(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
	MAPTYPE *vol, *get_maps();
	int m0,m1,m2, n0,n1,n2;
	double *B0, *B1, *B2;
	for(n0=1; n0<nrhs; n0++)
	{
		if (!mxIsNumeric(prhs[n0]) || mxIsComplex(prhs[n0]) ||
			mxIsSparse(prhs[n0]) || !mxIsDouble(prhs[n0]))
		{
			mexErrMsgTxt("Arguments must be numeric, real, full and double.");
		}
	}

	vol = get_maps(prhs[0], &n0);
	if (n0!=1)
	{
		free_maps(vol, n0);
		mexErrMsgTxt("Incorrect usage.");
	}
	n0 = vol->dim[0];
	n1 = vol->dim[1];
	n2 = vol->dim[2];

	m0 = mxGetN(prhs[1]);
	m1 = mxGetN(prhs[2]);
	m2 = mxGetN(prhs[3]);

	if (m0>MAXB || m1>MAXB || m2>MAXB)
	{
		free_maps(vol, 1);
		mexErrMsgTxt("Too many basis functions.");
	}

	B0 = mxGetPr(prhs[1]);
	B1 = mxGetPr(prhs[2]);
	B2 = mxGetPr(prhs[3]);

	if (mxGetM(prhs[1])!=n0 || mxGetM(prhs[2])!=n1 || mxGetM(prhs[3])!=n2)
	{
		free_maps(vol, 1);
		mexErrMsgTxt("Inappropriate matrix dimensions.");
	}
	plhs[0] = mxCreateDoubleMatrix(m0*m1*m2,1, mxREAL);
	plhs[1] = mxCreateDoubleMatrix(1,1, mxREAL);
	mxGetPr(plhs[1])[0] = constr(m0,m1,m2,n0,n1,n2,mxGetPr(plhs[0]),vol,B0,B1,B2);
	free_maps(vol, 1);
}
int
SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
		asn_app_constraint_failed_f *ctfailcb, void *app_key) {
	asn_TYPE_member_t *elm = td->elements;
	asn_constr_check_f *constr;
	const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr);
	int i;

	if(!sptr) {
		_ASN_CTFAIL(app_key, td, sptr,
			"%s: value not given (%s:%d)",
			td->name, __FILE__, __LINE__);
		return -1;
	}

	constr = elm->memb_constraints;
	if(!constr) constr = elm->type->check_constraints;

	/*
	 * Iterate over the members of an array.
	 * Validate each in turn, until one fails.
	 */
	for(i = 0; i < list->count; i++) {
		const void *memb_ptr = list->array[i];
		int ret;

		if(!memb_ptr) continue;

		ret = constr(elm->type, memb_ptr, ctfailcb, app_key);
		if(ret) return ret;
	}

	/*
	 * Cannot inherit it eralier:
	 * need to make sure we get the updated version.
	 */
	if(!elm->memb_constraints)
		elm->memb_constraints = elm->type->check_constraints;

	return 0;
}
Beispiel #4
0
TEST(MiniTensor_ROL, NLLS01)
{
  bool const
  print_output = ::testing::GTEST_FLAG(print_time);

  // outputs nothing
  Teuchos::oblackholestream
  bhs;

  std::ostream &
  os = (print_output == true) ? std::cout : bhs;

  constexpr Intrepid2::Index
  NUM_CONSTR{3};

  constexpr Intrepid2::Index
  NUM_VAR{5};

  using MSEC = Intrepid2::Nonlinear01<Real, NUM_CONSTR>;

  MSEC
  msec;

  ROL::MiniTensor_EqualityConstraint<MSEC, Real, NUM_CONSTR, NUM_VAR>
  constr(msec);

  Intrepid2::Vector<Real, NUM_VAR>
  xval(Intrepid2::ZEROS);

  Intrepid2::Vector<Real, NUM_CONSTR>
  cval(Intrepid2::ZEROS);

  Intrepid2::Vector<Real, NUM_VAR>
  solval(Intrepid2::ZEROS);

  // Set initial guess.
  xval(0) = -1.8;
  xval(1) =  1.7;
  xval(2) =  1.9;
  xval(3) = -0.8;
  xval(4) = -0.8;

  // Set solution.
  solval(0) = -1.717143570394391e+00;
  solval(1) =  1.595709690183565e+00;
  solval(2) =  1.827245752927178e+00;
  solval(3) = -7.636430781841294e-01;
  solval(4) = -7.636430781841294e-01;

  Real const
  error_full_hess{2.3621708067012991e-02};

  Real const
  error_gn_hess{2.3669791103726853e-02};

  Real const
  tol{1.0e-08};

  ROL::MiniTensorVector<Real, NUM_VAR>
  x(xval);

  ROL::MiniTensorVector<Real, NUM_CONSTR>
  c(cval);

  ROL::MiniTensorVector<Real, NUM_VAR>
  sol(solval);

  Teuchos::RCP<ROL::EqualityConstraint<Real>>
  pconstr = Teuchos::rcp(&constr, false);

  // Define algorithm.
  Teuchos::ParameterList
  params;

  std::string
  step{"Trust Region"};

  params.sublist("Step").sublist(step).set("Subproblem Solver", "Truncated CG");
  params.sublist("Status Test").set("Gradient Tolerance", 1.0e-10);
  params.sublist("Status Test").set("Constraint Tolerance", 1.0e-10);
  params.sublist("Status Test").set("Step Tolerance", 1.0e-18);
  params.sublist("Status Test").set("Iteration Limit", 128);

  ROL::Algorithm<Real>
  algo(step, params);

  ROL::NonlinearLeastSquaresObjective<Real>
  nlls(pconstr, x, c, false);

  os << "\nSOLVE USING FULL HESSIAN\n";

  algo.run(x, nlls, true, os);

  Intrepid2::Vector<Real, NUM_VAR>
  xfinal = ROL::MTfromROL<Real, NUM_VAR>(x);

  os << "\nfinal x : " << xfinal << "\n";

  Real
  error = std::abs(Intrepid2::norm(xfinal - solval) - error_full_hess);

  os << "\nerror : " << error << "\n";

  ASSERT_LE(error, tol);

  algo.reset();
  x.set(xval);

  ROL::NonlinearLeastSquaresObjective<Real>
  gnnlls(pconstr, x, c, true);

  os << "\nSOLVE USING GAUSS-NEWTON HESSIAN\n";

  algo.run(x, gnnlls, true, os);

  xfinal = ROL::MTfromROL<Real, NUM_VAR>(x);

  os << "\nfinal x : " << xfinal << "\n";

  error = std::abs(Intrepid2::norm(xfinal - solval) - error_gn_hess);

  os << "\nerror : " << error << "\n";

  ASSERT_LE(error, tol);
}
Beispiel #5
0
static inline CIMGArchiveTranslatorHandle* GenOpenArchiveTemplate( imgExtension *env, CFileTranslator *srcRoot, const charType *srcPath, constructionHandler constr )
{
    CIMGArchiveTranslatorHandle *transOut = NULL;
        
    bool hasValidArchive = false;
    eIMGArchiveVersion theVersion;

    CFile *contentFile = srcRoot->Open( srcPath, GetReadWriteMode <charType> ( false ), FILE_FLAG_WRITESHARE );

    if ( !contentFile )
    {
        return NULL;
    }

    bool hasUniqueRegistryFile = false;
    CFile *registryFile = NULL;

    // Check for version 2.
    struct mainHeader
    {
        union
        {
            unsigned char version[4];
            fsUInt_t checksum;
        };
    };

    mainHeader imgHeader;

    bool hasReadMainHeader = contentFile->ReadStruct( imgHeader );

    if ( hasReadMainHeader && imgHeader.checksum == '2REV' )
    {
        hasValidArchive = true;
        theVersion = IMG_VERSION_2;

        registryFile = contentFile;
    }

    if ( !hasValidArchive )
    {
        // Check for version 1.
        hasUniqueRegistryFile = true;

        registryFile = OpenSeperateIMGRegistryFile( srcRoot, srcPath, false );
        
        if ( registryFile )
        {
            hasValidArchive = true;
            theVersion = IMG_VERSION_1;
        }
    }

    if ( hasValidArchive )
    {
        CIMGArchiveTranslator *translator = constr( env, registryFile, contentFile, theVersion );

        if ( translator )
        {
            bool loadingSuccess = translator->ReadArchive();

            if ( loadingSuccess )
            {
                transOut = translator;
            }
            else
            {
                delete translator;

                contentFile = NULL;
                registryFile = NULL;
            }
        }
    }

    if ( !transOut )
    {
        if ( contentFile )
        {
            delete contentFile;

            contentFile = NULL;
        }

        if ( hasUniqueRegistryFile && registryFile )
        {
            delete registryFile;

            registryFile = NULL;
        }
    }

    return transOut;
}
void
MiniTensor_Minimizer<T, N>::
solve(
    std::string const & algoname,
    Teuchos::ParameterList & params,
    FN & fn,
    EIC & eic,
    Intrepid2::Vector<T, N> & soln,
    Intrepid2::Vector<T, NC> & cv)
{
  step_method_name = algoname.c_str();
  function_name = FN::NAME;
  initial_guess = soln;

  Intrepid2::Vector<T, N>
  resi = fn.gradient(soln);

  initial_value = fn.value(soln);
  previous_value = initial_value;
  failed = failed || fn.failed;
  initial_norm = Intrepid2::norm(resi);

  // Define algorithm.
  ROL::MiniTensor_Objective<FN, T, N>
  obj(fn);

  // Define constraint
  using MTCONSTR = typename std::conditional<eic.IS_EQUALITY,
      ROL::MiniTensor_EqualityConstraint<EIC, T, NC, N>,
      ROL::MiniTensor_InequalityConstraint<EIC, T, NC, N>>::type;

  MTCONSTR
  constr(eic);

  ROL::Algorithm<T>
  algo(algoname, params);

  // Set Initial Guess
  ROL::MiniTensorVector<T, N>
  x(soln);

  // Set constraint vector
  ROL::MiniTensorVector<T, NC>
  c(cv);

  // Run Algorithm
  algo.run(x, c, obj, constr, verbose);

  soln = ROL::MTfromROL<T, N>(x);

  resi = fn.gradient(soln);

  T const
  norm_resi = Intrepid2::norm(resi);

  updateConvergenceCriterion(norm_resi);

  ROL::AlgorithmState<T> &
  state = const_cast<ROL::AlgorithmState<T> &>(*(algo.getState()));

  ROL::StatusTest<T>
  status(params);

  converged = status.check(state) == false;

  recordFinals(fn, soln);

  return;
}
Beispiel #7
0
Etre::Etre(float x_, float y_)
{
    position.x =x_;
    position.y=y_;
   constr ();
}
Beispiel #8
0
Etre::Etre()
{
    position.x = position.y = 0;
   constr ();

}
Beispiel #9
0
void
ShapesDialog::onSubscribeButtonClicked()
{
    dds::topic::qos::TopicQos topicQos = dp_.default_topic_qos()
                                         << dds::core::policy::Durability::Persistent()
                                         << dds::core::policy::DurabilityService(
                                                    dds::core::Duration(3600,0),
                                                    dds::core::policy::HistoryKind::KEEP_LAST,
                                                    100,
                                                    8192,
                                                    4196,
                                                    8192);

    dds::sub::qos::SubscriberQos SQos = dp_.default_subscriber_qos() << gQos_;
    dds::sub::Subscriber sub(dp_, SQos);
    int d = mainWidget.sizeSlider->value();
    QRect rect(0, 0, d, d);
    QRect constr(0, 0, IS_WIDTH, IS_HEIGHT);
    int x = static_cast<int>(constr.width() * ((float)rand() / RAND_MAX)*0.9F);
    int y = static_cast<int>(constr.height() * ((float)rand() / RAND_MAX)*0.9F);
    int sIdx = mainWidget.rShapeList->currentIndex();

    QColor gray = QColor(0x99, 0x99, 0x99);
    QBrush brush(gray, Qt::SolidPattern);

    QPen pen(QColor(0xff,0xff,0xff), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    std::vector<std::string> empty;
    filterParams_ = empty;
    std::string filterS;
    if (filterDialog_->isEnabled())
    {
        QRect rect =  filterDialog_->getFilterBounds();
        std::string x0 = lexicalCast(rect.x());
        std::string x1 = lexicalCast(rect.x() + rect.width() -d);
        std::string y0 = lexicalCast(rect.y());
        std::string y1 = lexicalCast(rect.y() + rect.height() -d);
        filterParams_.push_back(x0);
        filterParams_.push_back(x1);
        filterParams_.push_back(y0);
        filterParams_.push_back(y1);
        filterS = "(x BETWEEN "
            + filterParams_[0]
            + " AND "
            + filterParams_[1]
            + ") AND (y BETWEEN "
            + filterParams_[2]
            + " AND "
            + filterParams_[3]
            + ")";

        if (filterDialog_->filterOutside() == false)
        {
             filterS = "(x < "
                 + filterParams_[0]
                 + " ) OR ( x > "
                 + filterParams_[1]
                 + " ) OR (y < "
                 + filterParams_[2]
                 + ") OR ( y > "
                 + filterParams_[3]
                 + ")";
        }
    }

    switch (sIdx)
    {

        case CIRCLE:
        {
            dds::topic::Topic<ShapeType> circle_(dp_, circleTopicName, topicQos);
	        dds::topic::ContentFilteredTopic<ShapeType> cfcircle_(dds::core::null);
            dds::sub::DataReader<ShapeType> dr(sub, circle_, readerQos_.get_qos());

            if (filterDialog_->isEnabled())
            {
                std::string tname = "CFCircle";
                const dds::topic::Filter filter(filterS);
                std::cout << filterS << std::endl;
                dds::topic::ContentFilteredTopic<ShapeType> cfcircle_(circle_, "CFCircle", filter);
	            dds::sub::DataReader<ShapeType> dr2(sub, cfcircle_, readerQos_.get_qos());
                dr = dr2;
            }
            for (int i = 0; i < CN; ++i)
            {
                std::string colorStr(colorString_[i]);

                DDSShapeDynamics::ref_type
                dynamics(new DDSShapeDynamics(x, y, dr, colorStr, i));

                Shape::ref_type
                circle(new Circle(rect, dynamics, pen, brush, true));

                dynamics->setShape(circle);
                shapesWidget->addShape(circle);
            }
            break;
        }

        case SQUARE:
        {
            dds::topic::Topic<ShapeType> square_(dp_, squareTopicName, topicQos);
            dds::sub::LoanedSamples<ShapeType>::iterator si;
	        dds::topic::ContentFilteredTopic<ShapeType> cfsquare_(dds::core::null);
            dds::sub::DataReader<ShapeType> dr(sub, square_, readerQos_.get_qos());

            if (filterDialog_->isEnabled())
            {
                std::string tname = "CFSquare";
                const dds::topic::Filter filter(filterS);
                std::cout << filterS << std::endl;
                dds::topic::ContentFilteredTopic<ShapeType> cfsquare_(square_, "CFSquare", filter);
	            dds::sub::DataReader<ShapeType> dr2(sub, cfsquare_, readerQos_.get_qos());
                dr = dr2;
            }

            for (int i = 0; i < CN; ++i)
            {
                std::string colorStr(colorString_[i]);

                DDSShapeDynamics::ref_type
                dynamics(new DDSShapeDynamics(x, y, dr, colorStr, i));

                Shape::ref_type
                square(new Square(rect, dynamics, pen, brush, true));

                dynamics->setShape(square);
                shapesWidget->addShape(square);
            }
            break;
        }

        case TRIANGLE:
        {
            dds::topic::Topic<ShapeType> triangle_(dp_, triangleTopicName, topicQos);
            dds::sub::LoanedSamples<ShapeType>::iterator si;
	        dds::topic::ContentFilteredTopic<ShapeType> cftriangle_(dds::core::null);
            dds::sub::DataReader<ShapeType> dr(sub, triangle_, readerQos_.get_qos());

            if (filterDialog_->isEnabled())
            {
                std::string tname = "CFTriangle";
                const dds::topic::Filter filter(filterS);
                std::cout << filterS << std::endl;
                dds::topic::ContentFilteredTopic<ShapeType> cftriangle_(triangle_, "CFTriangle", filter);
	            dds::sub::DataReader<ShapeType> dr2(sub, cftriangle_, readerQos_.get_qos());
                dr = dr2;
            }

            for (int i = 0; i < CN; ++i)
            {
                std::string colorStr(colorString_[i]);

                DDSShapeDynamics::ref_type
                dynamics(new DDSShapeDynamics(x, y, dr, colorStr, i));

                Shape::ref_type
                triangle(new Triangle(rect, dynamics, pen, brush, true));

                dynamics->setShape(triangle);
                shapesWidget->addShape(triangle);
            }
        break;
        }

        default:
            break;
    }
}
Beispiel #10
0
void
ShapesDialog::onPublishButtonClicked()
{
    dds::topic::qos::TopicQos topicQos = dp_.default_topic_qos()
                                         << dds::core::policy::Durability::Persistent()
                                         << dds::core::policy::DurabilityService(dds::core::Duration(3600,0),
                                                    dds::core::policy::HistoryKind::KEEP_LAST,
                                                    100,
                                                    8192,
                                                    4196,
                                                    8192);

    dds::pub::qos::PublisherQos PQos = dp_.default_publisher_qos()
                                        << gQos_;
    dds::pub::Publisher pub(dp_, PQos);


    int d = mainWidget.sizeSlider->value();
    float speed = ((float)mainWidget.speedSlider->value()) / 9;
    QRect rect(0, 0, d, d);
    // TODO: This should be retrieved from the canvas...


    QRect constr(0, 0, IS_WIDTH, IS_HEIGHT);
    // QRect constr = this->geometry();
    int x = constr.width() * ((float)rand() / RAND_MAX);
    int y = constr.height() * ((float)rand() / RAND_MAX);
    int cIdx = mainWidget.colorList->currentIndex();
    int sIdx = mainWidget.wShapeList->currentIndex();

    QBrush brush(color_[cIdx], Qt::SolidPattern);
    QPen pen(QColor(0xff, 0xff, 0xff), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    ShapeType shape;
    shape.color = DDS::string_dup(colorString_[cIdx]);
    shape.shapesize = rect.width();
    shape.x = x;
    shape.y = y;

    switch (sIdx)
    {

        case CIRCLE:
        {
            dds::topic::Topic<ShapeType> circle_(dp_, circleTopicName, topicQos);
            dds::pub::qos::DataWriterQos dwqos = circle_.qos();
            dds::pub::DataWriter<ShapeType> dw(pub, circle_, writerQos_.get_qos());


            BouncingShapeDynamics::ref_type dynamics(new BouncingShapeDynamics(x, y, rect, constr, PI/6, speed, shape, dw));
            Shape::ref_type  circle(new Circle(rect, dynamics, pen, brush));
            shapesWidget->addShape(circle);

            break;
        }

        case SQUARE:
        {
            dds::topic::Topic<ShapeType> square_(dp_, squareTopicName, topicQos);
            dds::pub::qos::DataWriterQos dwqos = square_.qos();
            dds::pub::DataWriter<ShapeType> dw(pub, square_, writerQos_.get_qos());


            BouncingShapeDynamics::ref_type dynamics(new BouncingShapeDynamics(x, y, rect, constr, PI/6, speed, shape, dw));
            Shape::ref_type  square(new Square(rect, dynamics, pen, brush));
            shapesWidget->addShape(square);
            break;
        }
        case TRIANGLE:
        {
            dds::topic::Topic<ShapeType> triangle_(dp_, triangleTopicName, topicQos);
            dds::pub::qos::DataWriterQos dwqos = triangle_.qos();
            dds::pub::DataWriter<ShapeType> dw(pub, triangle_, writerQos_.get_qos());


            BouncingShapeDynamics::ref_type dynamics(new BouncingShapeDynamics(x, y, rect, constr, PI/6, speed, shape, dw));
            Shape::ref_type  triangle(new Triangle(rect, dynamics, pen, brush));
            shapesWidget->addShape(triangle);
            break;
        }
        default:
            break;
    };
}
Beispiel #11
0
int main(int argc, char **argv) {

    // Set up MPI
    Teuchos::GlobalMPISession mpiSession(&argc, &argv);

    // This little trick lets us print to std::cout only if a (dummy) command-line argument is provided.
    int iprint     = argc - 1;
    Teuchos::RCP<std::ostream> outStream;
    Teuchos::oblackholestream bhs; // outputs nothing
    if (iprint > 0)
        outStream = Teuchos::rcp(&std::cout, false);
    else
        outStream = Teuchos::rcp(&bhs, false);

    int errorFlag = 0;

    Teuchos::ParameterList parlist;
    std::string paramfile = "parameters.xml";
    Teuchos::updateParametersFromXmlFile(paramfile,Teuchos::Ptr<Teuchos::ParameterList>(&parlist));

    int nx     = parlist.get("Interior Grid Points",100);
    double gnl = parlist.get("Nonlinearity Coefficient g",50.0);

    // Grid spacing
    RealT dx = 1.0/(nx+1);

    // Pointer to linspace type vector \f$x_i = \frac{i+1}{n_x+1}\f$ where \f$i=0,\hdots,n_x\f$
    Teuchos::RCP<std::vector<RealT> > xi_rcp = Teuchos::rcp( new std::vector<RealT> (nx, 0.0) );

    for(int i=0; i<nx; ++i) {
        (*xi_rcp)[i] = RealT(i+1)/(nx+1);
    }

    // Pointer to potential vector (quadratic centered at x=0.5)
    Teuchos::RCP<std::vector<RealT> > V_rcp = Teuchos::rcp( new std::vector<RealT> (nx, 0.0) );
    for(int i=0; i<nx; ++i) {
        (*V_rcp)[i] = 100.0*pow((*xi_rcp)[i]-0.5,2);
    }

    StdVector<RealT> V(V_rcp);

    // Iteration Vector (pointer to optimzation vector)
    Teuchos::RCP<std::vector<RealT> > psi_rcp = Teuchos::rcp( new std::vector<RealT> (nx, 0.0) );


    // Set Initial Guess (normalized)
    double sqrt30 = sqrt(30);

    for (int i=0; i<nx; i++) {
        (*psi_rcp)[i]   = sqrt30*(*xi_rcp)[i]*(1.0-(*xi_rcp)[i]);
    }

    StdVector<RealT> psi(psi_rcp);

    // Equality constraint value (scalar)
    Teuchos::RCP<std::vector<RealT> > c_rcp = Teuchos::rcp( new std::vector<RealT> (1, 0.0) );
    StdVector<RealT> c(c_rcp);

    // Lagrange multiplier value (scalar)
    Teuchos::RCP<std::vector<RealT> > lam_rcp = Teuchos::rcp( new std::vector<RealT> (1, 0.0) );
    StdVector<RealT> lam(lam_rcp);

    // Gradient
    Teuchos::RCP<std::vector<RealT> > g_rcp = Teuchos::rcp( new std::vector<RealT> (nx, 0.0) );
    StdVector<RealT> g(g_rcp);

    // Instantiate objective function
    Objective_GrossPitaevskii<RealT> obj(gnl,V);

    // Instantiate normalization constraint
    Normalization_Constraint<RealT> constr(nx,dx);

    // Define algorithm.
    std::string stepname = "Composite Step";
    parlist.sublist("Step").sublist(stepname).sublist("Optimality System Solver").set("Nominal Relative Tolerance",1e-4);
    parlist.sublist("Step").sublist(stepname).sublist("Optimality System Solver").set("Fix Tolerance",true);
    parlist.sublist("Step").sublist(stepname).sublist("Tangential Subproblem Solver").set("Iteration Limit",20);
    parlist.sublist("Step").sublist(stepname).sublist("Tangential Subproblem Solver").set("Relative Tolerance",1e-2);
    parlist.sublist("Step").sublist(stepname).set("Output Level",0);
    parlist.sublist("Status Test").set("Gradient Tolerance",1.e-12);
    parlist.sublist("Status Test").set("Constraint Tolerance",1.e-12);
    parlist.sublist("Status Test").set("Step Tolerance",1.e-14);
    parlist.sublist("Status Test").set("Iteration Limit",100);
    ROL::Algorithm<RealT> algo(stepname, parlist);

    // Run algorithm.
    algo.run(psi, g, lam, c, obj, constr, true, *outStream);


    if(algo.getState()->gnorm>1e-6) {
        errorFlag += 1;
    }

    if (errorFlag != 0)
        std::cout << "End Result: TEST FAILED\n";
    else
        std::cout << "End Result: TEST PASSED\n";



    return 0;

}
int main(){
  cond::TokenBuilder tk;
  tk.set("CondFormatsCalibration",
	 "Pedestals",
	 "Pedestals",
	 0);
  std::string const tok1 = tk.tokenAsString();
  tk.set("CondFormatsCalibration",
	 "Pedestals",
	 "Pedestals",
	 1);
  std::string const tok2 = tk.tokenAsString();
  std::string constr("sqlite_file:unittest_DBLogger.db");
  //std::string constr("oracle://devdb10/cms_xiezhen_dev");
  edmplugin::PluginManager::Config config;
  edmplugin::PluginManager::configure(edmplugin::standard::config());
  cond::DbConnection connection;
  connection.configuration().setMessageLevel( coral::Error );
  connection.configure();
  cond::DbSession session = connection.createSession();
  session.open( constr );
  cond::Logger mylogger( session );
  cond::UserLogInfo a;
  a.provenance="me";
  mylogger.createLogDBIfNonExist();
  mylogger.logOperationNow(a,constr,std::string("Pedestals"),tok1,"mytag1","runnumber",0,1);
  std::cout<<"1. waiting"<<std::endl;
  sleep(1);
  std::cout<<"1. stop waiting"<<std::endl;
  std::cout<<"1. waiting"<<std::endl;
  sleep(1);
  std::cout<<"1. stop waiting"<<std::endl;
  mylogger.logFailedOperationNow(a,constr,std::string("Pedestals"),tok1,"mytag1","runnumber",1,1,"EOOROR");
  std::cout<<"1. waiting"<<std::endl;
  sleep(1);
  std::cout<<"1. stop waiting"<<std::endl;
  
  std::cout<<"1. waiting"<<std::endl;
  sleep(1);
  std::cout<<"1. stop waiting"<<std::endl;
  mylogger.logOperationNow(a,constr,std::string("Pedestals"),tok2,"mytag","runnumber",1,2);
  std::cout<<"1. waiting"<<std::endl;
  sleep(1);
  std::cout<<"1. stop waiting"<<std::endl;
  /*std::cout<<"about to lookup last entry"<<std::endl;
  cond::LogDBEntry result;
  mylogger.LookupLastEntryByProvenance("me",result);
  std::cout<<"result \n";
  std::cout<<"logId "<<result.logId<<"\n";
  std::cout<<"destinationDB "<<result.destinationDB<<"\n";
  std::cout<<"provenance "<<result.provenance<<"\n";
  std::cout<<"usertext "<<result.usertext<<"\n";
  std::cout<<"iovtag "<<result.iovtag<<"\n";
  std::cout<<"iovtimetype "<<result.iovtimetype<<"\n";
  std::cout<<"payloadIdx "<<result.payloadIdx<<"\n";
  std::cout<<"payloadName "<<result.payloadName<<"\n";
  std::cout<<"payloadToken "<<result.payloadToken<<"\n";
  std::cout<<"payloadContainer "<<result.payloadContainer<<"\n";
  std::cout<<"exectime "<<result.exectime<<"\n";
  std::cout<<"execmessage "<<result.execmessage<<std::endl;
  cond::LogDBEntry result2;
  mylogger.LookupLastEntryByTag("mytag1",result2);
  std::cout<<"result2 \n";
  std::cout<<"logId "<<result2.logId<<"\n";
  std::cout<<"destinationDB "<<result2.destinationDB<<"\n";
  std::cout<<"provenance "<<result2.provenance<<"\n";
  std::cout<<"usertext "<<result2.usertext<<"\n";
  std::cout<<"iovtag "<<result2.iovtag<<"\n";
  std::cout<<"iovtimetype "<<result2.iovtimetype<<"\n";
  std::cout<<"payloadIdx "<<result2.payloadIdx<<"\n";
  std::cout<<"payloadName "<<result2.payloadName<<"\n";
  std::cout<<"payloadToken "<<result2.payloadToken<<"\n";
  std::cout<<"payloadContainer "<<result2.payloadContainer<<"\n";
  std::cout<<"exectime "<<result2.exectime<<"\n";
  std::cout<<"execmessage "<<result2.execmessage<<std::endl;
  */
  //coralTransaction.commit();
}