/[ascend]/trunk/base/generic/solver/slv8.c
ViewVC logotype

Diff of /trunk/base/generic/solver/slv8.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 918 by johnpye, Thu Oct 26 12:44:41 2006 UTC revision 919 by johnpye, Mon Nov 6 04:48:59 2006 UTC
# Line 88  int slv8_register(SlvFunctionsT *f){ Line 88  int slv8_register(SlvFunctionsT *f){
88  #define SLV8(s) ((slv8_system_t)(s))  #define SLV8(s) ((slv8_system_t)(s))
89  #define MI8F(s) slv_get_output_file( SLV8(s)->p.output.more_important )  #define MI8F(s) slv_get_output_file( SLV8(s)->p.output.more_important )
90  #define SERVER (sys->slv)  #define SERVER (sys->slv)
91  #define slv8_PA_SIZE 33  #define slv8_PA_SIZE 54
92  #define SAFE_CALC_PTR (sys->parm_array[0])  #define SAFE_CALC_PTR (sys->parm_array[0])
93  #define SAFE_CALC     ((*(int *)SAFE_CALC_PTR))  #define SAFE_CALC     ((*(int *)SAFE_CALC_PTR))
94  #define SCALEOPT_PTR (sys->parm_array[1])  #define SCALEOPT_PTR (sys->parm_array[1])
# Line 533  static boolean calc_residuals( slv8_syst Line 533  static boolean calc_residuals( slv8_syst
533    sys->s.block.funcs++;    sys->s.block.funcs++;
534    square_norm( &(sys->residuals) );    square_norm( &(sys->residuals) );
535    sys->s.block.residual = calc_sqrt_D0(sys->residuals.norm2);    sys->s.block.residual = calc_sqrt_D0(sys->residuals.norm2);
536      if(!calc_ok){
537        CONOPT_CONSOLE_DEBUG("ERROR IN EVALUATION");
538      }
539    return(calc_ok);    return(calc_ok);
540  }  }
541    
# Line 1202  int32 slv8_get_default_parameters(slv_sy Line 1205  int32 slv8_get_default_parameters(slv_sy
1205       * an instance of slv8_system_structure has this pointer       * an instance of slv8_system_structure has this pointer
1206       * already set in slv8_create       * already set in slv8_create
1207       */       */
1208      new_parms = (struct slv_parameter *)      new_parms = ASC_NEW_ARRAY(struct slv_parameter, slv8_PA_SIZE);
       ascmalloc((slv8_PA_SIZE)*sizeof(struct slv_parameter));  
