[Coin-ipopt] A problem using IPOPT with QT library

Liu Yang yliu at cs.hku.hk
Tue Jul 4 06:00:36 EDT 2006


Dear all,

Does anyone use IPOPT in QT(Trolltech QT GUI library) program?

My program always failed in the constructor of IpoptApplication. 

I traced back to ipipoptapplication.cpp,  and I found the variables jnlst_,
options_  are not created 
by new operator.

  IpoptApplication::IpoptApplication(bool create_console_out)
      :
      jnlst_(new Journalist()),
      options_(new OptionsList()),
      statistics_(NULL),
      alg_(NULL),
      nlp_adapter_(NULL)


The problem only occurs in QT environment.  

The following is my main code.  

////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////
#include <QtGui/QApplication>
#include "qtest.h"
#include "IpIpoptApplication.hpp"
#include "IpSolveStatistics.hpp"
#include "MyNLP.hpp"  //The example from Itopt library
using namespace Ipopt;

int main(int argc, char *argv[])
{

	// Create an instance of your nlp...
	SmartPtr<TNLP> mynlp = new MyNLP();

	// Create an instance of the IpoptApplication
	SmartPtr<IpoptApplication> app = new IpoptApplication();
	//The program failed here


	// Initialize the IpoptApplication and process the options
	app->Initialize();

	ApplicationReturnStatus status = app->OptimizeTNLP(mynlp);


    QApplication a(argc, argv);
    qtest w;
    w.show();
    a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
    return a.exec();
}

////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////

Many thanks.  


Best regards,

Yang Liu
PhD Candidate
Department of Computer Science,
The University of Hong Kong




More information about the Coin-ipopt mailing list