Changeset 4789


Ignore:
Timestamp:
06/01/07 17:24:22 (7 years ago)
Author:
wehart
Message:

Revised the syntax for loading ampl to enable
the specification of the solver name.

Location:
colin/branches/colin-dev-3a
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • colin/branches/colin-dev-3a/TODO

    r4785 r4789  
    3030 
    3131- Setup XML application. 
     32 
     33- Should we have the LoadAMPL mechanism use a customized name for  
     34  the environmental variables that is uses? 
  • colin/branches/colin-dev-3a/colin/ColinMain.h

    r4721 r4789  
    55namespace colin { 
    66 
    7 int colin_main(int argc, char* argv[]); 
     7int colin_main(int argc, char* argv[], const char* codename="colin"); 
    88 
    99}; 
  • colin/branches/colin-dev-3a/src/ColinMain.cpp

    r4788 r4789  
    1212 
    1313void load_xml(const std::string&,colin::OptSolverHandle*&,utilib::Any&); 
    14 void load_ampl(const std::string&,colin::OptSolverHandle*&,utilib::Any&, char* argv[]); 
    15  
    16  
    17 int colin_main(int argc, char* argv[]) 
     14void load_ampl(const std::string&,colin::OptSolverHandle*&,utilib::Any&, char* argv[], const char* ); 
     15 
     16 
     17int colin_main(int argc, char* argv[], const char* codename) 
    1818{ 
    1919InitializeTiming(); 
     
    170170           break; 
    171171     case AMPL_MODE: 
    172            load_ampl(argv[1], handle, initpt, argv); 
     172           load_ampl(argv[1], handle, initpt, argv, codename); 
    173173           break; 
    174174     }; 
  • colin/branches/colin-dev-3a/src/LoadAMPL.cpp

    r4785 r4789  
    154154} 
    155155 
    156 void load_ampl(const std::string& fname, colin::OptSolverHandle*& handle, utilib::Any& initpt_, char* argv[]) 
     156void load_ampl(const std::string& fname, colin::OptSolverHandle*& handle, utilib::Any& initpt_, char* argv[], const char* codename) 
    157157{ 
    158158if (fname == "") 
    159159   EXCEPTION_MNGR(std::runtime_error, "Empty filename passed to load_ampl()") 
     160// 
     161// Copy NL file to a standard location 
     162// 
     163CharString tmp; 
     164tmp += "cp "; 
     165tmp += fname.c_str(); 
     166tmp += ".nl "; 
     167tmp += codename; 
     168tmp += ".nl"; 
     169system(tmp.data()); 
    160170 
    161171// 
    162172// Process solver options 
    163173// 
     174ASL*  asl = ASL_alloc(ASL_read_fg); 
    164175getstub(&argv,&Oinfo); 
    165176ParameterList plist; 
    166177BasicArray<ParameterList> plist_subsolvers; 
    167 CharString envstr = "coliny_options"; 
     178CharString envstr = codename; 
     179envstr += "_options"; 
    168180char* s = getenv(envstr.data()); 
    169181if (!s) { 
    170    envstr = "COLINY_OPTIONS"; 
     182   toUpper(envstr); 
    171183   s = getenv(envstr.data()); 
    172184   } 
     
    195207   } 
    196208else 
    197    EXCEPTION_MNGR(std::runtime_error, "Missing coliny_options environmental variable!") 
     209   EXCEPTION_MNGR(std::runtime_error, "Missing " << envstr << " environmental variable!") 
    198210   
    199211handle= OptSolverFactory(solverstr.data()); 
     
    206218// Read *.nl file 
    207219//   
    208 ASL*  asl = ASL_alloc(ASL_read_fg); 
    209220const char* stub = fname.c_str(); 
    210221FILE* nl = jac0dim(const_cast<char*>(stub), (fint) strlen(stub)); 
     
    270281   colin::OptProblem<MINLP1_problem> problem; 
    271282   problem.set_application( new_application<utilib::MixedIntVars,MINLP1_problem>("ampl_fn", &ampl::test_function,num_ineqc,num_eqc) ); 
     283   problem->config_real_domain(n_var); 
    272284   problem->set_real_bounds(vlower,vupper); 
    273285   problem->set_nonlinear_constraint_bounds(clower,cupper); 
     
    277289   colin::OptProblem<MOMINLP1_problem> problem; 
    278290   problem.set_application( new_application<utilib::MixedIntVars,MOMINLP1_problem>("ampl_fn", &ampl::test_function,num_ineqc,num_eqc,n_obj) ); 
     291   problem->config_real_domain(n_var); 
    279292   problem->set_real_bounds(vlower,vupper); 
    280293   problem->set_nonlinear_constraint_bounds(clower,cupper); 
  • colin/branches/colin-dev-3a/test/colintest.cpp

    r4727 r4789  
    44int main(int argc, char* argv[] ) 
    55{ 
    6 return colin::colin_main(argc,argv); 
     6return colin::colin_main(argc,argv,"colintest"); 
    77} 
Note: See TracChangeset for help on using the changeset viewer.