void open_input(MPL *mpl, char *file) { mpl->line = 0; mpl->c = '\n'; mpl->token = 0; mpl->imlen = 0; mpl->image[0] = '\0'; mpl->value = 0.0; mpl->b_token = T_EOF; mpl->b_imlen = 0; mpl->b_image[0] = '\0'; mpl->b_value = 0.0; mpl->f_dots = 0; mpl->f_scan = 0; mpl->f_token = 0; mpl->f_imlen = 0; mpl->f_image[0] = '\0'; mpl->f_value = 0.0; memset(mpl->context, ' ', CONTEXT_SIZE); mpl->c_ptr = 0; insist(mpl->in_fp == NULL); mpl->in_fp = ufopen(file, "r"); if (mpl->in_fp == NULL) error(mpl, "unable to open %s - %s", file, strerror(errno)); mpl->in_file = file; /* scan the very first character */ get_char(mpl); /* scan the very first token */ get_token(mpl); return; }
BYTE palette_load_from_file(const uTCHAR *file) { FILE *fp; memset((BYTE *) palette_base_file, 0x00, 64 * 3); if ((fp = ufopen(file, uL("rb"))) == NULL) { ufprintf(stderr, uL("ERROR: open file " uPERCENTs "\n"), file); return (EXIT_ERROR); } fseek(fp, 0, SEEK_END); if (ftell(fp) < (64 * 3)) { ufprintf(stderr, uL("ERROR: read file " uPERCENTs "\n"), file); fclose(fp); return (EXIT_ERROR); } rewind(fp); if (!(fread((BYTE *) palette_base_file, 64 * 3, 1, fp))) { ; } fclose(fp); return (EXIT_OK); }
void *BLI_gzopen(const char *filename, const char *mode) { gzFile gzfile; if (!filename || !mode) { return 0; } else { /* xxx Creates file before transcribing the path */ if (mode[0] == 'w') fclose(ufopen(filename, "a")); /* temporary #if until we update all libraries to 1.2.7 * for correct wide char path handling */ #if ZLIB_VERNUM >= 0x1270 && !defined(FREE_WINDOWS) UTF16_ENCODE(filename); gzfile = gzopen_w(filename_16, mode); UTF16_UN_ENCODE(filename); #else { char short_name[256]; BLI_get_short_name(short_name, filename); gzfile = gzopen(short_name, mode); } #endif } return gzfile; }
void palette_save_on_file(const uTCHAR *file) { FILE *fp; if ((fp = ufopen(file, uL("wb"))) == NULL) { ufprintf(stderr, uL("ERROR: Impossible save palette file " uPERCENTs "\n"), file); return; } if (!(fwrite((BYTE *) palette_RGB, 64 * 3, 1, fp))) { ; } fclose(fp); }
void open_output(MPL *mpl, char *file, char *mode) { insist(mpl->out_fp == NULL); if (file == NULL) mpl->out_fp = stdout; else { mpl->out_fp = ufopen(file, mode); if (mpl->out_fp == NULL) error(mpl, "unable to create %s - %s", file, strerror(errno)); } mpl->out_file = file; mpl->out_buf = umalloc(OUTBUF_SIZE); mpl->out_cnt = 0; return; }
void open_output(MPL *mpl, char *file) { insist(mpl->out_fp == NULL); if (file == NULL) { file = "<stdout>"; mpl->out_fp = stdout; } else { mpl->out_fp = ufopen(file, "w"); if (mpl->out_fp == NULL) error(mpl, "unable to create %s - %s", file, strerror(errno)); } mpl->out_file = umalloc(strlen(file)+1); strcpy(mpl->out_file, file); mpl->out_buf = umalloc(OUTBUF_SIZE); mpl->out_cnt = 0; return; }
void save_slot_preview(BYTE slot) { uTCHAR *file; FILE *fp; if (!save_slot.preview_start) { memcpy(tl.snaps[TL_SNAP_FREE] + tl.preview, screen.data, screen_size()); save_slot.preview_start = TRUE; } if (!save_slot.state[slot]) { memcpy(screen.data, tl.snaps[TL_SNAP_FREE] + tl.preview, screen_size()); gfx_draw_screen(TRUE); return; } if ((file = name_slot_file(slot)) == NULL) { memcpy(screen.data, tl.snaps[TL_SNAP_FREE] + tl.preview, screen_size()); gfx_draw_screen(TRUE); return; } if ((fp = ufopen(file, uL("rb"))) == NULL) { memcpy(screen.data, tl.snaps[TL_SNAP_FREE] + tl.preview, screen_size()); gfx_draw_screen(TRUE); fprintf(stderr, "error on load preview\n"); return; } fseek(fp, save_slot.preview[slot], SEEK_SET); { DBWORD bytes; bytes = fread(screen.data, screen_size(), 1, fp); if (bytes != 1) { memcpy(screen.data, tl.snaps[TL_SNAP_FREE] + tl.preview, screen_size()); } } fclose(fp); gfx_draw_screen(TRUE); }
BYTE save_slot_save(BYTE slot) { uTCHAR *file; FILE *fp; /* game genie */ if (info.mapper.id == GAMEGENIE_MAPPER) { text_add_line_info(1, "[yellow]save is impossible in Game Genie menu"); return (EXIT_ERROR); } if (slot < SAVE_SLOT_FILE) { if ((file = name_slot_file(slot)) == NULL) { return (EXIT_ERROR); } } else { file = cfg->save_file; } if ((fp = ufopen(file, uL("wb"))) == NULL) { fprintf(stderr, "error on write save state\n"); return (EXIT_ERROR); } slot_operation(SAVE_SLOT_SAVE, slot, fp); fflush(fp); /* aggiorno la posizione della preview e il totalsize */ slot_operation(SAVE_SLOT_COUNT, slot, fp); save_slot.state[slot] = TRUE; fclose(fp); if (slot < SAVE_SLOT_FILE) { text_save_slot(SAVE_SLOT_SAVE); } return (EXIT_OK); }
void save_slot_count_load(void) { uTCHAR *file; BYTE i; for (i = 0; i < SAVE_SLOTS; i++) { save_slot.preview[i] = save_slot.tot_size[i] = 0; save_slot.state[i] = FALSE; file = name_slot_file(i); if (emu_file_exist(file) == EXIT_OK) { FILE *fp; save_slot.state[i] = TRUE; if ((fp = ufopen(file, uL("rb"))) == NULL) { continue; } slot_operation(SAVE_SLOT_COUNT, i, fp); fclose(fp); } } save_slot.preview_start = FALSE; if (!save_slot.state[save_slot.slot]) { BYTE i; save_slot.slot = 0; for (i = 0; i < SAVE_SLOTS; i++) { if (save_slot.state[i]) { save_slot.slot = i; } } } gui_save_slot(save_slot.slot); }
BYTE save_slot_load(BYTE slot) { uTCHAR *file; FILE *fp; if (tas.type) { text_add_line_info(1, "[yellow]movie playback interrupted[normal]"); tas_quit(); } /* game genie */ if (info.mapper.id == GAMEGENIE_MAPPER) { gamegenie_reset(); gamegenie.phase = GG_LOAD_ROM; emu_reset(CHANGE_ROM); gamegenie.phase = GG_FINISH; } if (slot < SAVE_SLOT_FILE) { if ((file = name_slot_file(slot)) == NULL) { return (EXIT_ERROR); } } else { file = cfg->save_file; } if ((fp = ufopen(file, uL("rb"))) == NULL) { text_add_line_info(1, "[red]error[normal] loading state"); fprintf(stderr, "error loading state\n"); return (EXIT_ERROR); } /* * mi salvo lo stato attuale da ripristinare in caso * di un file di salvataggio corrotto. */ timeline_snap(TL_SAVE_SLOT); if (slot == SAVE_SLOT_FILE) { slot_operation(SAVE_SLOT_COUNT, slot, fp); if (memcmp(info.sha1sum.prg.value, save_slot.sha1sum.prg.value, sizeof(info.sha1sum.prg.value)) != 0) { text_add_line_info(1, "[red]state file is not for this rom[normal]"); fprintf(stderr, "state file is not for this rom.\n"); timeline_back(TL_SAVE_SLOT, 0); fclose(fp); return (EXIT_ERROR); } } if (slot_operation(SAVE_SLOT_READ, slot, fp)) { fprintf(stderr, "error loading state, corrupted file.\n"); timeline_back(TL_SAVE_SLOT, 0); fclose(fp); return (EXIT_ERROR); } fclose(fp); if (slot < SAVE_SLOT_FILE) { text_save_slot(SAVE_SLOT_READ); } /* riavvio il timeline */ timeline_init(); return (EXIT_OK); }
FILE *BLI_fopen(const char *filename, const char *mode) { return ufopen(filename, mode); }
int getrec(char **pbuf, int *pbufsize, int isrecord) /* get next input record */ { /* note: cares whether buf == record */ int c; char *buf = *pbuf; uschar saveb0; int bufsize = *pbufsize, savebufsize = bufsize; if (firsttime) { firsttime = 0; initgetrec(); } dprintf( ("RS=<%s>, FS=<%s>, ARGC=%g, FILENAME=%s\n", *RS, *FS, *ARGC, *FILENAME) ); if (isrecord) { donefld = 0; donerec = 1; } saveb0 = buf[0]; buf[0] = 0; while (argno < *ARGC || infile == stdin) { dprintf( ("argno=%d, file=|%s|\n", argno, file) ); if (infile == NULL) { /* have to open a new file */ file = getargv(argno); if (file == NULL || *file == '\0') { /* deleted or zapped */ argno++; continue; } if (isclvar(file)) { /* a var=value arg */ setclvar(file); argno++; continue; } *FILENAME = file; dprintf( ("opening file %s\n", file) ); if (*file == '-' && *(file+1) == '\0') infile = stdin; else if ((infile = ufopen(file, "r")) == NULL) FATAL("can't open file %s", file); setfval(fnrloc, 0.0); } c = readrec(&buf, &bufsize, infile); if (c != 0 || buf[0] != '\0') { /* normal record */ if (isrecord) { if (freeable(fldtab[0])) xfree(fldtab[0]->sval); fldtab[0]->sval = buf; /* buf == record */ fldtab[0]->tval = REC | STR | DONTFREE; if (is_number(fldtab[0]->sval)) { fldtab[0]->fval = atof(fldtab[0]->sval); fldtab[0]->tval |= NUM; } } setfval(nrloc, nrloc->fval+1); setfval(fnrloc, fnrloc->fval+1); *pbuf = buf; *pbufsize = bufsize; return 1; } /* EOF arrived on this file; set up next */ if (infile != stdin) fclose(infile); infile = NULL; argno++; } buf[0] = saveb0; *pbuf = buf; *pbufsize = savebufsize; return 0; /* true end of file */ }
int lpx_print_sens_bnds(LPX *lp, char *fname) { FILE *fp = NULL; int what, round; print("lpx_print_sens_bnds: writing LP problem solution bounds to" " `%s'...", fname); #if 1 /* added by mao */ /* this routine needs factorization of the current basis matrix which, however, does not exist if the basic solution was obtained by the lp presolver; therefore we should warm up the basis to be sure that the factorization is valid (note that if the factorization exists, lpx_warm_up does nothing) */ lpx_warm_up(lp); #endif #if 0 /* 21/XII-2003 by mao */ if (lp->b_stat == LPX_B_UNDEF) #else if (!lpx_is_b_avail(lp)) #endif { print("lpx_print_sens_bnds: basis information not available (m" "ay be a presolve issue)"); goto fail; } fp = ufopen(fname, "w"); if (fp == NULL) { print("lpx_print_sens_bnds: can't create `%s' - %s", fname, strerror(errno)); goto fail; } /* problem name */ { char *name; name = lpx_get_prob_name(lp); if (name == NULL) name = ""; fprintf(fp, "%-12s%s\n", "Problem:", name); } /* number of rows (auxiliary variables) */ { int nr; nr = lpx_get_num_rows(lp); fprintf(fp, "%-12s%d\n", "Rows:", nr); } /* number of columns (structural variables) */ { int nc; nc = lpx_get_num_cols(lp); fprintf(fp, "%-12s%d\n", "Columns:", nc); } /* number of non-zeros (constraint coefficients) */ { int nz; nz = lpx_get_num_nz(lp); fprintf(fp, "%-12s%d\n", "Non-zeros:", nz); } /* solution status */ { int status; status = lpx_get_status(lp); fprintf(fp, "%-12s%s\n", "Status:", status == LPX_OPT ? "OPTIMAL" : status == LPX_FEAS ? "FEASIBLE" : status == LPX_INFEAS ? "INFEASIBLE (INTERMEDIATE)" : status == LPX_NOFEAS ? "INFEASIBLE (FINAL)" : status == LPX_UNBND ? "UNBOUNDED" : status == LPX_UNDEF ? "UNDEFINED" : "???"); } /* explanation/warning */ { fprintf(fp, "\nExplanation: This file presents amounts by whi" "ch objective coefficients,\n"); fprintf(fp, "constraint bounds, and variable bounds may be cha" "nged in the original problem\n"); fprintf(fp, "while the optimal basis remains the same. Note t" "hat the optimal solution\n"); fprintf(fp, "and objective value may change even though the ba" "sis remains the same.\n"); fprintf(fp, "These bounds assume that all parameters remain fi" "xed except the one in\n"); fprintf(fp, "question. If more than one parameter is changed," " it is possible for the\n"); fprintf(fp, "optimal basis to change even though each paramete" "r stays within its bounds.\n"); fprintf(fp, "For more details, consult a text on linear progra" "mming.\n"); } /* Sensitivity ranges if solution was optimal */ { int status; status = lpx_get_status(lp); if (status == LPX_OPT) { int i,j,k,m,n; int dir; double max_inc, max_dec; int *index; double *val; fprintf(fp, "\nObjective Coefficient Analysis\n"); fprintf(fp, " No. Column name St Value Max incr" "ease Max decrease\n"); fprintf(fp, "------ ------------ -- ------------- ---------" "---- ------------- \n"); n = lpx_get_num_cols(lp); m = lpx_get_num_rows(lp); dir = lpx_get_obj_dir(lp); /* allocate memory for index and val arrays */ index = ucalloc(1+n+m, sizeof(int)); val = ucalloc(1+n+m, sizeof(double)); for (j = 1; j <= n; j++) { char *name; int typx, tagx; double lb, ub, vx, dx; name = lpx_get_col_name(lp, j); if (name == NULL) name = ""; lpx_get_col_bnds(lp, j, &typx, &lb, &ub); #if 0 /* 21/XII-2003 by mao */ round = lp->round, lp->round = 1; lpx_get_col_info(lp, j, &tagx, &vx, &dx); lp->round = round; #else round = lpx_get_int_parm(lp, LPX_K_ROUND); lpx_set_int_parm(lp, LPX_K_ROUND, 1); lpx_get_col_info(lp, j, &tagx, &vx, &dx); lpx_set_int_parm(lp, LPX_K_ROUND, round); #endif /* row/column ordinal number */ fprintf(fp, "%6d ", j); /* row column/name */ if (strlen(name) <= 12) fprintf(fp, "%-12s ", name); else fprintf(fp, "%s\n%20s", name, ""); /* row/column status */ fprintf(fp, "%s ", tagx == LPX_BS ? "B " : tagx == LPX_NL ? "NL" : tagx == LPX_NU ? "NU" : tagx == LPX_NF ? "NF" : tagx == LPX_NS ? "NS" : "??"); /* objective coefficient */ fprintf(fp, "%13.6g ", lpx_get_obj_coef(lp, j)); if (tagx == LPX_NL) { if (dir==LPX_MIN) { /* reduced cost must be positive */ max_inc = DBL_MAX; /* really represents infinity */ max_dec = dx; } else { /* reduced cost must be negative */ max_inc = -dx; max_dec = DBL_MAX; /* means infinity */ } } if (tagx == LPX_NU) { if (dir==LPX_MIN) { /* reduced cost must be negative */ max_inc = -dx; max_dec = DBL_MAX; } else { max_inc = DBL_MAX; max_dec = dx; } } if (tagx == LPX_NF) { /* can't change nonbasic free variables' cost */ max_inc = 0.0; max_dec = 0.0; } if (tagx == LPX_NS) { /* doesn't matter what happens to the cost */ max_inc = DBL_MAX; max_dec = DBL_MAX; } if (tagx == LPX_BS) { int len; /* We need to see how this objective coefficient affects reduced costs of other variables */ len = lpx_eval_tab_row(lp, m+j, index, val); max_inc = DBL_MAX; max_dec = DBL_MAX; for (i = 1; i <= len; i++) { /*int stat;*/ int tagx2; double vx2, dx2; double delta; if (index[i]>m) lpx_get_col_info(lp, index[i]-m, &tagx2, &vx2, &dx2); else lpx_get_row_info(lp, index[i], &tagx2, &vx2, &dx2); if (tagx2 == LPX_NL) { if (val[i] != 0.0) { delta = dx2 / val[i]; if (delta < 0 && -delta < max_inc) max_inc = -delta; else if (delta >0 && delta < max_dec) max_dec = delta; } } if (tagx2 == LPX_NU) { if (val[i] != 0.0) { delta = dx2 / val[i]; if (delta < 0 && -delta < max_inc) max_inc = -delta; else if (delta > 0 && delta < max_dec) max_dec = delta; } } if (tagx2 == LPX_NF) { if (val[i] != 0.0) { max_inc = 0.0; max_dec = 0.0; } } } } if (max_inc == -0.0) max_inc = 0.0; if (max_dec == -0.0) max_dec = 0.0; if (max_inc == DBL_MAX) fprintf(fp, "%13s ", "infinity"); else if (max_inc < 1.0e-12 && max_inc > 0) fprintf(fp, "%13s ", "< eps"); else fprintf(fp, "%13.6g ", max_inc); if (max_dec == DBL_MAX) fprintf(fp, "%13s ", "infinity"); else if (max_dec < 1.0e-12 && max_dec > 0) fprintf(fp, "%13s ", "< eps"); else fprintf(fp, "%13.6g ", max_dec); fprintf(fp, "\n"); } for (what = 1; what <= 2; what++) { int ij, mn; fprintf(fp, "\n"); fprintf(fp, "%s Analysis\n", what==1? "Constraint Bounds":"Variable Bounds"); fprintf(fp, " No. %12s St Value Max increase " " Max decrease\n", what==1 ? " Row name":"Column name"); fprintf(fp, "------ ------------ -- ------------- ------" "------- ------------- \n"); mn = what==1 ? m : n; for (ij = 1; ij <= mn; ij++) { char *name; int typx, tagx; double lb, ub, vx, dx; if (what==1) name = lpx_get_row_name(lp, ij); else name = lpx_get_col_name(lp, ij); if (name == NULL) name = ""; #if 0 /* 21/XII-2003 by mao */ if (what==1) { lpx_get_row_bnds(lp, ij, &typx, &lb, &ub); round = lp->round, lp->round = 1; lpx_get_row_info(lp, ij, &tagx, &vx, &dx); lp->round = round; } else { lpx_get_col_bnds(lp, ij, &typx, &lb, &ub); round = lp->round, lp->round = 1; lpx_get_col_info(lp, ij, &tagx, &vx, &dx); lp->round = round; } #else round = lpx_get_int_parm(lp, LPX_K_ROUND); lpx_set_int_parm(lp, LPX_K_ROUND, 1); if (what==1) { lpx_get_row_bnds(lp, ij, &typx, &lb, &ub); lpx_get_row_info(lp, ij, &tagx, &vx, &dx); } else { lpx_get_col_bnds(lp, ij, &typx, &lb, &ub); lpx_get_col_info(lp, ij, &tagx, &vx, &dx); } lpx_set_int_parm(lp, LPX_K_ROUND, round); #endif /* row/column ordinal number */ fprintf(fp, "%6d ", ij); /* row column/name */ if (strlen(name) <= 12) fprintf(fp, "%-12s ", name); else fprintf(fp, "%s\n%20s", name, ""); /* row/column status */ fprintf(fp, "%s ", tagx == LPX_BS ? "B " : tagx == LPX_NL ? "NL" : tagx == LPX_NU ? "NU" : tagx == LPX_NF ? "NF" : tagx == LPX_NS ? "NS" : "??"); fprintf(fp, "\n"); /* first check lower bound */ if (typx == LPX_LO || typx == LPX_DB || typx == LPX_FX) { int at_lower; at_lower = 0; if (tagx == LPX_BS || tagx == LPX_NU) { max_inc = vx - lb; max_dec = DBL_MAX; } if (tagx == LPX_NS) { max_inc = 0.0; max_dec = 0.0; if (dir == LPX_MIN && dx > 0) at_lower = 1; if (dir == LPX_MAX && dx < 0) at_lower = 1; } if (tagx == LPX_NL || at_lower == 1) { int len; /* we have to see how it affects basic variables */ len = lpx_eval_tab_col(lp, what==1?ij:ij+m, index, val); k = lpx_prim_ratio_test(lp, len, index, val, 1, 10e-7); max_inc = DBL_MAX; if (k != 0) { /*int stat;*/ int tagx2, typx2; double vx2, dx2, lb2, ub2; /*double delta;*/ double alpha; int l; for (l = 1; l <= len; l++) if (index[l] == k) alpha = val[l]; if (k>m) { lpx_get_col_info(lp, k-m, &tagx2, &vx2, &dx2); lpx_get_col_bnds(lp, k-m, &typx2, &lb2, &ub2); } else { lpx_get_row_info(lp, k, &tagx2, &vx2, &dx2); lpx_get_row_bnds(lp, k, &typx2, &lb2, &ub2); } /* Check which direction; remember this is upper bound */ if (alpha > 0) max_inc = (ub2 - vx2)/ alpha; else max_inc = (lb2 - vx2)/ alpha; } /* now check lower bound */ k = lpx_prim_ratio_test(lp, len, index, val, -1, 10e-7); max_dec = DBL_MAX; if (k != 0) { /*int stat;*/ int tagx2, typx2; double vx2, dx2, lb2, ub2; /*double delta;*/ double alpha; int l; for (l = 1; l <= len; l++) if (index[l] == k) alpha = val[l]; if (k>m) { lpx_get_col_info(lp, k-m, &tagx2, &vx2, &dx2); lpx_get_col_bnds(lp, k-m, &typx2, &lb2, &ub2); } else { lpx_get_row_info(lp, k, &tagx2, &vx2, &dx2); lpx_get_row_bnds(lp, k, &typx2, &lb2, &ub2); } /* Check which direction; remember this is lower bound */ if (alpha > 0) max_dec = (vx2 - lb2)/ alpha; else max_dec = (vx2 - ub2)/ alpha; } } /* bound */ if (typx == LPX_DB || typx == LPX_FX) { if (max_inc > ub - lb) max_inc = ub - lb; } fprintf(fp, " LOWER %13.6g ", lb); if (max_inc == -0.0) max_inc = 0.0; if (max_dec == -0.0) max_dec = 0.0; if (max_inc == DBL_MAX) fprintf(fp, "%13s ", "infinity"); else if (max_inc < 1.0e-12 && max_inc > 0) fprintf(fp, "%13s ", "< eps"); else fprintf(fp, "%13.6g ", max_inc); if (max_dec == DBL_MAX) fprintf(fp, "%13s ", "infinity"); else if (max_dec < 1.0e-12 && max_dec > 0) fprintf(fp, "%13s ", "< eps"); else fprintf(fp, "%13.6g ", max_dec); fprintf(fp, "\n"); } /* now check upper bound */ if (typx == LPX_UP || typx == LPX_DB || typx == LPX_FX) { int at_upper; at_upper = 0; if (tagx == LPX_BS || tagx == LPX_NL) { max_inc = DBL_MAX; max_dec = ub - vx; } if (tagx == LPX_NS) { max_inc = 0.0; max_dec = 0.0; if (dir == LPX_MIN && dx < 0) at_upper = 1; if (dir == LPX_MAX && dx > 0) at_upper = 1; } if (tagx == LPX_NU || at_upper == 1) { int len; /* we have to see how it affects basic variables */ len = lpx_eval_tab_col(lp, what==1?ij:ij+m, index, val); k = lpx_prim_ratio_test(lp, len, index, val, 1, 10e-7); max_inc = DBL_MAX; if (k != 0) { /*int stat;*/ int tagx2, typx2; double vx2, dx2, lb2, ub2; /*double delta;*/ double alpha; int l; for (l = 1; l <= len; l++) if (index[l] == k) alpha = val[l]; if (k>m) { lpx_get_col_info(lp, k-m, &tagx2, &vx2, &dx2); lpx_get_col_bnds(lp, k-m, &typx2, &lb2, &ub2); } else { lpx_get_row_info(lp, k, &tagx2, &vx2, &dx2); lpx_get_row_bnds(lp, k, &typx2, &lb2, &ub2); } /* Check which direction; remember this is upper bound */ if (alpha > 0) max_inc = (ub2 - vx2)/ alpha; else max_inc = (lb2 - vx2)/ alpha; } /* now check lower bound */ k = lpx_prim_ratio_test(lp, len, index, val, -1, 10e-7); max_dec = DBL_MAX; if (k != 0) { /*int stat;*/ int tagx2, typx2; double vx2, dx2, lb2, ub2; /*double delta;*/ double alpha; int l; for (l = 1; l <= len; l++) if (index[l] == k) alpha = val[l]; if (k>m) { lpx_get_col_info(lp, k-m, &tagx2, &vx2, &dx2); lpx_get_col_bnds(lp, k-m, &typx2, &lb2, &ub2); } else { lpx_get_row_info(lp, k, &tagx2, &vx2, &dx2); lpx_get_row_bnds(lp, k, &typx2, &lb2, &ub2); } /* Check which direction; remember this is lower bound */ if (alpha > 0) max_dec = (vx2 - lb2)/ alpha; else max_dec = (vx2 - ub2)/ alpha; } } if (typx == LPX_DB || typx == LPX_FX) { if (max_dec > ub - lb) max_dec = ub - lb; } /* bound */ fprintf(fp, " UPPER %13.6g ", ub); if (max_inc == -0.0) max_inc = 0.0; if (max_dec == -0.0) max_dec = 0.0; if (max_inc == DBL_MAX) fprintf(fp, "%13s ", "infinity"); else if (max_inc < 1.0e-12 && max_inc > 0) fprintf(fp, "%13s ", "< eps"); else fprintf(fp, "%13.6g ", max_inc); if (max_dec == DBL_MAX) fprintf(fp, "%13s ", "infinity"); else if (max_dec < 1.0e-12 && max_dec > 0) fprintf(fp, "%13s ", "< eps"); else fprintf(fp, "%13.6g ", max_dec); fprintf(fp, "\n"); } } } /* free the memory we used */ ufree(index); ufree(val); } else fprintf(fp, "No range information since solution is not o" "ptimal.\n"); } fprintf(fp, "\n"); fprintf(fp, "End of output\n"); fflush(fp); if (ferror(fp)) { print("lpx_print_sens_bnds: can't write to `%s' - %s", fname, strerror(errno)); goto fail; } ufclose(fp); return 0; fail: if (fp != NULL) ufclose(fp); return 1; }