Mercurial > octave-nkf
comparison src/DLD-FUNCTIONS/__glpk__.cc @ 5241:ab89f95de831
[project @ 2005-03-24 02:45:30 by jwe]
author | jwe |
---|---|
date | Thu, 24 Mar 2005 02:45:30 +0000 |
parents | 2bb31f40c339 |
children | 3589aff4a35d |
comparison
equal
deleted
inserted
replaced
5240:2bb31f40c339 | 5241:ab89f95de831 |
---|---|
109 LPX_K_OUTDLY, | 109 LPX_K_OUTDLY, |
110 LPX_K_TOLINT, | 110 LPX_K_TOLINT, |
111 LPX_K_TOLOBJ | 111 LPX_K_TOLOBJ |
112 }; | 112 }; |
113 | 113 |
114 jmp_buf mark; //-- Address for long jump to jump to | 114 static jmp_buf mark; //-- Address for long jump to jump to |
115 int fperr; //-- Global error number | |
116 | |
117 | 115 |
118 int | 116 int |
119 glpk_fault_hook (void * /* info */, char *msg) | 117 glpk_fault_hook (void * /* info */, char *msg) |
120 { | 118 { |
121 error ("CRITICAL ERROR in GLPK: %s", msg); | 119 error ("CRITICAL ERROR in GLPK: %s", msg); |
123 } | 121 } |
124 | 122 |
125 int | 123 int |
126 glpk_print_hook (void * /* info */, char *msg) | 124 glpk_print_hook (void * /* info */, char *msg) |
127 { | 125 { |
128 message (0, "%s\n", msg); | 126 message (0, "%s", msg); |
129 return 1; | 127 return 1; |
130 } | 128 } |
131 | |
132 | 129 |
133 int | 130 int |
134 glpk (int sense, int n, int m, double *c, int nz, int *rn, int *cn, | 131 glpk (int sense, int n, int m, double *c, int nz, int *rn, int *cn, |
135 double *a, double *b, char *ctype, int *freeLB, double *lb, | 132 double *a, double *b, char *ctype, int *freeLB, double *lb, |
136 int *freeUB, double *ub, int *vartype, int isMIP, int lpsolver, | 133 int *freeUB, double *ub, int *vartype, int isMIP, int lpsolver, |
289 */ | 286 */ |
290 if (errnum == LPX_E_OK) | 287 if (errnum == LPX_E_OK) |
291 { | 288 { |
292 if (isMIP) | 289 if (isMIP) |
293 { | 290 { |
294 *status = static_cast<double> (lpx_mip_status (lp)); | 291 *status = lpx_mip_status (lp); |
295 *fmin = lpx_mip_obj_val (lp); | 292 *fmin = lpx_mip_obj_val (lp); |
296 } | 293 } |
297 else | 294 else |
298 { | 295 { |
299 if (lpsolver == 1) | 296 if (lpsolver == 1) |
300 { | 297 { |
301 *status = static_cast<double> (lpx_get_status (lp)); | 298 *status = lpx_get_status (lp); |
302 *fmin = lpx_get_obj_val (lp); | 299 *fmin = lpx_get_obj_val (lp); |
303 } | 300 } |
304 else | 301 else |
305 { | 302 { |
306 *status = static_cast<double> (lpx_ipt_status (lp)); | 303 *status = lpx_ipt_status (lp); |
307 *fmin = lpx_ipt_obj_val (lp); | 304 *fmin = lpx_ipt_obj_val (lp); |
308 } | 305 } |
309 } | 306 } |
310 | 307 |
311 if (isMIP) | 308 if (isMIP) |
341 else | 338 else |
342 redcosts[i] = lpx_ipt_col_dual (lp, i+1); | 339 redcosts[i] = lpx_ipt_col_dual (lp, i+1); |
343 } | 340 } |
344 } | 341 } |
345 | 342 |
346 *time = static_cast<double> (clock () - t_start) / CLOCKS_PER_SEC; | 343 *time = (clock () - t_start) / CLOCKS_PER_SEC; |
347 *mem = static_cast<double> (lib_env_ptr () -> mem_tpeak); | 344 *mem = (lib_env_ptr () -> mem_tpeak); |
348 | 345 |
349 lpx_delete_prob (lp); | 346 lpx_delete_prob (lp); |
350 return 0; | 347 return 0; |
351 } | 348 } |
352 | 349 |
353 lpx_delete_prob (lp); | 350 lpx_delete_prob (lp); |
354 | 351 |
355 *status= static_cast<double> (errnum); | 352 *status = errnum; |
356 | 353 |
357 return errnum; | 354 return errnum; |
358 } | 355 } |
359 | 356 |
360 #endif | 357 #endif |