diff options
author | Harpreet | 2015-10-26 15:46:23 +0530 |
---|---|---|
committer | Harpreet | 2015-10-26 15:46:23 +0530 |
commit | 1e82cbeeb97000ce243fb4ef6566d0b554473713 (patch) | |
tree | b9d99d4784c6e6317d67fd9f43baf7f5198a1f53 /sci_gateway/cpp/sci_ipopt.cpp | |
parent | 4b0ab259b440fa1bb57494dcbdffb865e293b768 (diff) | |
download | symphony-1e82cbeeb97000ce243fb4ef6566d0b554473713.tar.gz symphony-1e82cbeeb97000ce243fb4ef6566d0b554473713.tar.bz2 symphony-1e82cbeeb97000ce243fb4ef6566d0b554473713.zip |
initial guess added
Diffstat (limited to 'sci_gateway/cpp/sci_ipopt.cpp')
-rw-r--r-- | sci_gateway/cpp/sci_ipopt.cpp | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/sci_gateway/cpp/sci_ipopt.cpp b/sci_gateway/cpp/sci_ipopt.cpp index 06796a9..5837df1 100644 --- a/sci_gateway/cpp/sci_ipopt.cpp +++ b/sci_gateway/cpp/sci_ipopt.cpp @@ -51,13 +51,13 @@ bool readSparse(int arg,int *iRows,int *iCols,int *iNbItem,int** piNbItemRow, in int sci_solveqp(char *fname) { - CheckInputArgument(pvApiCtx, 9, 9); // We need total 9 input arguments. + CheckInputArgument(pvApiCtx, 10, 10); // We need total 10 input arguments. CheckOutputArgument(pvApiCtx, 7, 7); // Error management variable SciErr sciErr; - int retVal=0, *piAddressVarQ = NULL,*piAddressVarP = NULL,*piAddressVarCM = NULL,*piAddressVarCUB = NULL,*piAddressVarCLB = NULL, *piAddressVarLB = NULL,*piAddressVarUB = NULL; - double *QItems=NULL,*PItems=NULL,*ConItems=NULL,*conUB=NULL,*conLB=NULL,*varUB=NULL,*varLB=NULL,x,f,iter; + int retVal=0, *piAddressVarQ = NULL,*piAddressVarP = NULL,*piAddressVarCM = NULL,*piAddressVarCUB = NULL,*piAddressVarCLB = NULL, *piAddressVarLB = NULL,*piAddressVarUB = NULL,*piAddressVarG = NULL; + double *QItems=NULL,*PItems=NULL,*ConItems=NULL,*conUB=NULL,*conLB=NULL,*varUB=NULL,*varLB=NULL,*init_guess = NULL,x,f,iter; static unsigned int nVars = 0,nCons = 0; unsigned int temp1 = 0,temp2 = 0; @@ -260,10 +260,43 @@ int sci_solveqp(char *fname) return 0; } + /* get matrix */ + sciErr = getMatrixOfDouble(pvApiCtx, piAddressVarLB, &temp1,&temp2, &varLB); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + //Initial Value of variables from scilab + /* get Address of inputs */ + sciErr = getVarAddressFromPosition(pvApiCtx, 10, &piAddressVarG); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + /* Check that the first input argument is a real matrix (and not complex) */ + if ( !isDoubleType(pvApiCtx, piAddressVarG) || isVarComplex(pvApiCtx, piAddressVarG) ) + { + Scierror(999, "%s: Wrong type for input argument #%d: A real matrix expected.\n", fname, 10); + return 0; + } + + temp1 = 1; + temp2 = nVars; + /* get matrix */ + sciErr = getMatrixOfDouble(pvApiCtx, piAddressVarG, &temp1,&temp2, &init_guess); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + using namespace Ipopt; - SmartPtr<QuadNLP> Prob = new QuadNLP(nVars,nCons,QItems,PItems,ConItems,conUB,conLB,varUB,varLB); + SmartPtr<QuadNLP> Prob = new QuadNLP(nVars,nCons,QItems,PItems,ConItems,conUB,conLB,varUB,varLB,init_guess); SmartPtr<IpoptApplication> app = IpoptApplicationFactory(); app->RethrowNonIpoptException(true); |