00001 /* $Id: template.cpp 3488 2010-04-29 20:16:06Z kmartin $ */ 00017 #include "OSCoinSolver.h" 00018 #include "OSResult.h" 00019 #include "OSiLReader.h" 00020 #include "OSiLWriter.h" 00021 #include "OSoLReader.h" 00022 #include "OSrLReader.h" 00023 #include "OSrLWriter.h" 00024 #include "OSInstance.h" 00025 #include "OSOption.h" 00026 #include "OSoLWriter.h" 00027 #include "OSFileUtil.h" 00028 #include "OSConfig.h" 00029 #include "OSDefaultSolver.h" 00030 #include "OSWSUtil.h" 00031 #include "OSSolverAgent.h" 00032 #include "OShL.h" 00033 #include "OSErrorClass.h" 00034 #include "OSmps2osil.h" 00035 #include "OSBase64.h" 00036 00037 00038 00039 00040 using std::ostringstream; 00041 00042 00043 #ifdef COIN_HAS_KNITRO 00044 #include "OSKnitroSolver.h" 00045 #endif 00046 00047 00048 00049 00050 00051 #ifdef COIN_HAS_LINDO 00052 #include "OSLindoSolver.h" 00053 #endif 00054 00055 /* 00056 #ifdef COIN_HAS_IPOPT 00057 #ifndef COIN_HAS_ASL 00058 #include "OSIpoptSolver.h" 00059 #undef COIN_HAS_ASL 00060 #else 00061 #include "OSIpoptSolver.h" 00062 #endif 00063 #endif 00064 */ 00065 00066 #ifdef COIN_HAS_ASL 00067 #include "OSnl2osil.h" 00068 #endif 00069 00070 #ifdef HAVE_CTIME 00071 # include <ctime> 00072 #else 00073 # ifdef HAVE_TIME_H 00074 # include <time.h> 00075 # else 00076 # error "don't have header file for time" 00077 # endif 00078 #endif 00079 00080 //#ifdef COIN_HAS_IPOPT 00081 //#include "OSIpoptSolver.h" 00082 //#endif 00083 00084 #ifdef COIN_HAS_IPOPT 00085 #ifndef COIN_HAS_ASL 00086 #include "OSIpoptSolver.h" 00087 #undef COIN_HAS_ASL 00088 #else 00089 #include "OSIpoptSolver.h" 00090 #endif 00091 #endif 00092 00093 00094 00095 #ifdef COIN_HAS_BONMIN 00096 #include "OSBonminSolver.h" 00097 #endif 00098 00099 #ifdef COIN_HAS_COUENNE 00100 #include "OSCouenneSolver.h" 00101 #endif 00102 00103 00104 #include "OSOptionsStruc.h" 00105 00106 00107 using std::cout; 00108 using std::endl; 00109 using std::ostringstream; 00110 using std::string; 00111 00112 00113 00114 00115 00116 int main(int argC, char* argV[]){ 00117 00118 // template -- add your code here -- // 00119 00120 // temporary experimentation by Kipp 00121 std::cout << "Hello World" << std::endl; 00122 std::cout << std::endl << std::endl; 00123 size_t i; 00124 size_t numberOfNonlinearExpressions; 00125 numberOfNonlinearExpressions = 100000; 00128 Nl **nlarray; 00129 nlarray = new Nl*[ numberOfNonlinearExpressions ]; 00130 OSnLNodeNumber *nlNodeNumberPoint; 00131 00132 std::vector<Nl*> nlVec; 00133 std::cout << "Start Loop " << std::endl; 00134 for(i = 0; i < numberOfNonlinearExpressions ; i++){ 00135 nlarray[ i] = new Nl(); 00136 nlarray[i]->idx = i; 00137 nlarray[ i]->osExpressionTree = new OSExpressionTree(); 00138 nlNodeNumberPoint = new OSnLNodeNumber(); 00139 nlNodeNumberPoint->value = 77.77; 00140 nlarray[ i]->osExpressionTree->m_treeRoot = nlNodeNumberPoint; 00141 nlVec.push_back( nlarray[ i]) ; 00142 } 00143 00144 std::cout << "End Loop" << std::endl; 00145 //garbage collection 00146 00147 for(i = 0; i < numberOfNonlinearExpressions; i++){ 00148 delete nlarray[i]; 00149 nlarray[i] = NULL; 00150 } 00151 delete[] nlarray; 00152 nlarray = NULL; 00153 00154 return 0; 00155 // OSnl2osil *nl2osil = NULL; 00156 // try { 00157 // 00158 // double cpuTime; 00159 // cpuTime = CoinCpuTime(); 00160 // std::cout << "start the process " << std::endl; 00161 // // nl2osil = new OSnl2osil( "../../../../OS/data/amplFiles/blpmpec1.nl"); 00162 // nl2osil = new OSnl2osil( "rbrockmod.nl"); 00163 // std::cout << "nl file read " << std::endl; 00164 // cpuTime = CoinCpuTime() - cpuTime; 00165 // std::cout << "Time to read nl file: " << cpuTime << std::endl; 00166 // nl2osil->createOSInstance() ; 00167 // std::cout << "Number Variable = " << nl2osil->osinstance->getVariableNumber() << std::endl; 00168 // std::cout << "Number Constraints = " << nl2osil->osinstance->getConstraintNumber() << std::endl; 00169 // std::cout << "an osinstance created " << std::endl; 00170 // cpuTime = CoinCpuTime() - cpuTime; 00171 // std::cout << "Time to create osinstance : " << cpuTime << std::endl; 00172 // 00173 // std::cout << std::endl; 00174 // std::cout << "THE OPERATORS" << std::endl; 00175 // for(int i = 0; i < nl2osil->op_type.size(); i++){ 00176 // std::cout << nl2osil->op_type[ i] << std::endl; 00177 // } 00178 // 00179 // std::cout << std::endl; 00180 // std::cout << "THE OPERANDS" << std::endl; 00181 // for(int i = 0; i < nl2osil->operand.size(); i++){ 00182 // std::cout << nl2osil->operand[ i] << std::endl; 00183 // } 00184 // 00185 // /***** 00186 // std::cout << "Initialize Nonlinear Structures" << std::endl; 00187 // nl2osil->osinstance->initForAlgDiff( ); 00188 // cpuTime = CoinCpuTime() - cpuTime; 00189 // std::cout << "Time to initialize Nonlinear Structures : " << cpuTime << std::endl; 00190 // std::cout << "Get Sparse Jacobian" << std::endl; 00191 // SparseJacobianMatrix *sparseJac; 00192 // sparseJac = nl2osil->osinstance->getJacobianSparsityPattern(); 00193 // cpuTime = CoinCpuTime() - cpuTime; 00194 // std::cout << "Time to get Sparse Jacobian pattern : " << cpuTime << std::endl; 00195 // SparseHessianMatrix *sparseHessian = nl2osil->osinstance->getLagrangianHessianSparsityPattern(); 00196 // cpuTime = CoinCpuTime() - cpuTime; 00197 // std::cout << "Time to get Sparse Hessain pattern : " << cpuTime << std::endl; 00198 // OSiLWriter *osilwriter = NULL; 00199 // osilwriter = new OSiLWriter(); 00200 // std::string osil; 00201 // osil = osilwriter->writeOSiL( nl2osil->osinstance) ; 00202 // std::cout << "osil generated" << std::endl; 00203 // cpuTime = CoinCpuTime() - cpuTime; 00204 // std::cout << "Time to create osil : " << cpuTime << std::endl; 00205 // std::cout << "Size of osil string : " << osil.size() << std::endl; 00206 // fileUtil->writeFileFromString("tmp.osil", osil); 00207 // delete osilwriter; 00208 // 00209 // */ 00210 // delete nl2osil; 00211 // std::cout << "nl2osil deleted " << std::endl; 00212 // cpuTime = CoinCpuTime() - cpuTime; 00213 // std::cout << "Time to delete nl2osil : " << cpuTime << std::endl; 00214 // return 0; 00215 // } 00216 // catch(const ErrorClass& eclass){ 00217 // std::cout << "THERE WAS AN ERROR" << std::endl; 00218 // delete nl2osil; 00219 // std::cout << "THERE WAS AN ERROR" << std::endl; 00220 // std::cout << eclass.errormsg << std::endl; 00221 // return 0; 00222 // } 00223 00224 /*** 00225 00226 minimize GMM : sum{h1 in H, h2 in H} Zw[h1]*invA[h1, h2]*Zw[h2]; 00227 00228 subject to 00229 00230 conZw {h in H}: Zw[h] = sum {mj in MJ} Z[mj,h]*w[mj] ; 00231 00232 Shares {mj in MJ}: log(EstShare[mj]) = log(ActuShare[mj]) ; 00233 */ 00234 00235 00236 // time_t rawtime; 00237 // struct tm * timeinfo; 00238 // int year, month ,day; 00239 // char * weekday[] = { "Sunday", "Monday", 00240 // "Tuesday", "Wednesday", 00241 // "Thursday", "Friday", "Saturday"}; 00242 // int days_per_month[] = {31, 28, 31, 30, 00243 // 31, 30, 31, 31, 30, 31, 30, 31}; 00244 // 00245 // 00246 // 00247 // /* prompt user for date */ 00248 // printf ("Enter year: "); scanf ("%d",&year); 00249 // printf ("Enter month: "); scanf ("%d",&month); 00250 // 00251 // // adjust for leap year 00252 // if ( ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) { 00253 // days_per_month[ 1] = 29; 00254 // } 00255 // std::cout << "GAIL = " << year % 4 << std::endl; 00256 // /* get current timeinfo and modify it to the user's choice */ 00257 // time ( &rawtime ); 00258 // timeinfo = localtime ( &rawtime ); 00259 // timeinfo->tm_year = year - 1900; 00260 // timeinfo->tm_mon = month - 1; 00261 // timeinfo->tm_mday = 1; 00262 // 00263 // /* call mktime: timeinfo->tm_wday will be set */ 00264 // mktime ( timeinfo ); 00265 // 00266 // printf ("That day is a %s.\n", weekday[timeinfo->tm_wday]); 00267 // std::cout << "Days in this month = " << days_per_month[ month-1] << std::endl; 00268 00269 }// end main 00270