[Coin-ipopt] how to link with IPOPT?

aychy at sohu.com aychy at sohu.com
Mon Aug 22 04:28:33 EDT 2005


Hi,Andreas !

   I had built a object of Ui class -UserInput, because it was easier to build through this method;
I`d like to link my code with IPOPT, how to link correctly ?My method is followed ,but it seemed to fail;


class Ui{
	string InPutFile ;//input data file;
	double fx;//fx-objective function;
	vector < double > x,hx,dfx;//x-optimizaition variables;hx-equality constraints;dfx-gradient of the objective function;
	sparse_matrix dhx,d2hx;//dhx-Jacobian of the equality constraints;d2hx-Hessian of the Lagrangian function;
	Ui(){;}
	update();//update some data;
	void getfx();//get the value of the objective function;
	void gethx();//get the values of the equality constraints;
	void getdfx();//get the gradient of the objective function;
	void getdhx();//the Jacobian of the equality constraints;
	void getd2hx();//get the Hessian of the Lagrangian function
	}
	
 
 1)in the main function: add
 
 Ui UserInput;
 UserInput.InPutFile="c:\\data.dat";
 ...//define the problem;
 
 2)in the Eval_F function: add
 	UserInput.x=x;
 	UserInput.update();
 	UserInput.fx();
 	*f=UserInput.fx;
 	...
 
 3)in the Eval_G function: add
   UserInput.x=x;
   UserInput.update();
   UserInput.getfx();
   for (int i=0;i<UserInput.dfx.size();++i) {    
          G[i+1]=UserInput.dfx(i);
   }
   ...


Best!





More information about the Coin-ipopt mailing list