summaryrefslogtreecommitdiff
path: root/sci_gateway/cpp
diff options
context:
space:
mode:
authorharpreet2016-07-01 00:11:55 +0530
committerharpreet2016-07-01 00:11:55 +0530
commit89b96cb79cbe75ba8c1afea61b3caca37a083f62 (patch)
tree1b879fb0dce2406c1c49bf5bdabcedfb12ff020c /sci_gateway/cpp
parent10e2e4d8b4a7592a8631ddac8e8d1664d6f0b9e3 (diff)
downloadFOSSEE-Optimization-toolbox-89b96cb79cbe75ba8c1afea61b3caca37a083f62.tar.gz
FOSSEE-Optimization-toolbox-89b96cb79cbe75ba8c1afea61b3caca37a083f62.tar.bz2
FOSSEE-Optimization-toolbox-89b96cb79cbe75ba8c1afea61b3caca37a083f62.zip
Windows Included
Diffstat (limited to 'sci_gateway/cpp')
-rw-r--r--[-rwxr-xr-x]sci_gateway/cpp/LinCLP.hpp0
-rw-r--r--sci_gateway/cpp/Makelib.mak70
-rw-r--r--sci_gateway/cpp/QuadNLP.hpp28
-rw-r--r--sci_gateway/cpp/builder_gateway_cpp.sce57
-rw-r--r--sci_gateway/cpp/libFOSSEE_Optimization_Toolbox.c2
-rwxr-xr-xsci_gateway/cpp/libFOSSEE_Optimization_Toolbox.sobin194948 -> 183588 bytes
-rw-r--r--sci_gateway/cpp/loader.sce1
-rw-r--r--sci_gateway/cpp/minbndNLP.hpp14
-rw-r--r--sci_gateway/cpp/minconNLP.hpp30
-rw-r--r--sci_gateway/cpp/minuncNLP.hpp12
-rw-r--r--sci_gateway/cpp/read_mps.cpp12
-rw-r--r--sci_gateway/cpp/sci_LinProg.cpp76
-rw-r--r--sci_gateway/cpp/sci_QuadNLP.cpp20
-rw-r--r--sci_gateway/cpp/sci_iofunc.cpp2
-rw-r--r--sci_gateway/cpp/sci_iofunc.hpp2
-rw-r--r--sci_gateway/cpp/sci_ipopt.cpp11
-rw-r--r--sci_gateway/cpp/sci_ipoptfminbnd.cpp11
-rw-r--r--sci_gateway/cpp/sci_ipoptfmincon.cpp17
-rw-r--r--sci_gateway/cpp/sci_ipoptfminunc.cpp11
-rw-r--r--sci_gateway/cpp/sci_minbndNLP.cpp18
-rw-r--r--sci_gateway/cpp/sci_minconNLP.cpp20
-rw-r--r--sci_gateway/cpp/sci_minuncNLP.cpp18
-rw-r--r--sci_gateway/cpp/sci_sym_get_dbl_arr.cpp122
-rw-r--r--sci_gateway/cpp/sci_sym_get_iteration_count.cpp51
-rw-r--r--sci_gateway/cpp/sci_sym_get_matrix.cpp165
-rw-r--r--sci_gateway/cpp/sci_sym_get_num_int.cpp70
-rw-r--r--sci_gateway/cpp/sci_sym_loadproblem.cpp3
-rw-r--r--sci_gateway/cpp/sci_sym_remove.cpp22
28 files changed, 669 insertions, 196 deletions
diff --git a/sci_gateway/cpp/LinCLP.hpp b/sci_gateway/cpp/LinCLP.hpp
index bd08505..bd08505 100755..100644
--- a/sci_gateway/cpp/LinCLP.hpp
+++ b/sci_gateway/cpp/LinCLP.hpp
diff --git a/sci_gateway/cpp/Makelib.mak b/sci_gateway/cpp/Makelib.mak
new file mode 100644
index 0000000..ebf94b1
--- /dev/null
+++ b/sci_gateway/cpp/Makelib.mak
@@ -0,0 +1,70 @@
+# ------------------------------------------------------
+# generated by builder.sce : Please do not edit this file
+# see TEMPLATE makefile for Visual Studio
+# see SCI/modules/dynamic_link/src/scripts/TEMPLATE_MAKEFILE.VC
+# ------------------------------------------------------
+SCIDIR = C:/PROGRA~1/SCILAB~1.2
+# ------------------------------------------------------
+# default include options
+INCLUDES = -I"$(SCIDIR)/libs/MALLOC/includes" \
+-I"$(SCIDIR)/libs/f2c" \
+-I"$(SCIDIR)/libs/hashtable" \
+-I"$(SCIDIR)/libs/intl" \
+-I"$(SCIDIR)/modules/core/includes" \
+-I"$(SCIDIR)/modules/api_scilab/includes" \
+-I"$(SCIDIR)/modules/call_scilab/includes" \
+-I"$(SCIDIR)/modules/output_stream/includes" \
+-I"$(SCIDIR)/modules/jvm/includes" \
+-I"$(SCIDIR)/modules/localization/includes" \
+-I"$(SCIDIR)/modules/dynamic_link/includes" \
+-I"$(SCIDIR)/modules/mexlib/includes" \
+-I"$(SCIDIR)/modules/time/includes" \
+-I"$(SCIDIR)/modules/windows_tools/includes"
+# ------------------------------------------------------
+# SCILAB_LIBS is used by the binary version of Scilab for linking external codes
+SCILAB_LIBS = "$(SCIDIR)/bin/blasplus.lib" \
+"$(SCIDIR)/bin/libf2c.lib" \
+"$(SCIDIR)/bin/core.lib" \
+"$(SCIDIR)/bin/core_f.lib" \
+"$(SCIDIR)/bin/lapack.lib" \
+"$(SCIDIR)/bin/libintl.lib" \
+"$(SCIDIR)/bin/intersci.lib" \
+"$(SCIDIR)/bin/output_stream.lib" \
+"$(SCIDIR)/bin/dynamic_link.lib" \
+"$(SCIDIR)/bin/integer.lib" \
+"$(SCIDIR)/bin/optimization_f.lib" \
+"$(SCIDIR)/bin/libjvm.lib" \
+"$(SCIDIR)/bin/scilocalization.lib" \
+"$(SCIDIR)/bin/linpack_f.lib" \
+"$(SCIDIR)/bin/call_scilab.lib" \
+"$(SCIDIR)/bin/time.lib" \
+"$(SCIDIR)/bin/api_scilab.lib" \
+"$(SCIDIR)/bin/libintl.lib" \
+"$(SCIDIR)/bin/scilab_windows.lib"
+# ------------------------------------------------------
+# name of the dll to be built
+LIBRARY = FOSSEE_Optimization_Toolbox
+# ------------------------------------------------------
+# list of files
+FILES_SRC = FOSSEE_Optimization_Toolbox.c globals.cpp read_mps.cpp sci_LinProg.cpp sci_QuadNLP.cpp sci_iofunc.cpp sci_ipopt.cpp sci_ipoptfminbnd.cpp sci_ipoptfmincon.cpp sci_ipoptfminunc.cpp sci_minbndNLP.cpp sci_minconNLP.cpp sci_minuncNLP.cpp sci_solver_status_query_functions.cpp sci_sym_addrowcol.cpp sci_sym_get_dbl_arr.cpp sci_sym_get_iteration_count.cpp sci_sym_get_matrix.cpp sci_sym_get_num_int.cpp sci_sym_getinfinity.cpp sci_sym_getobjsense.cpp sci_sym_getrowact.cpp sci_sym_isenvactive.cpp sci_sym_load_mps.cpp sci_sym_loadproblem.cpp sci_sym_openclose.cpp sci_sym_primalbound.cpp sci_sym_remove.cpp sci_sym_rowmod.cpp sci_sym_set_indices.cpp sci_sym_set_variables.cpp sci_sym_setcolsoln.cpp sci_sym_setobj.cpp sci_sym_solution.cpp sci_sym_solve.cpp sci_sym_varbounds.cpp sci_vartype.cpp
+# ------------------------------------------------------
+# list of objects file
+OBJS = FOSSEE_Optimization_Toolbox.obj globals.obj read_mps.obj sci_LinProg.obj sci_QuadNLP.obj sci_iofunc.obj sci_ipopt.obj sci_ipoptfminbnd.obj sci_ipoptfmincon.obj sci_ipoptfminunc.obj sci_minbndNLP.obj sci_minconNLP.obj sci_minuncNLP.obj sci_solver_status_query_functions.obj sci_sym_addrowcol.obj sci_sym_get_dbl_arr.obj sci_sym_get_iteration_count.obj sci_sym_get_matrix.obj sci_sym_get_num_int.obj sci_sym_getinfinity.obj sci_sym_getobjsense.obj sci_sym_getrowact.obj sci_sym_isenvactive.obj sci_sym_load_mps.obj sci_sym_loadproblem.obj sci_sym_openclose.obj sci_sym_primalbound.obj sci_sym_remove.obj sci_sym_rowmod.obj sci_sym_set_indices.obj sci_sym_set_variables.obj sci_sym_setcolsoln.obj sci_sym_setobj.obj sci_sym_solution.obj sci_sym_solve.obj sci_sym_varbounds.obj sci_vartype.obj
+OBJS_WITH_PATH = Release/FOSSEE_Optimization_Toolbox.obj Release/globals.obj Release/read_mps.obj Release/sci_LinProg.obj Release/sci_QuadNLP.obj Release/sci_iofunc.obj Release/sci_ipopt.obj Release/sci_ipoptfminbnd.obj Release/sci_ipoptfmincon.obj Release/sci_ipoptfminunc.obj Release/sci_minbndNLP.obj Release/sci_minconNLP.obj Release/sci_minuncNLP.obj Release/sci_solver_status_query_functions.obj Release/sci_sym_addrowcol.obj Release/sci_sym_get_dbl_arr.obj Release/sci_sym_get_iteration_count.obj Release/sci_sym_get_matrix.obj Release/sci_sym_get_num_int.obj Release/sci_sym_getinfinity.obj Release/sci_sym_getobjsense.obj Release/sci_sym_getrowact.obj Release/sci_sym_isenvactive.obj Release/sci_sym_load_mps.obj Release/sci_sym_loadproblem.obj Release/sci_sym_openclose.obj Release/sci_sym_primalbound.obj Release/sci_sym_remove.obj Release/sci_sym_rowmod.obj Release/sci_sym_set_indices.obj Release/sci_sym_set_variables.obj Release/sci_sym_setcolsoln.obj Release/sci_sym_setobj.obj Release/sci_sym_solution.obj Release/sci_sym_solve.obj Release/sci_sym_varbounds.obj Release/sci_vartype.obj
+# ------------------------------------------------------
+# added libraries
+FORTRAN_RUNTIME_LIBRARIES =
+OTHERLIBS =
+# ------------------------------------------------------
+!include $(SCIDIR)\modules\dynamic_link\src\scripts\Makefile.incl.mak
+# ------------------------------------------------------
+#CC =
+# ------------------------------------------------------
+CFLAGS = $(CC_OPTIONS) -D__SCILAB_TOOLBOX__ -DFORDLL -D__USE_DEPRECATED_STACK_FUNCTIONS__ -w -I C:\Users\harpreet\Desktop\symphony-work\symphony\sci_gateway\cpp\ -I C:\Users\harpreet\Desktop\symphony-work\symphony\sci_gateway\cpp\\..\..\thirdparty\windows\include\coin
+# ------------------------------------------------------
+FFLAGS = $(FC_OPTIONS) -DFORDLL
+# ------------------------------------------------------
+EXTRA_LDFLAGS = C:\Users\harpreet\Desktop\symphony-work\symphony\sci_gateway\cpp\\..\..\thirdparty\windows\lib\x64\libClp.lib C:\Users\harpreet\Desktop\symphony-work\symphony\sci_gateway\cpp\\..\..\thirdparty\windows\lib\x64\libCgl.lib C:\Users\harpreet\Desktop\symphony-work\symphony\sci_gateway\cpp\\..\..\thirdparty\windows\lib\x64\libOsi.lib C:\Users\harpreet\Desktop\symphony-work\symphony\sci_gateway\cpp\\..\..\thirdparty\windows\lib\x64\libOsiClp.lib C:\Users\harpreet\Desktop\symphony-work\symphony\sci_gateway\cpp\\..\..\thirdparty\windows\lib\x64\libCoinUtils.lib C:\Users\harpreet\Desktop\symphony-work\symphony\sci_gateway\cpp\\..\..\thirdparty\windows\lib\x64\libSymphony.lib C:\Users\harpreet\Desktop\symphony-work\symphony\sci_gateway\cpp\\..\..\thirdparty\windows\lib\x64\IpOptFSS.lib C:\Users\harpreet\Desktop\symphony-work\symphony\sci_gateway\cpp\\..\..\thirdparty\windows\lib\x64\IpOpt-vc10.lib
+# ------------------------------------------------------
+!include $(SCIDIR)\modules\dynamic_link\src\scripts\Makedll.incl
+# ------------------------------------------------------
diff --git a/sci_gateway/cpp/QuadNLP.hpp b/sci_gateway/cpp/QuadNLP.hpp
index 4020913..4e0da42 100644
--- a/sci_gateway/cpp/QuadNLP.hpp
+++ b/sci_gateway/cpp/QuadNLP.hpp
@@ -26,46 +26,44 @@ class QuadNLP : public TNLP
Index numConstr_; // Number of constraints.
- const Number *qMatrix_ = NULL; //qMatrix_ is a pointer to matrix of size numVars X numVars_
+ const Number *qMatrix_; //qMatrix_ is a pointer to matrix of size numVars X numVars_
// with coefficents of quadratic terms in objective function.
- const Number *lMatrix_ = NULL;//lMatrix_ is a pointer to matrix of size 1*numVars_
+ const Number *lMatrix_;//lMatrix_ is a pointer to matrix of size 1*numVars_
// with coefficents of linear terms in objective function.
- const Number *conMatrix_ = NULL;//conMatrix_ is a pointer to matrix of size numConstr X numVars
// with coefficients of terms in a each objective in each row.
+ const Number *conMatrix_ ;//conMatrix_ is a pointer to matrix of size numConstr X numVars
- const Number *conUB_= NULL; //conUB_ is a pointer to a matrix of size of 1*numConstr_
+ const Number *conUB_; //conUB_ is a pointer to a matrix of size of 1*numConstr_
// with upper bounds of all constraints.
- const Number *conLB_ = NULL; //conLB_ is a pointer to a matrix of size of 1*numConstr_
+ const Number *conLB_ ; //conLB_ is a pointer to a matrix of size of 1*numConstr_
// with lower bounds of all constraints.
- const Number *varUB_= NULL; //varUB_ is a pointer to a matrix of size of 1*numVar_
+ const Number *varUB_; //varUB_ is a pointer to a matrix of size of 1*numVar_
// with upper bounds of all variables.
- const Number *varLB_= NULL; //varLB_ is a pointer to a matrix of size of 1*numVar_
+ const Number *varLB_; //varLB_ is a pointer to a matrix of size of 1*numVar_
// with lower bounds of all variables.
- const Number *varGuess_= NULL; //varGuess_ is a pointer to a matrix of size of 1*numVar_
+ const Number *varGuess_; //varGuess_ is a pointer to a matrix of size of 1*numVar_
// with initial guess of all variables.
- Number *finalX_= NULL; //finalX_ is a pointer to a matrix of size of 1*numVar_
+ Number *finalX_; //finalX_ is a pointer to a matrix of size of 1*numVar_
// with final value for the primal variables.
- Number *finalZl_= NULL; //finalZl_ is a pointer to a matrix of size of 1*numVar_
+ Number *finalZl_; //finalZl_ is a pointer to a matrix of size of 1*numVar_
// with final values for the lower bound multipliers
- Number *finalZu_= NULL; //finalZu_ is a pointer to a matrix of size of 1*numVar_
+ Number *finalZu_; //finalZu_ is a pointer to a matrix of size of 1*numVar_
// with final values for the upper bound multipliers
- Number *finalLambda_= NULL; //finalLambda_ is a pointer to a matrix of size of 1*numConstr_
+ Number *finalLambda_; //finalLambda_ is a pointer to a matrix of size of 1*numConstr_
// with final values for the upper bound multipliers
Number finalObjVal_; //finalObjVal_ is a scalar with the final value of the objective.
- int iter_; //Number of iteration.
-
int status_; //Solver return status
QuadNLP(const QuadNLP&);
@@ -123,8 +121,6 @@ class QuadNLP : public TNLP
double getObjVal(); //Returns the output of the final value of the objective.
- double iterCount(); //Returns the iteration count
-
int returnStatus(); //Returns the status count
diff --git a/sci_gateway/cpp/builder_gateway_cpp.sce b/sci_gateway/cpp/builder_gateway_cpp.sce
index c92bd7f..f0890d9 100644
--- a/sci_gateway/cpp/builder_gateway_cpp.sce
+++ b/sci_gateway/cpp/builder_gateway_cpp.sce
@@ -14,20 +14,10 @@ lines(0)
toolbox_title = "FOSSEE_Optimization_Toolbox";
-[a, opt] = getversion();
-Version = opt(2);
-
-Build_64Bits = %f;
+Build_64Bits = %t;
path_builder = get_absolute_file_path('builder_gateway_cpp.sce');
-tools_path = path_builder + "../../thirdparty/linux/";
-
-C_Flags=["-D__USE_DEPRECATED_STACK_FUNCTIONS__ -w -fpermissive -I"+tools_path+"include/coin -Wl,-rpath="+tools_path+"lib/"+Version+filesep()+" "]
-
-Linker_Flag = ["-L"+tools_path+"lib/"+Version+filesep()+"libSym"+" "+"-L"+tools_path+"lib/"+Version+filesep()+"libipopt"+" "+"-L"+tools_path+"lib/"+Version+filesep()+"libClp"+" "+"-L"+tools_path+"lib/"+Version+filesep()+"libOsiClp"+" "+"-L"+tools_path+"lib/"+Version+filesep()+"libCoinUtils" ]
-
-
//Name of All the Functions
Function_Names = [
//for opening/closing environment and checking if it is open/close
@@ -79,7 +69,6 @@ Function_Names = [
"sym_setConstrUpper","sci_sym_setConstrBound";
"sym_setConstrType","sci_sym_setConstrType";
"sym_getMatrix","sci_sym_get_matrix";
- "sym_getConstrSense","sci_sym_get_row_sense";
//add/remove variables and constraints
"sym_addConstr","sci_sym_addConstr";
@@ -126,18 +115,20 @@ Function_Names = [
//Name of all the files to be compiled
Files = [
"globals.cpp",
- "sci_iofunc.hpp",
"sci_iofunc.cpp",
"sci_sym_openclose.cpp",
"sci_solver_status_query_functions.cpp",
- "sci_sym_solve.cpp",
+ "sci_sym_solve.cpp",
"sci_sym_loadproblem.cpp",
"sci_sym_isenvactive.cpp",
"sci_sym_load_mps.cpp",
"sci_vartype.cpp",
"sci_sym_getinfinity.cpp",
"sci_sym_solution.cpp",
- "sym_data_query_functions.cpp"
+ "sci_sym_get_dbl_arr.cpp",
+ "sci_sym_get_iteration_count.cpp",
+ "sci_sym_get_matrix.cpp",
+ "sci_sym_get_num_int.cpp",
"sci_sym_set_variables.cpp",
"sci_sym_setobj.cpp",
"sci_sym_varbounds.cpp",
@@ -150,24 +141,42 @@ Files = [
"sci_sym_getobjsense.cpp",
"sci_sym_remove.cpp",
"sci_QuadNLP.cpp",
- "QuadNLP.hpp",
"sci_ipopt.cpp",
- "minuncNLP.hpp",
+ "sci_QuadNLP.cpp",
+ "sci_ipopt.cpp",
"sci_minuncNLP.cpp",
"sci_ipoptfminunc.cpp",
- "minbndNLP.hpp",
"sci_minbndNLP.cpp",
"sci_ipoptfminbnd.cpp",
- "minconNLP.hpp",
"sci_minconNLP.cpp",
"sci_ipoptfmincon.cpp",
- "sci_ipopt.cpp",
"sci_LinProg.cpp",
- "sci_LinCLP.cpp",
- "LinCLP.hpp",
"read_mps.cpp"
]
-tbx_build_gateway(toolbox_title,Function_Names,Files,get_absolute_file_path("builder_gateway_cpp.sce"), [], Linker_Flag, C_Flags, [], "g++");
+[a, opt] = getversion();
+Version = opt(2);
-clear WITHOUT_AUTO_PUTLHSVAR toolbox_title Function_Names Files Linker_Flag C_Flags;
+//Build_64Bits = %f;
+
+if getos()=="Windows" then
+ third_dir = path_builder+filesep()+'..'+filesep()+'..'+filesep()+'thirdparty';
+ lib_base_dir = third_dir + filesep() + 'windows' + filesep() + 'lib' + filesep() + Version + filesep();
+ inc_base_dir = third_dir + filesep() + 'windows' + filesep() + 'include' + filesep() + 'coin';
+ C_Flags=['-D__USE_DEPRECATED_STACK_FUNCTIONS__ -w -I '+path_builder+' '+ '-I '+inc_base_dir+' ']
+ Linker_Flag = [lib_base_dir+"libClp.lib "+lib_base_dir+"libCgl.lib "+lib_base_dir+"libOsi.lib "+lib_base_dir+"libOsiClp.lib "+lib_base_dir+"libCoinUtils.lib "+lib_base_dir+"libSymphony.lib "+lib_base_dir+"IpOptFSS.lib "+lib_base_dir+"IpOpt-vc10.lib "]
+
+else
+ third_dir = path_builder+filesep()+'..'+filesep()+'..'+filesep()+'thirdparty';
+ lib_base_dir = third_dir + filesep() + 'linux' + filesep() + 'lib' + filesep() + Version + filesep();
+ inc_base_dir = third_dir + filesep() + 'linux' + filesep() + 'include' + filesep() + 'coin';
+
+ C_Flags=["-D__USE_DEPRECATED_STACK_FUNCTIONS__ -w -fpermissive -I"+path_builder+" -I"+inc_base_dir+" -Wl,-rpath="+lib_base_dir+" "]
+
+ Linker_Flag = ["-L"+lib_base_dir+"libSym"+" "+"-L"+lib_base_dir+"libipopt"+" "+"-L"+lib_base_dir+"libClp"+" "+"-L"+lib_base_dir+"libOsiClp"+" "+"-L"+lib_base_dir+"libCoinUtils" ]
+
+end
+
+tbx_build_gateway(toolbox_title,Function_Names,Files,get_absolute_file_path("builder_gateway_cpp.sce"), [], Linker_Flag, C_Flags);
+
+clear toolbox_title Function_Names Files Linker_Flag C_Flags;
diff --git a/sci_gateway/cpp/libFOSSEE_Optimization_Toolbox.c b/sci_gateway/cpp/libFOSSEE_Optimization_Toolbox.c
index cd53066..5e5ce31 100644
--- a/sci_gateway/cpp/libFOSSEE_Optimization_Toolbox.c
+++ b/sci_gateway/cpp/libFOSSEE_Optimization_Toolbox.c
@@ -44,7 +44,6 @@ extern Gatefunc sci_sym_setConstrBound;
extern Gatefunc sci_sym_setConstrBound;
extern Gatefunc sci_sym_setConstrType;
extern Gatefunc sci_sym_get_matrix;
-extern Gatefunc sci_sym_get_row_sense;
extern Gatefunc sci_sym_addConstr;
extern Gatefunc sci_sym_addVar;
extern Gatefunc sci_sym_delete_cols;
@@ -109,7 +108,6 @@ static GenericTable Tab[]={
{(Myinterfun)sci_gateway,sci_sym_setConstrBound,"sym_setConstrUpper"},
{(Myinterfun)sci_gateway,sci_sym_setConstrType,"sym_setConstrType"},
{(Myinterfun)sci_gateway,sci_sym_get_matrix,"sym_getMatrix"},
- {(Myinterfun)sci_gateway,sci_sym_get_row_sense,"sym_getConstrSense"},
{(Myinterfun)sci_gateway,sci_sym_addConstr,"sym_addConstr"},
{(Myinterfun)sci_gateway,sci_sym_addVar,"sym_addVar"},
{(Myinterfun)sci_gateway,sci_sym_delete_cols,"sym_deleteVars"},
diff --git a/sci_gateway/cpp/libFOSSEE_Optimization_Toolbox.so b/sci_gateway/cpp/libFOSSEE_Optimization_Toolbox.so
index 28c2d3b..78cf4da 100755
--- a/sci_gateway/cpp/libFOSSEE_Optimization_Toolbox.so
+++ b/sci_gateway/cpp/libFOSSEE_Optimization_Toolbox.so
Binary files differ
diff --git a/sci_gateway/cpp/loader.sce b/sci_gateway/cpp/loader.sce
index 1ec953f..8b15fde 100644
--- a/sci_gateway/cpp/loader.sce
+++ b/sci_gateway/cpp/loader.sce
@@ -48,7 +48,6 @@ list_functions = [ 'sym_open';
'sym_setConstrUpper';
'sym_setConstrType';
'sym_getMatrix';
- 'sym_getConstrSense';
'sym_addConstr';
'sym_addVar';
'sym_deleteVars';
diff --git a/sci_gateway/cpp/minbndNLP.hpp b/sci_gateway/cpp/minbndNLP.hpp
index 17d5a7e..684d905 100644
--- a/sci_gateway/cpp/minbndNLP.hpp
+++ b/sci_gateway/cpp/minbndNLP.hpp
@@ -24,26 +24,24 @@ class minbndNLP : public TNLP
Index numConstr_; //Number of constraints
- Number *finalX_= NULL; //finalX_ is a pointer to a matrix of size of 1*1
+ Number *finalX_; //finalX_ is a pointer to a matrix of size of 1*1
//with final value for the primal variable.
- Number *finalZl_= NULL; //finalZl_ is a pointer to a matrix of size of 1*numVar_
+ Number *finalZl_; //finalZl_ is a pointer to a matrix of size of 1*numVar_
// with final values for the lower bound multipliers
- Number *finalZu_= NULL; //finalZu_ is a pointer to a matrix of size of 1*numVar_
+ Number *finalZu_; //finalZu_ is a pointer to a matrix of size of 1*numVar_
// with final values for the upper bound multipliers
Number finalObjVal_; //finalObjVal_ is a scalar with the final value of the objective.
- int iter_; //Number of iteration.
-
int status_; //Solver return status
- const Number *varUB_= NULL; //varUB_ is a pointer to a matrix of size of 1*1
+ const Number *varUB_; //varUB_ is a pointer to a matrix of size of 1*1
// with upper bounds of all variable.
- const Number *varLB_= NULL; //varLB_ is a pointer to a matrix of size of 1*1
+ const Number *varLB_; //varLB_ is a pointer to a matrix of size of 1*1
// with lower bounds of all variable.
minbndNLP(const minbndNLP&);
@@ -106,8 +104,6 @@ class minbndNLP : public TNLP
double getObjVal(); //Returns the output of the final value of the objective.
- double iterCount(); //Returns the iteration count
-
int returnStatus(); //Returns the status count
};
diff --git a/sci_gateway/cpp/minconNLP.hpp b/sci_gateway/cpp/minconNLP.hpp
index 0dcaf26..b768ec5 100644
--- a/sci_gateway/cpp/minconNLP.hpp
+++ b/sci_gateway/cpp/minconNLP.hpp
@@ -28,13 +28,13 @@ class minconNLP : public TNLP
Number nonlinIneqCon_; //Number of non-linear inequality constraints
- const Number *A_= NULL; //Matrix for linear inequality constraints
+ const Number *A_; //Matrix for linear inequality constraints
- const Number *b_= NULL; //Matrix for bounds of linear inequality constraints
+ const Number *b_; //Matrix for bounds of linear inequality constraints
- const Number *Aeq_= NULL; //Matrix for linear equality constraints
+ const Number *Aeq_; //Matrix for linear equality constraints
- const Number *beq_= NULL; //Matrix for bounds of linear equality constraints
+ const Number *beq_; //Matrix for bounds of linear equality constraints
Index Arows_; //Number of rows of linear inequality constraints
@@ -53,39 +53,37 @@ class minconNLP : public TNLP
Index beqcols_; //Number of columns of bounds of linear equality constraints
- const Number *varGuess_= NULL; //varGuess_ is a pointer to a matrix of size of 1*numVars_
+ const Number *varGuess_; //varGuess_ is a pointer to a matrix of size of 1*numVars_
//with initial guess of all variables.
- const Number *varUB_= NULL; //varUB_ is a pointer to a matrix of size of 1*numVar_
+ const Number *varUB_; //varUB_ is a pointer to a matrix of size of 1*numVar_
// with upper bounds of all variables.
- const Number *varLB_= NULL; //varLB_ is a pointer to a matrix of size of 1*numVar_
+ const Number *varLB_; //varLB_ is a pointer to a matrix of size of 1*numVar_
// with lower bounds of all variables.
- Number *finalZl_= NULL; //finalZl_ is a pointer to a matrix of size of 1*numVar_
+ Number *finalZl_; //finalZl_ is a pointer to a matrix of size of 1*numVar_
// with final values for the lower bound multipliers
- Number *finalZu_= NULL; //finalZu_ is a pointer to a matrix of size of 1*numVar_
+ Number *finalZu_; //finalZu_ is a pointer to a matrix of size of 1*numVar_
// with final values for the upper bound multipliers
- Number *finalLambda_= NULL; //finalLambda_ is a pointer to a matrix of size of 1*numConstr_
+ Number *finalLambda_; //finalLambda_ is a pointer to a matrix of size of 1*numConstr_
// with final values for the upper bound multipliers
- Number *finalX_= NULL; //finalX_ is a pointer to a matrix of size of 1*numVars_
+ Number *finalX_; //finalX_ is a pointer to a matrix of size of 1*numVars_
//with final value for the primal variables.
- Number *finalGradient_=NULL; //finalGradient_ is a pointer to a matrix of size of numVars_*numVars_
+ Number *finalGradient_; //finalGradient_ is a pointer to a matrix of size of numVars_*numVars_
//with final value of gradient for the primal variables.
- Number *finalHessian_=NULL; //finalHessian_ is a pointer to a matrix of size of 1*numVar_
+ Number *finalHessian_; //finalHessian_ is a pointer to a matrix of size of 1*numVar_
//with final value of hessian for the primal variables.
Number finalObjVal_; //finalObjVal_ is a scalar with the final value of the objective.
- int iter_; //Number of iteration.
-
int status_; //Solver return status
@@ -158,8 +156,6 @@ class minconNLP : public TNLP
double getObjVal(); //Returns the output of the final value of the objective.
- double iterCount(); //Returns the iteration count
-
int returnStatus(); //Returns the status count
};
diff --git a/sci_gateway/cpp/minuncNLP.hpp b/sci_gateway/cpp/minuncNLP.hpp
index 70910e5..fba38f7 100644
--- a/sci_gateway/cpp/minuncNLP.hpp
+++ b/sci_gateway/cpp/minuncNLP.hpp
@@ -28,18 +28,16 @@ class minuncNLP : public TNLP
Number flag2_; //Used for Hessian ON/OFF
- const Number *varGuess_= NULL; //varGuess_ is a pointer to a matrix of size of 1*numVars_ with initial guess of all variables.
+ const Number *varGuess_; //varGuess_ is a pointer to a matrix of size of 1*numVars_ with initial guess of all variables.
- Number *finalX_= NULL; //finalX_ is a pointer to a matrix of size of 1*numVars_ with final value for the primal variables.
+ Number *finalX_; //finalX_ is a pointer to a matrix of size of 1*numVars_ with final value for the primal variables.
- Number *finalGradient_=NULL; //finalGradient_ is a pointer to a matrix of size of numVars_*numVars_ with final value of gradient for the primal variables.
+ Number *finalGradient_; //finalGradient_ is a pointer to a matrix of size of numVars_*numVars_ with final value of gradient for the primal variables.
- Number *finalHessian_=NULL; //finalHessian_ is a pointer to a matrix of size of 1*numVar_ with final value of hessian for the primal variables.
+ Number *finalHessian_; //finalHessian_ is a pointer to a matrix of size of 1*numVar_ with final value of hessian for the primal variables.
Number finalObjVal_; //finalObjVal_ is a scalar with the final value of the objective.
- int iter_; //Number of iteration.
-
int status_; //Solver return status
@@ -103,8 +101,6 @@ class minuncNLP : public TNLP
double getObjVal(); //Returns the output of the final value of the objective.
- double iterCount(); //Returns the iteration count
-
int returnStatus(); //Returns the status count
};
diff --git a/sci_gateway/cpp/read_mps.cpp b/sci_gateway/cpp/read_mps.cpp
index 31f71b8..79a78c4 100644
--- a/sci_gateway/cpp/read_mps.cpp
+++ b/sci_gateway/cpp/read_mps.cpp
@@ -102,12 +102,8 @@ int sci_rmps(char *fname)
returnDoubleMatrixToScilab(5 , 1 , numVars_ , reducedCost);
returnDoubleMatrixToScilab(6 , 1 , numCons_ , dual);
- free(xValue);
- free(dual);
- free(reducedCost);
+ free((double *)xValue);
+ free((double *)dual);
+ free((double *)reducedCost);
+ }
}
-}
-
-
-
-
diff --git a/sci_gateway/cpp/sci_LinProg.cpp b/sci_gateway/cpp/sci_LinProg.cpp
index 95538ec..6be41cd 100644
--- a/sci_gateway/cpp/sci_LinProg.cpp
+++ b/sci_gateway/cpp/sci_LinProg.cpp
@@ -6,7 +6,10 @@
*/
#include "sci_iofunc.hpp"
-#include "LinCLP.hpp"
+#include"OsiSolverInterface.hpp"
+#include "OsiClpSolverInterface.hpp"
+#include "CoinPackedMatrix.hpp"
+#include "CoinPackedVector.hpp"
extern "C"{
#include <api_scilab.h>
@@ -33,8 +36,6 @@ int sci_linearprog(char *fname)
double* options;
//Flag for Mps
double flagMps;
- //mps file path
- char * mpsFile;
//Error structure in Scilab
SciErr sciErr;
//Number of rows and columns in objective function
@@ -113,35 +114,70 @@ int sci_linearprog(char *fname)
return 1;
}
- //Call to the Clp Solver
- LinCLP* Prob = new LinCLP(nVars,nCons,obj,conMatrix,conlb,conub,lb,ub,options);
-
+ OsiSolverInterface* si = new OsiClpSolverInterface();
+ //Defining the constraint matrix
+ CoinPackedMatrix *matrix = new CoinPackedMatrix(false , 0 , 0);
+ matrix->setDimensions(0 , nVars);
+ for(int i=0 ; i<nCons ; i++)
+ {
+ CoinPackedVector row;
+ for(int j=0 ; j<nVars; j++)
+ {
+ row.insert(j, conMatrix[i+j*nCons]);
+ }
+ matrix->appendRow(row);
+ }
+ //setting options for maximum iterations
+ si->setIntParam(OsiMaxNumIteration,options[0]);
+
+ //Load the problem to OSI
+ si->loadProblem(*matrix , lb , ub, obj , conlb , conub);
+
+ //Solve the problem
+ si->initialSolve();
//Output the solution to Scilab
//get solution for x
- double* xValue = Prob->getX();
-
+ const double* xValue = si->getColSolution();
+ for(int i=0;i<nVars;i++)
+ {
+ sciprint("%lf",xValue[i]);
+ }
//get objective value
- double objValue = Prob->getObjVal();
-
- //get Status value
- double status = Prob->returnStatus();
-
+ double objValue = si->getObjValue();
+
+ //get Status value
+ double status_ = 0;
+ if(si->isProvenOptimal())
+ status_=0;
+ else if(si->isProvenPrimalInfeasible())
+ status_=1;
+ else if(si->isProvenDualInfeasible())
+ status_=2;
+ else if(si->isIterationLimitReached())
+ status_=3;
+ else if(si->isAbandoned())
+ status_=4;
+ else if(si->isPrimalObjectiveLimitReached())
+ status_=5;
+ else if(si->isDualObjectiveLimitReached())
+ status_=6;
+
//get number of iterations
- double iterations = Prob->iterCount();
-
+ double iterations = si->getIterationCount();
+
//get reduced cost
- double* Zl = Prob->getReducedCost();
-
+ const double* Zl = si->getReducedCost();
+
//get dual vector
- double* dual = Prob->getDual();
+ const double* dual = si->getRowPrice();
returnDoubleMatrixToScilab(1 , 1 , nVars , xValue);
returnDoubleMatrixToScilab(2 , 1 , 1 , &objValue);
- returnDoubleMatrixToScilab(3 , 1 , 1 , &status);
+ returnDoubleMatrixToScilab(3 , 1 , 1 , &status_);
returnDoubleMatrixToScilab(4 , 1 , 1 , &iterations);
returnDoubleMatrixToScilab(5 , 1 , nVars , Zl);
returnDoubleMatrixToScilab(6 , 1 , nCons , dual);
-
+
}
}
diff --git a/sci_gateway/cpp/sci_QuadNLP.cpp b/sci_gateway/cpp/sci_QuadNLP.cpp
index b1a0e04..8ec6f40 100644
--- a/sci_gateway/cpp/sci_QuadNLP.cpp
+++ b/sci_gateway/cpp/sci_QuadNLP.cpp
@@ -10,7 +10,11 @@
// Email: toolbox@scilab.in
#include "QuadNLP.hpp"
-#include "IpIpoptData.hpp"
+#include <IpIpoptApplication.hpp>
+#include <IpSolveStatistics.hpp>
+#include <IpTNLP.hpp>
+#include <IpIpoptCalculatedQuantities.hpp>
+#include <IpSmartPtr.hpp>
extern "C"{
#include <api_scilab.h>
@@ -18,7 +22,11 @@ extern "C"{
#include <BOOL.h>
#include <localization.h>
#include <sciprint.h>
-
+#if defined(_MSC_VER)
+#include "config_ipopt.h"
+#else
+#include "IpoptConfig.h"
+#endif
double x_static,i, *op_obj_x = NULL,*op_obj_value = NULL;
@@ -214,9 +222,6 @@ void QuadNLP::finalize_solution(SolverReturn status,
finalObjVal_ = obj_value;
status_ = status;
- if (status_ == 0 | status_ == 1 | status_ == 2){
- iter_ = ip_data->iter_count();
- }
}
const double * QuadNLP::getX()
@@ -244,11 +249,6 @@ void QuadNLP::finalize_solution(SolverReturn status,
return finalObjVal_;
}
- double QuadNLP::iterCount()
- {
- return (double)iter_;
- }
-
int QuadNLP::returnStatus()
{
return status_;
diff --git a/sci_gateway/cpp/sci_iofunc.cpp b/sci_gateway/cpp/sci_iofunc.cpp
index 8dc2acf..978a017 100644
--- a/sci_gateway/cpp/sci_iofunc.cpp
+++ b/sci_gateway/cpp/sci_iofunc.cpp
@@ -267,7 +267,7 @@ int returnDoubleToScilab(double retVal)
return 0;
}
-int returnDoubleMatrixToScilab(int itemPos, int rows, int cols, double *dest)
+int returnDoubleMatrixToScilab(int itemPos, int rows, int cols, const double *dest)
{
SciErr sciErr;
//same steps as above
diff --git a/sci_gateway/cpp/sci_iofunc.hpp b/sci_gateway/cpp/sci_iofunc.hpp
index 2c84c82..287002a 100644
--- a/sci_gateway/cpp/sci_iofunc.hpp
+++ b/sci_gateway/cpp/sci_iofunc.hpp
@@ -18,7 +18,7 @@ int getStringFromScilab(int argNum,char** dest);
//output
int return0toScilab();
int returnDoubleToScilab(double retVal);
-int returnDoubleMatrixToScilab(int itemPos, int rows, int cols, double *dest);
+int returnDoubleMatrixToScilab(int itemPos, int rows, int cols,const double *dest);
int returnIntegerMatrixToScilab(int itemPos, int rows, int cols, int *dest);
#endif //SCI_IOFUNCHEADER
diff --git a/sci_gateway/cpp/sci_ipopt.cpp b/sci_gateway/cpp/sci_ipopt.cpp
index 635003e..e25ccd0 100644
--- a/sci_gateway/cpp/sci_ipopt.cpp
+++ b/sci_gateway/cpp/sci_ipopt.cpp
@@ -11,6 +11,7 @@
#include "sci_iofunc.hpp"
#include "IpIpoptApplication.hpp"
+#include "IpSolveStatistics.hpp"
#include "QuadNLP.hpp"
extern "C"{
@@ -33,11 +34,12 @@ int sci_solveqp(char *fname)
// Input arguments
double *QItems=NULL,*PItems=NULL,*ConItems=NULL,*conUB=NULL,*conLB=NULL;
double *cpu_time=NULL,*max_iter=NULL,*varUB=NULL,*varLB=NULL,*init_guess=NULL;
- static unsigned int nVars = 0,nCons = 0;
+ static int nVars = 0,nCons = 0;
unsigned int temp1 = 0,temp2 = 0, iret = 0;
// Output arguments
- double *fX = NULL, ObjVal=0,iteration=0, *Zl=NULL, *Zu=NULL, *Lambda=NULL;
+ const double *fX = NULL, *Zl=NULL, *Zu=NULL, *Lambda=NULL;
+ double ObjVal=0,iteration=0;
int rstatus = 0;
////////// Manage the input argument //////////
@@ -140,7 +142,6 @@ int sci_solveqp(char *fname)
new QuadNLP(nVars,nCons,QItems,PItems,ConItems,conUB,conLB,varUB,varLB,init_guess);
SmartPtr<IpoptApplication> app = IpoptApplicationFactory();
- app->RethrowNonIpoptException(true);
////////// Managing the parameters //////////
@@ -164,7 +165,7 @@ int sci_solveqp(char *fname)
}
// Ask Ipopt to solve the problem
- status = app->OptimizeTNLP(Prob);
+ status = app->OptimizeTNLP((SmartPtr<TNLP>&)Prob);
rstatus = Prob->returnStatus();
@@ -173,7 +174,7 @@ int sci_solveqp(char *fname)
if (rstatus >= 0 | rstatus <= 7){
fX = Prob->getX();
ObjVal = Prob->getObjVal();
- iteration = Prob->iterCount();
+ iteration = (double)app->Statistics()->IterationCount();
if (returnDoubleMatrixToScilab(1, 1, nVars, fX))
{
diff --git a/sci_gateway/cpp/sci_ipoptfminbnd.cpp b/sci_gateway/cpp/sci_ipoptfminbnd.cpp
index aa5addf..b06c741 100644
--- a/sci_gateway/cpp/sci_ipoptfminbnd.cpp
+++ b/sci_gateway/cpp/sci_ipoptfminbnd.cpp
@@ -49,9 +49,9 @@ int sci_solveminbndp(char *fname)
int x1_rows, x1_cols, x2_rows, x2_cols;
// Output arguments
- double *fX = NULL, ObjVal=0,iteration=0,cpuTime=0,fobj_eval=0;
- double *fZl=NULL;
- double *fZu=NULL;
+ double ObjVal=0,iteration=0,cpuTime=0,fobj_eval=0;
+ const double *fX = NULL,*fZl=NULL;
+ const double *fZu=NULL;
double dual_inf, constr_viol, complementarity, kkt_error;
int rstatus = 0;
int int_fobj_eval, int_constr_eval, int_fobj_grad_eval, int_constr_jac_eval, int_hess_eval;
@@ -110,7 +110,6 @@ int sci_solveminbndp(char *fname)
SmartPtr<minbndNLP> Prob = new minbndNLP(nVars,nCons,varLB,varUB);
SmartPtr<IpoptApplication> app = IpoptApplicationFactory();
- app->RethrowNonIpoptException(true);
////////// Managing the parameters //////////
@@ -126,7 +125,7 @@ int sci_solveminbndp(char *fname)
return (int) status;
}
// Ask Ipopt to solve the problem
- status = app->OptimizeTNLP(Prob);
+ status = app->OptimizeTNLP((SmartPtr<TNLP>&)Prob);
//Get the solve statistics
cpuTime = app->Statistics()->TotalCPUTime();
@@ -139,7 +138,7 @@ int sci_solveminbndp(char *fname)
fX = Prob->getX();
ObjVal = Prob->getObjVal();
- iteration = Prob->iterCount();
+ iteration = (double)app->Statistics()->IterationCount();
fobj_eval=(double)int_fobj_eval;
fZl = Prob->getZl();
fZu = Prob->getZu();
diff --git a/sci_gateway/cpp/sci_ipoptfmincon.cpp b/sci_gateway/cpp/sci_ipoptfmincon.cpp
index c19687d..4f9ea71 100644
--- a/sci_gateway/cpp/sci_ipoptfmincon.cpp
+++ b/sci_gateway/cpp/sci_ipoptfmincon.cpp
@@ -48,13 +48,13 @@ int sci_solveminconp(char *fname)
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
- double *fX = NULL, ObjVal=0,iteration=0,cpuTime=0,fobj_eval=0;
+ double ObjVal=0,iteration=0,cpuTime=0,fobj_eval=0;
double dual_inf, constr_viol, complementarity, kkt_error;
- double *fGrad = NULL;
- double *fHess = NULL;
- double *fLambda = NULL;
- double *fZl=NULL;
- double *fZu=NULL;
+ const double *fX = NULL, *fGrad = NULL;
+ const double *fHess = NULL;
+ const double *fLambda = NULL;
+ const double *fZl=NULL;
+ const double *fZu=NULL;
int rstatus = 0;
int int_fobj_eval, int_constr_eval, int_fobj_grad_eval, int_constr_jac_eval, int_hess_eval;
@@ -136,7 +136,6 @@ int sci_solveminconp(char *fname)
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);
////////// Managing the parameters //////////
@@ -155,7 +154,7 @@ int sci_solveminconp(char *fname)
}
// Ask Ipopt to solve the problem
- status = app->OptimizeTNLP(Prob);
+ status = app->OptimizeTNLP((SmartPtr<TNLP>&)Prob);
//Get the solve statistics
cpuTime = app->Statistics()->TotalCPUTime();
@@ -173,7 +172,7 @@ int sci_solveminconp(char *fname)
fZl = Prob->getZl();
fZu = Prob->getZu();
ObjVal = Prob->getObjVal();
- iteration = Prob->iterCount();
+ iteration = (double)app->Statistics()->IterationCount();
if (returnDoubleMatrixToScilab(1, 1, nVars, fX))
{
diff --git a/sci_gateway/cpp/sci_ipoptfminunc.cpp b/sci_gateway/cpp/sci_ipoptfminunc.cpp
index 19c59ac..1d74815 100644
--- a/sci_gateway/cpp/sci_ipoptfminunc.cpp
+++ b/sci_gateway/cpp/sci_ipoptfminunc.cpp
@@ -50,10 +50,10 @@ int sci_solveminuncp(char *fname)
int x0_rows, x0_cols;
// Output arguments
- double *fX = NULL, ObjVal=0,iteration=0,cpuTime=0,fobj_eval=0;
+ double ObjVal=0,iteration=0,cpuTime=0,fobj_eval=0;
double dual_inf, constr_viol, complementarity, kkt_error;
- double *fGrad= NULL;
- double *fHess= NULL;
+ const double *fX = NULL, *fGrad= NULL;
+ const double *fHess= NULL;
int rstatus = 0;
int int_fobj_eval, int_constr_eval, int_fobj_grad_eval, int_constr_jac_eval, int_hess_eval;
@@ -110,7 +110,6 @@ int sci_solveminuncp(char *fname)
SmartPtr<minuncNLP> Prob = new minuncNLP(nVars, nCons, x0ptr, flag1, flag2);
SmartPtr<IpoptApplication> app = IpoptApplicationFactory();
- app->RethrowNonIpoptException(true);
////////// Managing the parameters //////////
@@ -128,7 +127,7 @@ int sci_solveminuncp(char *fname)
}
// Ask Ipopt to solve the problem
- status = app->OptimizeTNLP(Prob);
+ status = app->OptimizeTNLP((SmartPtr<TNLP>&)Prob);
cpuTime = app->Statistics()->TotalCPUTime();
@@ -144,7 +143,7 @@ int sci_solveminuncp(char *fname)
fGrad = Prob->getGrad();
fHess = Prob->getHess();
ObjVal = Prob->getObjVal();
- iteration = Prob->iterCount();
+ iteration = (double)app->Statistics()->IterationCount();
fobj_eval = (double)int_fobj_eval;
if (returnDoubleMatrixToScilab(1, 1, nVars, fX))
diff --git a/sci_gateway/cpp/sci_minbndNLP.cpp b/sci_gateway/cpp/sci_minbndNLP.cpp
index 9a7024e..481a796 100644
--- a/sci_gateway/cpp/sci_minbndNLP.cpp
+++ b/sci_gateway/cpp/sci_minbndNLP.cpp
@@ -11,7 +11,6 @@
#include "minbndNLP.hpp"
-#include "IpIpoptData.hpp"
#include "sci_iofunc.hpp"
extern "C"
@@ -23,7 +22,6 @@ extern "C"
#include <sciprint.h>
#include <string.h>
#include <assert.h>
-#include <iostream>
using namespace std;
using namespace Ipopt;
@@ -98,7 +96,7 @@ bool minbndNLP::eval_f(Index n, const Number* x, bool new_x, Number& obj_value)
}
char name[20]="f";
double obj=0;
- double *xNew=x;
+ const Number *xNew=x;
createMatrixOfDouble(pvApiCtx, 3, 1, numVars_, xNew);
int positionFirstElementOnStackForScilabFunction = 3;
int numberOfRhsOnScilabFunction = 1;
@@ -137,7 +135,7 @@ bool minbndNLP::eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f
{
return 1;
}
- double *xNew=x;
+ const Number *xNew=x;
Index i;
double t=1;
createMatrixOfDouble(pvApiCtx, 3, 1, numVars_, xNew);
@@ -230,7 +228,7 @@ bool minbndNLP::eval_h(Index n, const Number* x, bool new_x,Number obj_factor, I
return 1;
}
- double *xNew=x;
+ const Number *xNew=x;
Index i;
double t=2;
@@ -312,10 +310,7 @@ void minbndNLP::finalize_solution(SolverReturn status,Index n, const Number* x,
finalObjVal_ = obj_value;
status_ = status;
- if (status_ == 0 | status_ == 1 | status_ == 2)
- {
- iter_ = ip_data->iter_count();
- }
+
}
@@ -339,11 +334,6 @@ const double * minbndNLP::getZu()
return finalZu_;
}
-double minbndNLP::iterCount()
-{
- return (double)iter_;
-}
-
int minbndNLP::returnStatus()
{
return status_;
diff --git a/sci_gateway/cpp/sci_minconNLP.cpp b/sci_gateway/cpp/sci_minconNLP.cpp
index 845e983..71e6b53 100644
--- a/sci_gateway/cpp/sci_minconNLP.cpp
+++ b/sci_gateway/cpp/sci_minconNLP.cpp
@@ -11,7 +11,6 @@
#include "minconNLP.hpp"
-#include "IpIpoptData.hpp"
#include "sci_iofunc.hpp"
extern "C"
@@ -24,7 +23,6 @@ extern "C"
#include <sciprint.h>
#include <string.h>
#include <assert.h>
-#include <iostream>
using namespace std;
using namespace Ipopt;
@@ -138,7 +136,7 @@ bool minconNLP::eval_f(Index n, const Number* x, bool new_x, Number& obj_value)
}
char name[18]="f";
double obj=0;
- double *xNew=x;
+ const Number *xNew=x;
double check;
createMatrixOfDouble(pvApiCtx, 14, 1, numVars_, xNew);
int positionFirstElementOnStackForScilabFunction = 14;
@@ -182,7 +180,7 @@ bool minconNLP::eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f
{
return 1;
}
- double *xNew=x;
+ const Number *xNew=x;
createMatrixOfDouble(pvApiCtx, 14, 1, numVars_, xNew);
int positionFirstElementOnStackForScilabFunction = 14;
int numberOfRhsOnScilabFunction = 1;
@@ -247,7 +245,7 @@ bool minconNLP::eval_g(Index n, const Number* x, bool new_x, Index m, Number* g)
return 1;
}
- double *xNew=x;
+ const Number *xNew=x;
double check;
createMatrixOfDouble(pvApiCtx, 14, 1, numVars_, xNew);
int positionFirstElementOnStackForScilabFunction = 14;
@@ -352,7 +350,7 @@ bool minconNLP::eval_jac_g(Index n, const Number* x, bool new_x,Index m, Index n
return 1;
}
- double *xNew=x;
+ const Number *xNew=x;
createMatrixOfDouble(pvApiCtx, 14, 1, numVars_, xNew);
int positionFirstElementOnStackForScilabFunction = 14;
int numberOfRhsOnScilabFunction = 1;
@@ -448,8 +446,8 @@ bool minconNLP::eval_h(Index n, const Number* x, bool new_x,Number obj_factor, I
{
return 1;
}
- double *xNew=x;
- double *lambdaNew=lambda;
+ const Number *xNew=x;
+ const Number *lambdaNew=lambda;
double objfac=obj_factor;
createMatrixOfDouble(pvApiCtx, 14, 1, numVars_, xNew);
createScalarDouble(pvApiCtx, 15,objfac);
@@ -543,7 +541,6 @@ void minconNLP::finalize_solution(SolverReturn status,Index n, const Number* x,
finalObjVal_ = obj_value;
status_ = status;
- iter_ = ip_data->iter_count();
}
@@ -582,11 +579,6 @@ double minconNLP::getObjVal()
return finalObjVal_;
}
-double minconNLP::iterCount()
-{
- return (double)iter_;
-}
-
int minconNLP::returnStatus()
{
return status_;
diff --git a/sci_gateway/cpp/sci_minuncNLP.cpp b/sci_gateway/cpp/sci_minuncNLP.cpp
index 874c093..fe4c0e5 100644
--- a/sci_gateway/cpp/sci_minuncNLP.cpp
+++ b/sci_gateway/cpp/sci_minuncNLP.cpp
@@ -11,7 +11,6 @@
#include "minuncNLP.hpp"
-#include "IpIpoptData.hpp"
#include "sci_iofunc.hpp"
extern "C"
@@ -24,7 +23,6 @@ extern "C"
#include <sciprint.h>
#include <string.h>
#include <assert.h>
-#include <iostream>
using namespace std;
using namespace Ipopt;
@@ -100,7 +98,7 @@ bool minuncNLP::eval_f(Index n, const Number* x, bool new_x, Number& obj_value)
}
char name[20]="f";
double obj=0;
- double *xNew=x;
+ const Number *xNew=x;
createMatrixOfDouble(pvApiCtx, 7, 1, numVars_, xNew);
int positionFirstElementOnStackForScilabFunction = 7;
int numberOfRhsOnScilabFunction = 1;
@@ -142,7 +140,7 @@ bool minuncNLP::eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f
{
return 1;
}
- double *xNew=x;
+ const Number *xNew=x;
double t=1;
createMatrixOfDouble(pvApiCtx, 7, 1, numVars_, xNew);
createScalarDouble(pvApiCtx, 8,t);
@@ -164,7 +162,7 @@ bool minuncNLP::eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f
{
return 1;
}
- double *xNew=x;
+ const Number *xNew=x;
createMatrixOfDouble(pvApiCtx, 7, 1, numVars_, xNew);
int positionFirstElementOnStackForScilabFunction = 7;
int numberOfRhsOnScilabFunction = 1;
@@ -253,7 +251,7 @@ bool minuncNLP::eval_h(Index n, const Number* x, bool new_x,Number obj_factor, I
{
return 1;
}
- double *xNew=x;
+ const Number *xNew=x;
double t=2;
createMatrixOfDouble(pvApiCtx, 7, 1, numVars_, xNew);
createScalarDouble(pvApiCtx, 8,t);
@@ -275,7 +273,7 @@ bool minuncNLP::eval_h(Index n, const Number* x, bool new_x,Number obj_factor, I
{
return 1;
}
- double *xNew=x;
+ const Number *xNew=x;
createMatrixOfDouble(pvApiCtx, 7, 1, numVars_, xNew);
int positionFirstElementOnStackForScilabFunction = 7;
int numberOfRhsOnScilabFunction = 1;
@@ -337,7 +335,6 @@ void minuncNLP::finalize_solution(SolverReturn status,Index n, const Number* x,
finalObjVal_ = obj_value;
status_ = status;
- iter_ = ip_data->iter_count();
}
@@ -361,11 +358,6 @@ double minuncNLP::getObjVal()
return finalObjVal_;
}
-double minuncNLP::iterCount()
-{
- return (double)iter_;
-}
-
int minuncNLP::returnStatus()
{
return status_;
diff --git a/sci_gateway/cpp/sci_sym_get_dbl_arr.cpp b/sci_gateway/cpp/sci_sym_get_dbl_arr.cpp
new file mode 100644
index 0000000..5cafce9
--- /dev/null
+++ b/sci_gateway/cpp/sci_sym_get_dbl_arr.cpp
@@ -0,0 +1,122 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Author: Sai Kiran
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+
+#include <symphony.h>
+#include <sci_iofunc.hpp>
+extern sym_environment* global_sym_env;//defined in globals.cpp
+
+extern "C" {
+#include <api_scilab.h>
+#include <Scierror.h>
+#include <BOOL.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <localization.h>
+#include <sciprint.h>
+
+#include <string.h>
+
+/* This is generelized function for
+ * sym_getVarLower,sym_getVarUpper,sym_getRhs,sym_getConstrRange,sym_getConstrLower,
+ * sym_getConstrUpper and sym_getObjCoeff .
+ * (Functions taking symphony env and pointer to array of doubles as arguments)
+*/
+int sci_sym_get_dbl_arr(char *fname, unsigned long fname_len){
+
+ int result_len=0;/* Length of the output double array */
+ double *result=NULL;/* Pointer to output double array */
+
+ //check whether we have no input and one output argument or not
+ CheckInputArgument(pvApiCtx, 0, 0) ; //no input argument
+ CheckOutputArgument(pvApiCtx, 1, 1) ; //one output argument
+
+ /* Array of possible callers of this function */
+ char* arr_caller[]={"sym_getVarLower","sym_getVarUpper",
+ "sym_getRhs","sym_getConstrRange",
+ "sym_getConstrLower","sym_getConstrUpper",
+ "sym_getObjCoeff"};
+
+ /* Array of functions to be called */
+ int (*fun[])(sym_environment*,double*)= {sym_get_col_lower,sym_get_col_upper,
+ sym_get_rhs,sym_get_row_range,
+ sym_get_row_lower,sym_get_row_upper,
+ sym_get_obj_coeff };
+
+ /* Array of functions the above functions depend on */
+ int (*fun_depends[])(sym_environment*,int*) = {sym_get_num_cols,sym_get_num_cols,
+ sym_get_num_rows,sym_get_num_rows,
+ sym_get_num_rows,sym_get_num_rows,
+ sym_get_num_cols };
+
+ /* We want to ouput row-matrix if we are dealing with column data .
+ * column matrix if we are dealing with row data .
+ * 0 - output a row matrix.
+ * 1 - output a column matrix.
+ */
+ int representation = 0; //output a row matrix
+
+ /* Array of representations of output depending on the above functions.
+ * It's length is same as above arrays.
+ */
+ int matrix_representation[] = { 0 ,0 , 1, 1, 1, 1, 0};
+ if(global_sym_env==NULL) //There is no environment opened.
+ sciprint("Error: Symphony environment is not initialized.\n");
+ else {
+ //There is an environment opened
+ int iter=0,length=sizeof(arr_caller)/sizeof(char*),found_at= -1;
+ for (;iter < length ;++iter){
+ if (!strcmp(fname,arr_caller[iter]))
+ found_at=iter;
+ }
+ if (found_at != -1){
+ int status1=fun_depends[found_at](global_sym_env,&result_len);
+ if ( status1 == FUNCTION_TERMINATED_NORMALLY && result_len ) {
+ result=(double*)malloc( sizeof(double) * result_len );
+ int ret_val=fun[found_at](global_sym_env,result);
+ sciprint("\nFunction invoked unsuccessfully.\n");
+ if (ret_val == FUNCTION_TERMINATED_ABNORMALLY)
+ result_len=0;
+ else {
+ if (found_at == 6) {//if called function is sym_getObjCoeff
+ int iter=0,sense=0,status2 = sym_get_obj_sense(global_sym_env,&sense);
+ if (sense == -1) // Multiply with -1 while showing
+ for (;iter < result_len;++iter) result[iter] *= -1;
+ }
+ representation = matrix_representation[found_at];
+ }
+ }
+ else
+ sciprint("\n Is a problem loaded ? \n");
+ }
+ else //very rare case
+ sciprint("\nError in function mapping in scilab script\n");
+ }
+
+ //Copy the result to scilab. Location is position next to input arguments.
+ SciErr err;
+ if (representation) // output a column-matrix
+ err=createMatrixOfDouble(pvApiCtx,nbInputArgument(pvApiCtx)+1,result_len,1,result);
+ else // output a row-matrix
+ err=createMatrixOfDouble(pvApiCtx,nbInputArgument(pvApiCtx)+1,1,result_len,result);
+ free(result); //Free the allocated space
+ result=NULL; //Set to NULL
+ if (err.iErr){ //Process error
+ AssignOutputVariable(pvApiCtx, 1) = 0;
+ printError(&err, 0);
+ return 1;
+ }
+
+ //assign result position to output argument
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ //ReturnArguments(pvApiCtx);
+ return 0;
+ }
+}
diff --git a/sci_gateway/cpp/sci_sym_get_iteration_count.cpp b/sci_gateway/cpp/sci_sym_get_iteration_count.cpp
new file mode 100644
index 0000000..007943c
--- /dev/null
+++ b/sci_gateway/cpp/sci_sym_get_iteration_count.cpp
@@ -0,0 +1,51 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Author: Sai Kiran
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+
+#include <symphony.h>
+#include <sci_iofunc.hpp>
+extern sym_environment* global_sym_env;//defined in globals.cpp
+
+extern "C" {
+#include <api_scilab.h>
+#include <Scierror.h>
+#include <BOOL.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <localization.h>
+#include <sciprint.h>
+
+#include <string.h>
+
+/*
+ * This function is used to get iteration count after solving a problem
+*/
+int sci_sym_get_iteration_count(char *fname, unsigned long fname_len){
+
+ //check whether we have no input and one output argument or not
+ CheckInputArgument(pvApiCtx, 0, 0) ; //no input argument
+ CheckOutputArgument(pvApiCtx, 1, 1) ; //one output argument
+
+ int iteration_count=0; // return value to the caller
+ if(global_sym_env==NULL) //There is no environment opened.
+ sciprint("Error: Symphony environment is not initialized.\n");
+ else { //There is an environment opened
+ //Call symphony function
+ int status=sym_get_iteration_count(global_sym_env,&iteration_count);
+ if (status == FUNCTION_TERMINATED_ABNORMALLY) {
+ sciprint("\nHave you solved a problem ?\n");
+ iteration_count = 0;
+ }
+ }
+ // Write the result to scilab
+ return returnDoubleToScilab(iteration_count);
+ }
+
+}
diff --git a/sci_gateway/cpp/sci_sym_get_matrix.cpp b/sci_gateway/cpp/sci_sym_get_matrix.cpp
new file mode 100644
index 0000000..8b8f620
--- /dev/null
+++ b/sci_gateway/cpp/sci_sym_get_matrix.cpp
@@ -0,0 +1,165 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Author: Sai Kiran
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+
+#include <symphony.h>
+#include <sci_iofunc.hpp>
+extern sym_environment* global_sym_env;//defined in globals.cpp
+
+extern "C" {
+#include <api_scilab.h>
+#include <Scierror.h>
+#include <BOOL.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <localization.h>
+#include <sciprint.h>
+
+#include <string.h>
+
+/*
+ * Proto-type of function that converts column-major (sparse) representation
+ * to row-major (sparse) representation .
+*/
+void column_major_to_row_major(int,int,int,double *,int *,int *,double *,int *,int *);
+
+
+/* This function is to retrieve the problem's constraint matrix (sparse) .
+ * Symphony uses column-major (sparse) representation.
+ * Scilab uses row-major (sparse) representation.
+ * So, This function takes column-major (sparse) representation from symphony ,
+ * converts that to row-major (sparse) representation and writes to scilab's memory.
+ *
+ **/
+int sci_sym_get_matrix(char *fname, unsigned long fname_len){
+ int nz_ele=0;// No.of non-zero elements of the matrix
+ int rows=0; //No. of rows in constraint matrix
+ int columns=0; //No. of columns in constraint matrix
+
+ /* Variables that store column-major representation of matrix.
+ * These variables will be filled by symphony
+ */
+ int *column_start=NULL;// Starting index(in elements array) of each column
+ int *row_indices=NULL;// Row indices corresponding to each non-zero element
+ double *elements=NULL;// Non-zero elements of matrix
+
+ /* Variables that store row-major representation of matrix.
+ * Filled by a function column_major_to_row_major.
+ */
+ double *new_list=NULL; // Non-zero elements of row-major representation
+ int *count_per_row=NULL; //Count of non-zero elements in earch row
+ int *column_position=NULL; //Column of each non-zero element
+
+ //check whether we have no input and one output argument or not
+ CheckInputArgument(pvApiCtx, 0, 0) ; //no input argument
+ CheckOutputArgument(pvApiCtx, 1, 1) ; //one output argument
+
+ if(global_sym_env==NULL) //There is no environment opened.
+ sciprint("Error: Symphony environment is not initialized.\n");
+ else { //There is an environment opened
+ int status1=sym_get_num_elements(global_sym_env,&nz_ele); //No. of non-zero elements
+ int status2=sym_get_num_cols(global_sym_env , &columns); //Columns
+ int status3=sym_get_num_rows(global_sym_env , &rows); //Rows
+ int status4=FUNCTION_TERMINATED_ABNORMALLY;
+
+ //Make sure functions terminated normally
+ if (status1 == status2 && status1 == status3 && status1 == FUNCTION_TERMINATED_NORMALLY){
+ //Allocate memory for column-major representation
+ column_start=(int*)malloc(sizeof(int) * (columns+1));
+ row_indices=(int*)malloc(sizeof(int) * nz_ele);
+ elements=(double*)malloc(sizeof(double) * nz_ele);
+
+ //Take column-major representation from symphony
+ status4=sym_get_matrix(global_sym_env,&nz_ele,column_start,row_indices,elements);
+ if (status1 == status4) { //Check termination status of function, if normal
+
+ //Allocate memory for row-major representation
+ new_list=(double*) calloc( nz_ele , sizeof(double));
+ count_per_row=(int*) calloc( rows, sizeof(int ) );
+ column_position=(int*) calloc( nz_ele, sizeof(int));
+
+ //Convert column-major representation to row-major representation
+ column_major_to_row_major(rows,columns,nz_ele,elements,row_indices,column_start,new_list,count_per_row,column_position);
+
+ /*
+ (Important)Scilab considers indices from 1 , But we have column indices starting from 0 in column_position.
+ Hence add 1 to each index
+ */
+ int iter=0;
+ for (;iter < nz_ele ; ++iter) column_position[iter]++;
+
+ }
+ else { //If termination status is abnormal
+ sciprint("\nFunction invoked unsuccessfully.\n");
+ sciprint("\n Is a problem loaded ? \n");
+ }
+ }
+ else //If termination status of any of functions is abnormal
+ sciprint("\nFunction invoked unsuccessfully.\n");
+
+ }
+
+ //Copy the result to scilab. Location is position next to input arguments.
+ SciErr err=createSparseMatrix(pvApiCtx,nbInputArgument(pvApiCtx)+1,rows,columns,nz_ele,count_per_row,column_position,new_list);
+
+ /*
+ *Free allocated memory before exit
+ */
+ free(row_indices);
+ free(column_start);
+ free(elements);
+ free(new_list);
+ free(count_per_row);
+ free(column_position);
+
+ if (err.iErr){ //Process error
+ printError(&err, 0);
+ AssignOutputVariable(pvApiCtx, 1) = 0;
+ return 1;
+ }
+
+ //assign result position to output argument
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ //ReturnArguments(pvApiCtx);
+ return 0;
+ }
+}
+
+/*
+ * It converts column-major representation to row-major representation
+ * :: ARGUMENTS ::
+ * rows - No. of rows IN
+ * columns - No. of columns IN
+ * nz_ele - No. of non-zero elements IN
+ * elements - Non-zero elements in column-major representation IN
+ * row_indices - Row index( starts from 0 : symphony) of each non-zero element IN
+ * column_start - Starting index in elements of each column IN
+ * new_list - Non-zero elements in row-major representation OUT
+ * count_per_row - Count of non-zero elements in each row OUT
+ * column_position - Column index ( starts from 0 (we'll add 1 to each index later)) of each non-zero element OUT
+*/
+void column_major_to_row_major(int rows,int columns,int nz_ele,double *elements,int *row_indices,int *column_start,double *new_list,int *count_per_row,int *column_position) {
+
+ int iter=0,iter2,iter3=0,index=0;
+ for (iter=0;iter < rows;++iter) {
+ for (iter2=0;iter2 < nz_ele;++iter2) {
+ if (row_indices[iter2] == iter) {
+ count_per_row[iter]++; //Count of non-zero elements per row.
+ new_list[index]=elements[iter2];
+ for (iter3=0; iter3 < columns+1 ; ++iter3) {
+ if (iter2 < column_start[iter3])
+ break;
+ }
+ column_position[index] = iter3 - 1;
+ index++ ;
+ }
+ }
+ }
+ } \ No newline at end of file
diff --git a/sci_gateway/cpp/sci_sym_get_num_int.cpp b/sci_gateway/cpp/sci_sym_get_num_int.cpp
new file mode 100644
index 0000000..0d0bd39
--- /dev/null
+++ b/sci_gateway/cpp/sci_sym_get_num_int.cpp
@@ -0,0 +1,70 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Author: Sai Kiran
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+
+#include <symphony.h>
+#include <sci_iofunc.hpp>
+extern sym_environment* global_sym_env;//defined in globals.cpp
+
+extern "C" {
+#include <api_scilab.h>
+#include <Scierror.h>
+#include <BOOL.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <localization.h>
+#include <sciprint.h>
+
+#include <string.h>
+
+/*
+ * Generelized function for sym_getNumVars,
+ * sym_getNumConstrs,sym_get_NumElements
+*/
+int sci_sym_get_num_int(char *fname, unsigned long fname_len){
+
+ int result=-1;/* Result of the callar */
+
+ //check whether we have no input and one output argument or not
+ CheckInputArgument(pvApiCtx, 0, 0) ; //no input argument
+ CheckOutputArgument(pvApiCtx, 1, 1) ; //one output argument
+
+ /* Array of possible callers of this function */
+ char* arr_caller[]={"sym_getNumConstr","sym_getNumVar","sym_getNumElements"};
+
+ /* Array of functions to be called */
+ int (*fun[])(sym_environment*,int*)= { sym_get_num_rows,
+ sym_get_num_cols,
+ sym_get_num_elements
+ };
+
+ if(global_sym_env==NULL) //There is no environment opened.
+ sciprint("Error: Symphony environment is not initialized.\n");
+ else {
+ //There is an environment opened
+ int iter=0,length=sizeof(arr_caller)/sizeof(char*),found_at= -1;
+ for (;iter < length ;++iter){
+ if (!strcmp(fname,arr_caller[iter]))
+ found_at=iter;
+ }
+ if (found_at != -1) {
+ int ret_val=fun[found_at](global_sym_env,&result);
+ sciprint("\nFunction invoked unsuccessfully.\n");
+ if (ret_val == FUNCTION_TERMINATED_ABNORMALLY)
+ result=-1;
+ }
+ else //very rare case
+ sciprint("\nError in function mapping in scilab script\n");
+ }
+
+ //Copy the result to scilab. Location is position next to input arguments.
+ return returnDoubleToScilab(result);
+ }
+} \ No newline at end of file
diff --git a/sci_gateway/cpp/sci_sym_loadproblem.cpp b/sci_gateway/cpp/sci_sym_loadproblem.cpp
index 5294082..1a00092 100644
--- a/sci_gateway/cpp/sci_sym_loadproblem.cpp
+++ b/sci_gateway/cpp/sci_sym_loadproblem.cpp
@@ -198,6 +198,9 @@ static int commonCodePart2()
cleanupBeforeExit();
return 1;
}
+ #ifdef _MSC_VER
+ double INFINITY = sym_get_infinity();
+ #endif
if(conLower[rowIter]==(-INFINITY) && conUpper[rowIter]==INFINITY){
conType[rowIter]='N';
conRange[rowIter]=0;
diff --git a/sci_gateway/cpp/sci_sym_remove.cpp b/sci_gateway/cpp/sci_sym_remove.cpp
index 0289064..c09cbc7 100644
--- a/sci_gateway/cpp/sci_sym_remove.cpp
+++ b/sci_gateway/cpp/sci_sym_remove.cpp
@@ -17,6 +17,8 @@ extern "C" {
#include <api_scilab.h>
#include <Scierror.h>
#include <BOOL.h>
+#include <stdlib.h>
+#include <malloc.h>
#include <localization.h>
#include <sciprint.h>
//function to remove specified columns
@@ -30,7 +32,7 @@ int sci_sym_delete_cols(char *fname, unsigned long fname_len){
int num_cols;//stores the number of columns in the loaded problem
int iType= 0;//stores the datatype of matrix
int rows=0,columns=0;//integer variables to denote the number of rows and columns in the array denoting the column numbers to be deleted
- unsigned int *value=NULL;//pointer to integer array allocated dynamically having the indices to be deleted
+ int *value=NULL;//pointer to integer array allocated dynamically having the indices to be deleted
double *array_ptr=NULL;//double array pointer to the array denoting the column numbers to be deleted
int *piAddressVarOne = NULL;//pointer used to access first and second arguments of the function
int output=0;//output parameter for the symphony sym_delete_cols function
@@ -63,11 +65,11 @@ int sci_sym_delete_cols(char *fname, unsigned long fname_len){
}
//dynamically allocate the integer array
- value=(unsigned int *)malloc(sizeof(unsigned int)*columns);
+ value=(int *)malloc(sizeof(int)*columns);
//store double values in the integer array by typecasting
while(count<columns)
{
- value[count]=(unsigned int)array_ptr[count];
+ value[count]=(int)array_ptr[count];
count++;
}
sciprint("\n");
@@ -103,7 +105,7 @@ int sci_sym_delete_cols(char *fname, unsigned long fname_len){
}
//only when the number of columns to be deleted is lesser than the actual number of columns ,execution is proceeded with
if(columns<=num_cols){
- output=sym_delete_cols(global_sym_env,(unsigned int)columns,value);//symphony function to delete the columns specified
+ output=sym_delete_cols(global_sym_env,(int)columns,value);//symphony function to delete the columns specified
if(output==FUNCTION_TERMINATED_NORMALLY)
{
sciprint("Execution is successfull\n");
@@ -147,7 +149,7 @@ int sci_sym_delete_rows(char *fname, unsigned long fname_len){
int num_rows;//stores the number of columns in the loaded problem
int iType= 0;//stores the datatype of matrix
int rows=0,columns=0;//integer variables to denote the number of rows and columns in the array denoting the row numbers to be deleted
- unsigned int *value=NULL;//pointer to integer array allocated dynamically having the indices to be deleted
+ int *value=NULL;//pointer to integer array allocated dynamically having the indices to be deleted
double *array_ptr=NULL;//double array pointer to the array denoting the rows numbers to be deleted
int *piAddressVarTwo = NULL;//pointer used to access first and second arguments of the function
int output=0;//output parameter for the symphony sym_delete_rows function
@@ -179,11 +181,11 @@ int sci_sym_delete_rows(char *fname, unsigned long fname_len){
}
//dynamically allocate the integer array
- value=(unsigned int *)malloc(sizeof(unsigned int)*columns);
+ value=(int *)malloc(sizeof(int)*columns);
//store double values in the integer array by typecasting
while(count<columns)
{
- value[count]=(unsigned int)array_ptr[count];
+ value[count]=(int)array_ptr[count];
count++;
}
sciprint("\n");
@@ -219,7 +221,7 @@ int sci_sym_delete_rows(char *fname, unsigned long fname_len){
}
//only when the number of rows to be deleted is lesser than the actual number of rows ,execution is proceeded with
if(columns<=num_rows){
- output=sym_delete_rows(global_sym_env,(unsigned int)columns,value);//symphony function to delete the rows specified
+ output=sym_delete_rows(global_sym_env,(int)columns,value);//symphony function to delete the rows specified
if(output==FUNCTION_TERMINATED_NORMALLY)
{
sciprint("Execution is successfull\n");
@@ -252,8 +254,4 @@ int sci_sym_delete_rows(char *fname, unsigned long fname_len){
return 0;
}
-
-
-
-
}