summaryrefslogtreecommitdiff
path: root/sci_gateway/cpp/sci_ipoptfmincon.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sci_gateway/cpp/sci_ipoptfmincon.cpp')
-rw-r--r--sci_gateway/cpp/sci_ipoptfmincon.cpp70
1 files changed, 20 insertions, 50 deletions
diff --git a/sci_gateway/cpp/sci_ipoptfmincon.cpp b/sci_gateway/cpp/sci_ipoptfmincon.cpp
index 551af41..18218a5 100644
--- a/sci_gateway/cpp/sci_ipoptfmincon.cpp
+++ b/sci_gateway/cpp/sci_ipoptfmincon.cpp
@@ -30,17 +30,15 @@ int sci_solveminconp(char *fname)
{
using namespace Ipopt;
- CheckInputArgument(pvApiCtx, 20, 20);
+ CheckInputArgument(pvApiCtx, 16, 16);
CheckOutputArgument(pvApiCtx, 12, 12);
// Error management variable
SciErr sciErr;
//Function pointers, input matrix(Starting point) pointer, flag variable
- int* funptr=NULL;
- int* gradhesptr=NULL;
double *x0ptr=NULL, *lbptr=NULL, *ubptr=NULL,*Aptr=NULL, *bptr=NULL, *Aeqptr=NULL, *beqptr=NULL;
- double flag1=0,flag2=0,flag3=0,nonlinCon=0,nonlinIneqCon=0;
+ double nonlinCon=0,nonlinIneqCon=0;
// Input arguments
@@ -49,7 +47,7 @@ int sci_solveminconp(char *fname)
unsigned int temp1 = 0,temp2 = 0, iret = 0;
int x0_rows=0, x0_cols=0, lb_rows=0, lb_cols=0, ub_rows=0, ub_cols=0, A_rows=0, A_cols=0, b_rows=0, b_cols=0, Aeq_rows=0, Aeq_cols=0, beq_rows=0, beq_cols=0;
- // Output arguments
+ // Output arguments
double *fX = NULL, ObjVal=0,iteration=0,cpuTime=0,fobj_eval=0;
double dual_inf, constr_viol, complementarity, kkt_error;
double *fGrad = NULL;
@@ -61,98 +59,70 @@ int sci_solveminconp(char *fname)
int int_fobj_eval, int_constr_eval, int_fobj_grad_eval, int_constr_jac_eval, int_hess_eval;
////////// Manage the input argument //////////
-
- //Objective Function
- if(getFunctionFromScilab(1,&funptr))
- {
- return 1;
- }
-
- //Function for gradient and hessian
- if(getFunctionFromScilab(2,&gradhesptr))
- {
- return 1;
- }
-
- //x0(starting point) matrix from scilab
- if(getDoubleMatrixFromScilab(18, &x0_rows, &x0_cols, &x0ptr))
- {
- return 1;
- }
-
- //Getting number of iterations
- if(getFixedSizeDoubleMatrixInList(19,2,temp1,temp2,&max_iter))
- {
- return 1;
- }
-
- //Getting Cpu Time
- if(getFixedSizeDoubleMatrixInList(19,4,temp1,temp2,&cpu_time))
- {
- return 1;
- }
+
//Getting matrix representing linear inequality constraints
- if(getDoubleMatrixFromScilab(3, &A_rows, &A_cols, &Aptr))
+ if(getDoubleMatrixFromScilab(2, &A_rows, &A_cols, &Aptr))
{
return 1;
}
//Getting matrix representing bounds of linear inequality constraints
- if(getDoubleMatrixFromScilab(4, &b_rows, &b_cols, &bptr))
+ if(getDoubleMatrixFromScilab(3, &b_rows, &b_cols, &bptr))
{
return 1;
}
//Getting matrix representing linear equality constraints
- if(getDoubleMatrixFromScilab(5, &Aeq_rows, &Aeq_cols, &Aeqptr))
+ if(getDoubleMatrixFromScilab(4, &Aeq_rows, &Aeq_cols, &Aeqptr))
{
return 1;
}
//Getting matrix representing bounds of linear inequality constraints
- if(getDoubleMatrixFromScilab(6, &beq_rows, &beq_cols, &beqptr))
+ if(getDoubleMatrixFromScilab(5, &beq_rows, &beq_cols, &beqptr))
{
return 1;
}
//Getting matrix representing linear inequality constraints
- if(getDoubleMatrixFromScilab(7, &lb_rows, &lb_cols, &lbptr))
+ if(getDoubleMatrixFromScilab(6, &lb_rows, &lb_cols, &lbptr))
{
return 1;
}
//Getting matrix representing linear inequality constraints
- if(getDoubleMatrixFromScilab(8, &ub_rows, &ub_cols, &ubptr))
+ if(getDoubleMatrixFromScilab(7, &ub_rows, &ub_cols, &ubptr))
{
return 1;
}
//Number of non-linear constraints
- if(getDoubleFromScilab(9, &nonlinCon))
+ if(getDoubleFromScilab(8, &nonlinCon))
{
return 1;
}
//Number of non-linear inequality constraints
- if(getDoubleFromScilab(10, &nonlinIneqCon))
+ if(getDoubleFromScilab(9, &nonlinIneqCon))
{
return 1;
}
-
- //Getting the required flag variables
-
- if(getDoubleFromScilab(12, &flag1))
+
+ //x0(starting point) matrix from scilab
+ if(getDoubleMatrixFromScilab(14, &x0_rows, &x0_cols, &x0ptr))
{
return 1;
}
- if(getDoubleFromScilab(14, &flag2))
+ //Getting number of iterations
+ if(getFixedSizeDoubleMatrixInList(15,2,temp1,temp2,&max_iter))
{
return 1;
}
- if(getDoubleFromScilab(16, &flag3))
+ //Getting Cpu Time
+ if(getFixedSizeDoubleMatrixInList(15,4,temp1,temp2,&cpu_time))
{
return 1;
}
@@ -164,7 +134,7 @@ int sci_solveminconp(char *fname)
// Starting Ipopt
- SmartPtr<minconNLP> Prob = new minconNLP(nVars, nCons, x0ptr, Aptr, bptr, Aeqptr, beqptr, A_rows, A_cols, b_rows, b_cols, Aeq_rows, Aeq_cols, beq_rows, beq_cols, lbptr, ubptr, nonlinCon, nonlinIneqCon, flag1, flag2, flag3);
+ SmartPtr<minconNLP> Prob = new minconNLP(nVars, nCons, x0ptr, Aptr, bptr, Aeqptr, beqptr, A_rows, A_cols, b_rows, b_cols, Aeq_rows, Aeq_cols, beq_rows, beq_cols, lbptr, ubptr, nonlinCon, nonlinIneqCon);
SmartPtr<IpoptApplication> app = IpoptApplicationFactory();
app->RethrowNonIpoptException(true);