1209      if (new_parms == NULL) {      if (new_parms == NULL) {
1210        return -1;        return -1;
1211      }      }
# Line 1224  int32 slv8_get_default_parameters(slv_sy Line 1226  int32 slv8_get_default_parameters(slv_sy
1226    SLV_RPARM_MACRO(RTMAXJ_PTR,parameters);    SLV_RPARM_MACRO(RTMAXJ_PTR,parameters);
1227    
1228    slv_define_parm(parameters, real_parm,    slv_define_parm(parameters, real_parm,
1229             "hessian_ub","RTMXJ2","upper bound on 2nd derivatives",             "hessian_ub","RTMXJ2","Upper bound on 2nd derivatives",
1230             U_p_real(val,1e4),U_p_real(lo,0),U_p_real(hi,MAX_REAL),2);             U_p_real(val,1e4),U_p_real(lo,0),U_p_real(hi,MAX_REAL),2);
1231    
1232    slv_define_parm(parameters, real_parm,    slv_define_parm(parameters, real_parm,
1233             "maxfeastol", "RTNWMA",             "maxfeastol", "RTNWMA",
1234             "max residual considered feasible (may be scaled)",             "Max. residual considered feasible (may be scaled)",
1235             U_p_real(val, 1e-3),U_p_real(lo, 1e-13),U_p_real(hi,10e10),2);             U_p_real(val, 1e-3),U_p_real(lo, 1e-13),U_p_real(hi,10e10),2);
1236    
1237    slv_define_parm(parameters, real_parm,    slv_define_parm(parameters, real_parm,
1238             "minfeastol", "RTNWMI",             "minfeastol", "RTNWMI",
1239             "residuals below this always considered feasible",             "Min. residual considered feasible",
1240             U_p_real(val, 4e-10),U_p_real(lo, 1e-20),U_p_real(hi,10e10),2);             U_p_real(val, 4e-10),U_p_real(lo, 1e-20),U_p_real(hi,10e10),2);
1241    
1242    slv_define_parm(parameters, real_parm,    slv_define_parm(parameters, real_parm,
1243             "oneDsearch","RTONED","accuracy of one dimensional search",             "oneDsearch","RTONED","Accuracy of one dimensional search",
1244             U_p_real(val,0.2),U_p_real(lo,0.1),U_p_real(hi,0.7),2);             U_p_real(val,0.2),U_p_real(lo,0.1),U_p_real(hi,0.7),2);
1245    
1246    slv_define_parm(parameters, real_parm,    slv_define_parm(parameters, real_parm,
1247             "stepmult","RVSTLM","steplength multiplier",             "stepmult","RVSTLM","Step-length multiplier",
1248             U_p_real(val,4),U_p_real(lo,0),U_p_real(hi,MAX_REAL),2);             U_p_real(val,4),U_p_real(lo,0),U_p_real(hi,MAX_REAL),2);
1249    
1250    slv_define_parm(parameters, real_parm,    slv_define_parm(parameters, real_parm,
1251             "objtol","RTOBJR","relative objective tolerance",             "objtol","RTOBJR","Relative objective tolerance",
1252             U_p_real(val,3e-13),U_p_real(lo,0),U_p_real(hi,1),2);             U_p_real(val,3e-13),U_p_real(lo,0),U_p_real(hi,1),2);
1253    
1254    slv_define_parm(parameters, real_parm,    slv_define_parm(parameters, real_parm,
1255             "pivottol","RTPIVA","absolute pivot tolerance",             "pivottol","RTPIVA","Absolute pivot tolerance",
1256             U_p_real(val,1e-7),U_p_real(lo,1e-15),U_p_real(hi,1),2);             U_p_real(val,1e-7),U_p_real(lo,1e-15),U_p_real(hi,1),2);
1257    
1258    slv_define_parm(parameters, real_parm,    slv_define_parm(parameters, real_parm,
1259             "pivtolrel","RTPIVR","relative pivot tolerance",             "pivtolrel","RTPIVR","Relative pivot tolerance",
1260             U_p_real(val,0.05),U_p_real(lo,0),U_p_real(hi,1),2);             U_p_real(val,0.05),U_p_real(lo,0),U_p_real(hi,1),2);
1261    
1262    slv_define_parm(parameters, real_parm,    slv_define_parm(parameters, real_parm,
1263             "opttol","RTREDG","optimality tolerance",             "opttol","RTREDG","Optimality tolerance",
1264             U_p_real(val,2e-5),U_p_real(lo,0),U_p_real(hi,MAX_REAL),2);             U_p_real(val,2e-5),U_p_real(lo,0),U_p_real(hi,MAX_REAL),2);
1265    
1266      /* integer valued parameters */
1267    
1268      slv_define_parm(parameters, int_parm,
1269               "log_freq","LFILOG","How often (in iterations) to write logging info",
1270               U_p_int(val,10),U_p_int(lo,1),U_p_int(hi,MAX_INT),1);
1271    
1272    slv_define_parm(parameters, int_parm,    slv_define_parm(parameters, int_parm,
1273             "log_freq","LFILOG","Log Frequency",             "log_freq","LFILOS","How often to write logging info during SLP and SQP",
1274             U_p_int(val,10),U_p_int(lo,1),U_p_int(hi,MAX_INT),1);             U_p_int(val,10),U_p_int(lo,1),U_p_int(hi,MAX_INT),1);
1275    
1276    slv_define_parm(parameters, int_parm,    slv_define_parm(parameters, int_parm,
1277             "iterationlimit", "LFITER", "maximum number of iterations",             "iterationlimit", "LFITER", "Maximum number of iterations",
1278             U_p_int(val, 1000),U_p_int(lo, 1),U_p_int(hi,MAX_INT),1);             U_p_int(val, 1000),U_p_int(lo, 1),U_p_int(hi,MAX_INT),1);
1279    SLV_IPARM_MACRO(ITER_LIMIT_PTR,parameters);    SLV_IPARM_MACRO(ITER_LIMIT_PTR,parameters);
1280    
1281    slv_define_parm(parameters, int_parm,    slv_define_parm(parameters, int_parm,
1282             "slowproglim","LFNICR","limit for slow progress",             "slowproglim","LFNICR","Limit for slow progress",
1283             U_p_int(val,5),U_p_int(lo,1),U_p_int(hi,MAX_INT),1);             U_p_int(val,12),U_p_int(lo,2),U_p_int(hi,MAX_INT),1);
1284    
1285    slv_define_parm(parameters, int_parm,    slv_define_parm(parameters, int_parm,
1286             "maxhessdim","LFNICR","maximum Hessian dimension",             "maxhessdim","LFNSUP","Maximum Hessian dimension",
1287             U_p_int(val,500),U_p_int(lo,1),U_p_int(hi,MAX_INT),1);             U_p_int(val,500),U_p_int(lo,5),U_p_int(hi,MAX_INT),1);
1288    
1289    slv_define_parm(parameters, int_parm,    slv_define_parm(parameters, int_parm,
1290             "supbasiclim","LFMXNS","limit on new superbasics",             "supbasiclim","LFMXNS","Limit on new super-basics",
1291             U_p_int(val,5),U_p_int(lo,0),U_p_int(hi,MAX_INT),1);             U_p_int(val,5),U_p_int(lo,0),U_p_int(hi,MAX_INT),1);
1292    
1293    slv_define_parm(parameters, int_parm,    slv_define_parm(parameters, int_parm,
1294               "lfscal","LFSCAL","Minimum frequency for updating row/col scales (see LSSCAL)",
1295               U_p_int(val,20),U_p_int(lo,1),U_p_int(hi,MAX_INT),1);
1296    
1297       slv_define_parm(parameters, int_parm,
1298               "lfstal","LFSTAL","Upper bound on the number of stalled iterations",
1299               U_p_int(val,100),U_p_int(lo,2),U_p_int(hi,MAX_INT),1);
1300    
1301      slv_define_parm(parameters, int_parm,
1302               "lkdebg","LKDEBG","How often (in iterations) to write debugging info for derivatives",
1303               U_p_int(val,0),U_p_int(lo,-1),U_p_int(hi,MAX_INT),1);
1304      
1305      slv_define_parm(parameters, int_parm,
1306               "lkdeb2","LKDEB2","How often (in iterations) to write debugging info for second derivs",
1307               U_p_int(val,0),U_p_int(lo,-1),U_p_int(hi,MAX_INT),1);
1308    
1309      slv_define_parm(parameters, int_parm,
1310               "lmdebg","LMDEBG","Func/derivative debugging: 0=default, 1=additional continuity tests",
1311               U_p_int(val,0),U_p_int(lo,0),U_p_int(hi,1),1);
1312    
1313      slv_define_parm(parameters, int_parm,
1314               "lmmxsf","LMMXSF","Method used to calc max step during Phase 0: 0=default, 1=new",
1315               U_p_int(val,0),U_p_int(lo,0),U_p_int(hi,1),1);
1316    
1317      slv_define_parm(parameters, int_parm,
1318               "lmmxst","LMMXST","'As for LMMXSF but for when tolerances are tightened'",
1319               U_p_int(val,0),U_p_int(lo,0),U_p_int(hi,1),1);
1320    
1321      slv_define_parm(parameters, int_parm,
1322             "errlim","max # func errs",             "errlim","max # func errs",
1323             "limit on function evaluation errors",             "Limit on number of function evaluation errors",
1324             U_p_int(val,500),U_p_int(lo,0),U_p_int(hi,MAX_INT),1);             U_p_int(val,500),U_p_int(lo,0),U_p_int(hi,MAX_INT),1);
1325    SLV_IPARM_MACRO(DOMLIM_PTR,parameters);    SLV_IPARM_MACRO(DOMLIM_PTR,parameters);
1326    
1327    slv_define_parm(parameters, char_parm,    slv_define_parm(parameters, char_parm,
1328             "scaleopt", "scaling option", "scaling option",             "scaleopt", "scaling option", "Scaling option",
1329             U_p_string(val,scaling_names[1]),             U_p_string(val,scaling_names[1]),
1330             U_p_strings(lo,scaling_names),             U_p_strings(lo,scaling_names),
1331             U_p_int(hi,sizeof(scaling_names)/sizeof(char *)),3);             U_p_int(hi,sizeof(scaling_names)/sizeof(char *)),3);
1332    SLV_CPARM_MACRO(SCALEOPT_PTR,parameters);    SLV_CPARM_MACRO(SCALEOPT_PTR,parameters);
1333    
1334    slv_define_parm(parameters, bool_parm,    slv_define_parm(parameters, bool_parm,
1335             "lifds", "show singletons details", "show singletons details",             "lifds", "show singletons details", "Show singletons details",
1336             U_p_bool(val, 0),U_p_bool(lo,0),U_p_bool(hi,1), 3);             U_p_bool(val, 0),U_p_bool(lo,0),U_p_bool(hi,1), 3);
1337    SLV_BPARM_MACRO(LIFDS_PTR,parameters);    SLV_BPARM_MACRO(LIFDS_PTR,parameters);
1338    
1339    slv_define_parm(parameters, bool_parm,    slv_define_parm(parameters, bool_parm,
1340             "safe_calc", "safe calculations", "safe calculations",             "safe_calc", "safe calculations", "Safe calculations",
1341             U_p_bool(val, 1),U_p_bool(lo,0),U_p_bool(hi,1), 3);             U_p_bool(val, 1),U_p_bool(lo,0),U_p_bool(hi,1), 3);
1342    SLV_BPARM_MACRO(SAFE_CALC_PTR,parameters);    SLV_BPARM_MACRO(SAFE_CALC_PTR,parameters);
1343    
1344    slv_define_parm(parameters, real_parm,    slv_define_parm(parameters, real_parm,
1345             "toosmall", "default for zero nominal",             "toosmall", "default for zero nominal",
1346                 "default for zero nominal",                 "Default for zero nominal",
1347             U_p_real(val, 1e-8),U_p_real(lo, 1e-12),U_p_real(hi,1.0), 3);             U_p_real(val, 1e-8),U_p_real(lo, 1e-12),U_p_real(hi,1.0), 3);
1348    SLV_RPARM_MACRO(TOO_SMALL_PTR,parameters);    SLV_RPARM_MACRO(TOO_SMALL_PTR,parameters);
1349    
# Line 1337  int32 slv8_get_default_parameters(slv_sy Line 1373  int32 slv8_get_default_parameters(slv_sy
1373    
1374    slv_define_parm(parameters, real_parm,    slv_define_parm(parameters, real_parm,
1375             "cnhigh", "largest allowable column norm",             "cnhigh", "largest allowable column norm",
1376                 "largest allowable column norm",                 "Largest allowable column norm",
1377             U_p_real(val, 100.0),U_p_real(lo,0),U_p_real(hi,10e10), 3);             U_p_real(val, 100.0),U_p_real(lo,0),U_p_real(hi,10e10), 3);
1378    SLV_RPARM_MACRO(CNHIGH_PTR,parameters);    SLV_RPARM_MACRO(CNHIGH_PTR,parameters);
1379    
# Line 1360  int32 slv8_get_default_parameters(slv_sy Line 1396  int32 slv8_get_default_parameters(slv_sy
1396    SLV_RPARM_MACRO(ITSCALETOL_PTR,parameters);    SLV_RPARM_MACRO(ITSCALETOL_PTR,parameters);
1397    
1398    slv_define_parm(parameters, char_parm,    slv_define_parm(parameters, char_parm,
1399             "reorder", "reorder method", "reorder method",             "reorder", "reorder method", "Re-order method",
1400             U_p_string(val,reorder_names[0]),             U_p_string(val,reorder_names[0]),
1401             U_p_strings(lo,reorder_names),             U_p_strings(lo,reorder_names),
1402             U_p_int(hi,sizeof(reorder_names)/sizeof(char *)),3);             U_p_int(hi,sizeof(reorder_names)/sizeof(char *)),3);
# Line 1373  int32 slv8_get_default_parameters(slv_sy Line 1409  int32 slv8_get_default_parameters(slv_sy
1409    SLV_IPARM_MACRO(CUTOFF_PTR,parameters);    SLV_IPARM_MACRO(CUTOFF_PTR,parameters);
1410    
1411    slv_define_parm(parameters, bool_parm,    slv_define_parm(parameters, bool_parm,
1412             "relnomscale", "calc rel nominals", "calc rel nominals",             "relnomscale", "calc rel nominals", "Whether to calculate relation nominals?",
1413             U_p_bool(val, 0),U_p_bool(lo,0),U_p_bool(hi,1), 3);             U_p_bool(val, 0),U_p_bool(lo,0),U_p_bool(hi,1), 3);
1414    SLV_BPARM_MACRO(RELNOMSCALE_PTR,parameters);    SLV_BPARM_MACRO(RELNOMSCALE_PTR,parameters);
1415    
1416    slv_define_parm(parameters, int_parm,    slv_define_parm(parameters, int_parm,
1417             "timelimit", "time limit (CPU sec/block)",             "timelimit", "time limit (CPU sec/block)",
1418                 "time limit (CPU sec/block)",                 "Time limit (CPU sec/block)",
1419             U_p_int(val,1500),U_p_int(lo, 1),U_p_int(hi,20000),1);             U_p_int(val,1500),U_p_int(lo, 1),U_p_int(hi,20000),1);
1420    SLV_IPARM_MACRO(TIME_LIMIT_PTR,parameters);    SLV_IPARM_MACRO(TIME_LIMIT_PTR,parameters);
1421    
1422    
1423    
1424      // CONOPT boolean options
1425    
1426      slv_define_parm(parameters, bool_parm,
1427          "ls2ptj", "LS2PTJ", "Allow computation of 2nd derivatives by peturbation",
1428          U_p_bool(val, 0),U_p_bool(lo,0),U_p_bool(hi,1), 4);
1429    
1430      slv_define_parm(parameters, bool_parm,
1431          "lsanrm", "LSANRM", "Use 'steepest edge' procedure",
1432          U_p_bool(val, 0),U_p_bool(lo,0),U_p_bool(hi,1), 4);
1433    
1434      slv_define_parm(parameters, bool_parm,
1435          "lscrsh", "LSCRSH", "Use Crash procedures to create initial basis",
1436          U_p_bool(val, 1),U_p_bool(lo,0),U_p_bool(hi,1), 4);
1437    
1438      slv_define_parm(parameters, bool_parm,
1439          "lseslp", "LSESLP", "Enable SLP mode",
1440          U_p_bool(val, 1),U_p_bool(lo,0),U_p_bool(hi,1), 4);
1441    
1442      slv_define_parm(parameters, bool_parm,
1443          "lsismp", "LSISMP", "Ignore small pivots",
1444          U_p_bool(val, 0),U_p_bool(lo,0),U_p_bool(hi,1), 4);
1445    
1446      slv_define_parm(parameters, bool_parm,
1447          "lslack", "LSLACK", "Use the set of all slacks as the initial basis",
1448          U_p_bool(val, 0),U_p_bool(lo,0),U_p_bool(hi,1), 4);
1449    
1450      slv_define_parm(parameters, bool_parm,
1451          "lspret", "LSPRET", "Identify and solve pre-triangular equations",
1452          U_p_bool(val, 1),U_p_bool(lo,0),U_p_bool(hi,1), 4);
1453    
1454      slv_define_parm(parameters, bool_parm,
1455          "lspost", "LSPOST", "Identify post-triangular equations (that can combine with the Objective)",
1456          U_p_bool(val, 1),U_p_bool(lo,0),U_p_bool(hi,1), 4);
1457    
1458      slv_define_parm(parameters, bool_parm,
1459          "lssqrs", "LSSQRS", "Modeller declares that this is a square system (c.f. COIDEF_Square)",
1460          U_p_bool(val, 0),U_p_bool(lo,0),U_p_bool(hi,1), 4);
1461    
1462      slv_define_parm(parameters, bool_parm,
1463          "lsscal", "LSSCAL", "Use dynamic scaling algorithm (NB, manual scaling is preferred)",
1464          U_p_bool(val, 0),U_p_bool(lo,0),U_p_bool(hi,1), 4);
1465    
1466      slv_define_parm(parameters, bool_parm,
1467          "lstcrs", "LSTCRS", "Try to crash triangular bases using Gould & Reid technique",
1468          U_p_bool(val, 0),U_p_bool(lo,0),U_p_bool(hi,1), 4);
1469    
1470      slv_define_parm(parameters, bool_parm,
1471          "lstria", "LSTRIA", "Modeller declares that the equations form a triangular or recursive system",
1472          U_p_bool(val, 0),U_p_bool(lo,0),U_p_bool(hi,1), 4);
1473    
1474      // Quick mode
1475    
1476      slv_define_parm(parameters, bool_parm,
1477          "lsnop2", "LSNOP2", "No \"Phase 2\"",
1478          U_p_bool(val, 0),U_p_bool(lo,0),U_p_bool(hi,1), 5);
1479    
1480      slv_define_parm(parameters, int_parm,
1481          "lfmxp4","LFMXP4","Maximum number of iterations in Phase 4",
1482               U_p_int(val,1000000000),U_p_int(lo,1),U_p_int(hi,MAX_INT),5);
1483    
1484      slv_define_parm(parameters, real_parm,
1485          "rvobjl", "RVOBJL","Limit on objective in Quick Mode",
1486               U_p_real(val, 0),U_p_real(lo,0),U_p_real(hi,10e10), 5);
1487        
1488    
1489    return 1;    return 1;
1490  }  }
1491    
# Line 1394  int32 slv8_get_default_parameters(slv_sy Line 1497  int32 slv8_get_default_parameters(slv_sy
1497  static SlvClientToken slv8_create(slv_system_t server, int32*statusindex){  static SlvClientToken slv8_create(slv_system_t server, int32*statusindex){
1498    slv8_system_t sys;    slv8_system_t sys;
1499    
1500    sys = (slv8_system_t)asccalloc(1, sizeof(struct slv8_system_structure) );    sys = ASC_NEW_CLEAR(struct slv8_system_structure);
1501    if (sys==NULL) {    if (sys==NULL) {
1502      *statusindex = 1;      *statusindex = 1;
1503      return sys;      return sys;
# Line 2071  static int COI_CALL slv8_conopt_fdeval( Line 2174  static int COI_CALL slv8_conopt_fdeval(
2174    real64 *derivatives;    real64 *derivatives;
2175    static var_filter_t vfilter;    static var_filter_t vfilter;
2176    slv8_system_t sys;    slv8_system_t sys;
2177      int status;
2178    
2179    /* stop gcc whining about unused parameter */    /* stop gcc whining about unused parameter */
2180    (void)jcnm;  (void)n;   (void)nj;    (void)jcnm;  (void)n;   (void)nj;
2181    
2182    /* CONSOLE_DEBUG("EVALUATION STARTING"); */    CONOPT_CONSOLE_DEBUG("EVALUATION STARTING (row=%d, n=%d, nj=%d)",*rowno,*n,*nj);
2183    
2184    sys = (slv8_system_t)usrmem;    sys = (slv8_system_t)usrmem;
2185    if (*newpt == 1) {    if (*newpt == 1) {
# Line 2094  static int COI_CALL slv8_conopt_fdeval( Line 2198  static int COI_CALL slv8_conopt_fdeval(
2198      (with future versions of CONOPT)      (with future versions of CONOPT)
2199    */    */
2200    if (*mode == 1 || *mode == 3) {    if (*mode == 1 || *mode == 3) {
2201      /* CONSOLE_DEBUG("FUNCTION VALUES"); */      CONOPT_CONSOLE_DEBUG("FUNCTION VALUES");
2202      offset =  sys->J.reg.row.low;      offset =  sys->J.reg.row.low;
2203      row = *rowno + offset;      row = *rowno + offset;
2204      /* CONSOLE_DEBUG("ROWNO = %d, OFFSET = %d: ROW = ROW = %d",*rowno, offset, row); */      CONOPT_CONSOLE_DEBUG("ROWNO = %d, OFFSET = %d: ROW = ROW = %d",*rowno, offset, row);
2205      if ((*rowno == sys->con.m - 1) && (sys->obj != NULL)){      if ((*rowno == sys->con.m - 1) && (sys->obj != NULL)){
2206        if(calc_objective(sys)){        if(calc_objective(sys)){
2207          *g = sys->objective;          *g = sys->objective;
# Line 2110  static int COI_CALL slv8_conopt_fdeval( Line 2214  static int COI_CALL slv8_conopt_fdeval(
2214        *g = relman_eval(rel,&calc_ok,SAFE_CALC)        *g = relman_eval(rel,&calc_ok,SAFE_CALC)
2215        * sys->weights.vec[row];        * sys->weights.vec[row];
2216        if (!calc_ok) {        if (!calc_ok) {
2217            CONOPT_CONSOLE_DEBUG("EVALUATION ERROR IN RELMAN_EVAL");
2218          (*errcnt)++;          (*errcnt)++;
2219        }        }
2220      }      }
2221    }    }
2222    if (*mode == 2 || *mode == 3) {    if (*mode == 2 || *mode == 3) {
2223      /* CONSOLE_DEBUG("JACOBIAN VALUES"); */      CONOPT_CONSOLE_DEBUG("JACOBIAN VALUES");
2224      len = sys->con.maxrow;      len = sys->con.maxrow;
2225      variables = ASC_NEW_ARRAY(int32,len);      variables = ASC_NEW_ARRAY(int32,len);
2226      derivatives = ASC_NEW_ARRAY(real64,len);      derivatives = ASC_NEW_ARRAY(real64,len);
# Line 2127  static int COI_CALL slv8_conopt_fdeval( Line 2232  static int COI_CALL slv8_conopt_fdeval(
2232      if ((*rowno == sys->con.m - 1) && (sys->obj != NULL)){      if ((*rowno == sys->con.m - 1) && (sys->obj != NULL)){
2233        rel = sys->obj;        rel = sys->obj;
2234        assert(rel!=NULL);        assert(rel!=NULL);
2235        calc_ok = relman_diff2(rel,&vfilter,derivatives,variables,        status = relman_diff2(rel,&vfilter,derivatives,variables,
2236             &(len),SAFE_CALC);             &(len),SAFE_CALC);
2237        for (c = 0; c < len; c++) {        for (c = 0; c < len; c++) {
2238          jac[variables[c]] = derivatives[c]          jac[variables[c]] = derivatives[c] *  sys->nominals.vec[variables[c]];
2239                *  sys->nominals.vec[variables[c]];          CONOPT_CONSOLE_DEBUG("Jacobian for row %d, var %d = %f",*rowno,variables[c],jac[variables[c]]);
2240        }        }
2241        if (!calc_ok) {        if(status){
2242            CONOPT_CONSOLE_DEBUG("ERROR IN JACOBIAN EVALUATION (OBJECTIVE) (%d)",status);
2243          (*errcnt)++;          (*errcnt)++;
2244        }        }
2245      }else{      }else{
2246          CONOPT_CONSOLE_DEBUG("NOT LAST ROW");
2247        rel = sys->rlist[mtx_row_to_org(sys->J.mtx,row)];        rel = sys->rlist[mtx_row_to_org(sys->J.mtx,row)];
2248        assert(rel!=NULL);        assert(rel!=NULL);
2249        calc_ok = relman_diff2(rel,&vfilter,derivatives,variables,        status = relman_diff2(rel,&vfilter,derivatives,variables,
2250             &(len),SAFE_CALC);             &(len),SAFE_CALC);
2251        for (c = 0; c < len; c++) {        for (c = 0; c < len; c++) {
2252          jac[variables[c]] = derivatives[c]          jac[variables[c]] = derivatives[c]
2253            * sys->weights.vec[row] *  sys->nominals.vec[variables[c]];            * sys->weights.vec[row] *  sys->nominals.vec[variables[c]];
2254            CONOPT_CONSOLE_DEBUG("Jacobian for row %d, var %d = %f",mtx_row_to_org(sys->J.mtx,row),variables[c],jac[variables[c]]);
2255        }        }
2256        if (!calc_ok) {        if(status){
2257            CONOPT_CONSOLE_DEBUG("ERROR IN JACOBIAN EVALUATION (%d)",status);      
2258          (*errcnt)++;          (*errcnt)++;
2259        }        }
2260      }      }
2261      for (c = 0; c < len; c++) {      for (c = 0; c < len; c++) {
2262        if(fabs(jac[variables[c]]) > RTMAXJ) {        if(fabs(jac[variables[c]]) > RTMAXJ) {
2263  #if CONDBG          CONOPT_CONSOLE_DEBUG("large jac element");
         CONSOLE_DEBUG("large jac element");  
 #endif /* CONDBG  */  
2264          if (jac[variables[c]] < 0) {          if (jac[variables[c]] < 0) {
2265            jac[variables[c]] = -RTMAXJ+1;            jac[variables[c]] = -RTMAXJ+1;
2266          } else {          } else {
# Line 2255  static int COI_CALL slv8_conopt_solution Line 2362  static int COI_CALL slv8_conopt_solution
2362        var_set_nonbasic(var,TRUE);        var_set_nonbasic(var,TRUE);
2363      }      }
2364    
2365      CONSOLE_DEBUG("%d: %s = %f (%s)",c,varname,value,varstat);      CONOPT_CONSOLE_DEBUG("%d: %s = %f (%s)",c,varname,value,varstat);
2366      ASC_FREE(varname);      ASC_FREE(varname);
2367    }    }
2368    
# Line 2352  static int COI_CALL slv8_conopt_option( Line 2459  static int COI_CALL slv8_conopt_option(
2459    name = memset(name,' ',8);    name = memset(name,' ',8);
2460    while (sys->con.opt_count < slv8_PA_SIZE) {    while (sys->con.opt_count < slv8_PA_SIZE) {
2461      if (strlen(sys->p.parms[sys->con.opt_count].interface_label) == 6){      if (strlen(sys->p.parms[sys->con.opt_count].interface_label) == 6){
2462        if (strncmp(sys->p.parms[sys->con.opt_count].interface_label,        if(0==strncmp(sys->p.parms[sys->con.opt_count].interface_label,"R",1)){
2463                    "R",1) == 0) {          /* real-valued (R*) parameter */
2464          name =          name = strncpy(name, sys->p.parms[sys->con.opt_count].interface_label,6);
           strncpy(name, sys->p.parms[sys->con.opt_count].interface_label,6);  
2465          *rval = sys->p.parms[sys->con.opt_count].info.r.value;          *rval = sys->p.parms[sys->con.opt_count].info.r.value;
2466            CONOPT_CONSOLE_DEBUG("Set real option '%s' to %f"
2467                ,sys->p.parms[sys->con.opt_count].interface_label,*rval
2468            );
2469          sys->con.opt_count++;          sys->con.opt_count++;
2470          return 0;          return 0;
2471        } else if (strncmp(sys->p.parms[sys->con.opt_count].interface_label,        }else if(0==strncmp(sys->p.parms[sys->con.opt_count].interface_label,"LS",2)){
2472                           "L",1) == 0) {          /* boolean-balued (LS*) parameter */
2473          name =          name = strncpy(name,sys->p.parms[sys->con.opt_count].interface_label,6);
2474                strncpy(name,sys->p.parms[sys->con.opt_count].interface_label,6);          *logical = sys->p.parms[sys->con.opt_count].info.b.value;
2475            CONOPT_CONSOLE_DEBUG("Set bool option '%s' to %s"
2476                ,sys->p.parms[sys->con.opt_count].interface_label,((*logical)?"TRUE":"FALSE")
2477            );
2478            sys->con.opt_count++;
2479            return 0;
2480          }else if(0==strncmp(sys->p.parms[sys->con.opt_count].interface_label,"L",1)){
2481            /* integer-valued (L*) parameter */
2482            name = strncpy(name,sys->p.parms[sys->con.opt_count].interface_label,6);
2483          *ival = sys->p.parms[sys->con.opt_count].info.i.value;          *ival = sys->p.parms[sys->con.opt_count].info.i.value;
2484            CONOPT_CONSOLE_DEBUG("Set int option '%s' to %d"
2485                ,sys->p.parms[sys->con.opt_count].interface_label,*ival
2486            );
2487          sys->con.opt_count++;          sys->con.opt_count++;
2488          return 0;          return 0;
2489        }        }
# Line 2643  void slv8_coiscr COISCR_ARGS { Line 2763  void slv8_coiscr COISCR_ARGS {
2763  */  */
2764  static void slv_conopt_iterate(slv8_system_t sys)  static void slv_conopt_iterate(slv8_system_t sys)
2765  {  {
2766      int retcode;
2767    /*    /*
2768      We pass the pointer to sys as 'usrmem'.      We pass the pointer to sys as 'usrmem'.
2769      Cast back to slv9_system_t to access the information required      Cast back to slv9_system_t to access the information required
# Line 2654  static void slv_conopt_iterate(slv8_syst Line 2775  static void slv_conopt_iterate(slv8_syst
2775    
2776    sys->con.kept = 1;    sys->con.kept = 1;
2777    
2778    COI_Solve(sys->con.cntvect);    retcode = COI_Solve(sys->con.cntvect);
2779    
2780      CONOPT_CONSOLE_DEBUG("CONOPT COI_Solve return code %d",retcode);
2781    
2782    /* conopt_start(&(sys->con.kept), usrmem, &(sys->con.lwork),    /* conopt_start(&(sys->con.kept), usrmem, &(sys->con.lwork),
2783       sys->con.work, &(sys->con.maxusd), &(sys->con.curusd)); */       sys->con.work, &(sys->con.maxusd), &(sys->con.curusd)); */
2784    
# Line 2705  static void slv8_presolve(slv_system_t s Line 2829  static void slv8_presolve(slv_system_t s
2829    slv8_system_t sys;    slv8_system_t sys;
2830    int *cntvect, temp;    int *cntvect, temp;
2831    
2832      CONOPT_CONSOLE_DEBUG("PRESOLVE");
2833    
2834    sys = SLV8(asys);    sys = SLV8(asys);
2835    iteration_begins(sys);    iteration_begins(sys);
2836    check_system(sys);    check_system(sys);
# Line 2725  static void slv8_presolve(slv_system_t s Line 2851  static void slv8_presolve(slv_system_t s
2851           && sys->obj == sys->old_obj           && sys->obj == sys->old_obj
2852      ){      ){
2853        matrix_creation_needed = 0;        matrix_creation_needed = 0;
2854  #if DEBUG        CONOPT_CONSOLE_DEBUG("YOU JUST AVOIDED MATRIX DESTRUCTION/CREATION");
       CONSOLE_DEBUG("YOU JUST AVOIDED MATRIX DESTRUCTION/CREATION");  
 #endif  
2855      }      }
2856    }    }
2857    
# Line 2756  static void slv8_presolve(slv_system_t s Line 2880  static void slv8_presolve(slv_system_t s
2880      sys->old_obj = sys->obj;      sys->old_obj = sys->obj;
2881    
2882      slv_sort_rels_and_vars(server,&(sys->con.m),&(sys->con.n));      slv_sort_rels_and_vars(server,&(sys->con.m),&(sys->con.n));
2883      CONSOLE_DEBUG("FOUND %d CONSTRAINTS AND %d VARS",sys->con.m,sys->con.n);      CONOPT_CONSOLE_DEBUG("FOUND %d CONSTRAINTS AND %d VARS",sys->con.m,sys->con.n);
2884      if (sys->obj != NULL) {      if (sys->obj != NULL) {
2885        CONSOLE_DEBUG("ADDING OBJECT AS A ROW");        CONOPT_CONSOLE_DEBUG("ADDING OBJECT AS A ROW");
2886        sys->con.m++; /* treat objective as a row */        sys->con.m++; /* treat objective as a row */
2887      }      }
2888    
2889      cntvect = ASC_NEW_ARRAY(int,COIDEF_Size());      cntvect = ASC_NEW_ARRAY(int,COIDEF_Size());
2890      COIDEF_Ini(cntvect);      COIDEF_Ini(cntvect);
2891      sys->con.cntvect = cntvect;      sys->con.cntvect = cntvect;
2892      CONSOLE_DEBUG("NUMBER OF CONSTRAINTS = %d",sys->con.m);      CONOPT_CONSOLE_DEBUG("NUMBER OF CONSTRAINTS = %d",sys->con.m);
2893      COIDEF_NumVar(cntvect, &(sys->con.n));      COIDEF_NumVar(cntvect, &(sys->con.n));
2894      COIDEF_NumCon(cntvect, &(sys->con.m));      COIDEF_NumCon(cntvect, &(sys->con.m));
2895      sys->con.nz = num_jacobian_nonzeros(sys, &(sys->con.maxrow));      sys->con.nz = num_jacobian_nonzeros(sys, &(sys->con.maxrow));
# Line 2780  static void slv8_presolve(slv_system_t s Line 2904  static void slv8_presolve(slv_system_t s
2904      if(sys->obj!=NULL){      if(sys->obj!=NULL){
2905          sys->con.optdir = relman_obj_direction(sys->obj);          sys->con.optdir = relman_obj_direction(sys->obj);
2906          sys->con.objcon = sys->con.m - 1; /* objective will be last row */          sys->con.objcon = sys->con.m - 1; /* objective will be last row */
2907          CONSOLE_DEBUG("SETTING OBJECTIVE CONSTRAINT TO BE %d",sys->con.objcon);          CONOPT_CONSOLE_DEBUG("SETTING OBJECTIVE CONSTRAINT TO BE %d",sys->con.objcon);
2908      }else{      }else{
2909          sys->con.optdir = 0;          sys->con.optdir = 0;
2910          sys->con.objcon = 0;          sys->con.objcon = 0;
# Line 2800  static void slv8_presolve(slv_system_t s Line 2924  static void slv8_presolve(slv_system_t s
2924      COIDEF_ErrMsg(cntvect, &slv8_conopt_errmsg);      COIDEF_ErrMsg(cntvect, &slv8_conopt_errmsg);
2925      COIDEF_Progress(cntvect, &asc_conopt_progress);      COIDEF_Progress(cntvect, &asc_conopt_progress);
2926    
2927        int debugfv = 1;
2928        COIDEF_DebugFV(cntvect, &debugfv);
2929    
2930  #if 0 /* these are the parameters we need to pass to CONOPT */  #if 0 /* these are the parameters we need to pass to CONOPT */
2931    ipsz[F2C(4)] = 0;             /* FIX THESE AT A LATER DATE!!!!  */    ipsz[F2C(4)] = 0;             /* FIX THESE AT A LATER DATE!!!!  */
# Line 3016  int32 slv8_register(SlvFunctionsT *sft){ Line 3142  int32 slv8_register(SlvFunctionsT *sft){
3142    }    }
3143  #endif  #endif
3144    
   /* do dlopening here, conopt_load, if DYNAMIC_CONOPT. not implemented. */  
   
3145    sft->name = "CONOPT";    sft->name = "CONOPT";
3146    sft->ccreate = slv8_create;    sft->ccreate = slv8_create;
3147    sft->cdestroy = slv8_destroy;    sft->cdestroy = slv8_destroy;

Legend:
Removed from v.918  
changed lines
  Added in v.919

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22