Detailed Description
Methods for loading Steiner problems in .stp format.
This file includes methods for reading a Steiner problem in .stp format.
A list of all interface methods can be found in graph.h.
Definition in file graph_load.c.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <assert.h>
#include <stdarg.h>
#include "reduce.h"
#include <unistd.h>
#include "portab.h"
#include "graph.h"
Go to the source code of this file.
Data Structures | |
struct | key |
struct | section |
struct | current_file |
union | parameter |
Typedefs | |
typedef struct current_file | CURF |
typedef union parameter | PARA |
Functions | |
static char * | strlower (char *s) |
static SCIP_RETCODE | check_inputgraph (SCIP *scip, int nterms, GRAPH *graph) |
static void | message (unsigned int type, const CURF *curf, const char *msg,...) |
static int | key_cmp (const void *key, const void *elem) |
static int | sec_cmp (const void *key, const void *section) |
static int | get_arguments (const CURF *curf, const char *format, const char *s, PARA *para) |
static int | open_file (CURF *curf, unsigned char main_file) |
static int | start_section (const char *pathname, const char *basename, CURF *curf, CURF *save, const char *s) |
static SCIP_RETCODE | init_coordinates (SCIP *scip, GRAPH *g, PARA *para, double ***coordinates, int *grid_dim, int *termcount, int dim, int nodes) |
static int | get_scale_order (SCIP_Real number) |
static SCIP_RETCODE | scale_coords (double **coordinates, int ***scaled_coords, int *scale_order, int nnodes, int grid_dim) |
SCIP_RETCODE | graph_load (SCIP *scip, GRAPH **graph, const char *file, PRESOL *presol) |
Variables | |
static const struct key | keyword_table [] |
static struct section | section_table [] |
Macro Definition Documentation
◆ GRPHLOAD_C
#define GRPHLOAD_C |
Definition at line 30 of file graph_load.c.
◆ MSG_FATAL
#define MSG_FATAL 0 |
Definition at line 56 of file graph_load.c.
Referenced by graph_load(), open_file(), and start_section().
◆ MSG_ERROR
#define MSG_ERROR 1 |
Definition at line 57 of file graph_load.c.
Referenced by graph_load().
◆ MSG_WARN
#define MSG_WARN 2 |
Definition at line 58 of file graph_load.c.
Referenced by get_arguments(), and open_file().
◆ MSG_INFO
#define MSG_INFO 3 |
Definition at line 59 of file graph_load.c.
Referenced by graph_load().
◆ MSG_DEBUG
#define MSG_DEBUG 4 |
Definition at line 60 of file graph_load.c.
Referenced by get_arguments(), and graph_load().
◆ VERBOSE
#define VERBOSE MSG_INFO |
Definition at line 65 of file graph_load.c.
Referenced by message().
◆ MAX_PATH_LEN
#define MAX_PATH_LEN 1024 |
Definition at line 81 of file graph_load.c.
Referenced by graph_load(), open_file(), and start_section().
◆ EXTSEP
#define EXTSEP '.' |
Definition at line 86 of file graph_load.c.
Referenced by graph_load(), and start_section().
◆ MAX_LINE_LEN
#define MAX_LINE_LEN 1024 |
Definition at line 88 of file graph_load.c.
Referenced by graph_load().
◆ MAX_KEYWORD_LEN
#define MAX_KEYWORD_LEN 64 |
Definition at line 89 of file graph_load.c.
Referenced by graph_load(), and start_section().
◆ MAX_STRING_LEN
#define MAX_STRING_LEN 256 |
Definition at line 90 of file graph_load.c.
Referenced by get_arguments().
◆ MAX_ARGUMENTS
#define MAX_ARGUMENTS 8 |
Definition at line 91 of file graph_load.c.
Referenced by graph_load().
◆ KEY_SECTION
#define KEY_SECTION 0001 |
Definition at line 100 of file graph_load.c.
Referenced by graph_load().
◆ KEY_EOF
#define KEY_EOF 9999 |
Definition at line 101 of file graph_load.c.
Referenced by graph_load().
◆ KEY_END
#define KEY_END 9998 |
Definition at line 102 of file graph_load.c.
Referenced by graph_load().
◆ KEY_COMMENT_NAME
#define KEY_COMMENT_NAME 1001 |
Definition at line 104 of file graph_load.c.
Referenced by graph_load().
◆ KEY_COMMENT_DATE
#define KEY_COMMENT_DATE 1002 |
Definition at line 105 of file graph_load.c.
Referenced by graph_load().
◆ KEY_COMMENT_CREATOR
#define KEY_COMMENT_CREATOR 1003 |
Definition at line 106 of file graph_load.c.
Referenced by graph_load().
◆ KEY_COMMENT_PROBLEM
#define KEY_COMMENT_PROBLEM 1004 |
Definition at line 107 of file graph_load.c.
Referenced by graph_load().
◆ KEY_COMMENT_REMARK
#define KEY_COMMENT_REMARK 1005 |
Definition at line 108 of file graph_load.c.
Referenced by graph_load().
◆ KEY_GRAPH_NODES
#define KEY_GRAPH_NODES 2001 |
Definition at line 110 of file graph_load.c.
Referenced by graph_load().
◆ KEY_GRAPH_EDGES
#define KEY_GRAPH_EDGES 2002 |
Definition at line 111 of file graph_load.c.
Referenced by graph_load().
◆ KEY_GRAPH_E
#define KEY_GRAPH_E 2003 |
Definition at line 112 of file graph_load.c.
Referenced by graph_load().
◆ KEY_GRAPH_A
#define KEY_GRAPH_A 2004 |
Definition at line 113 of file graph_load.c.
Referenced by graph_load().
◆ KEY_GRAPH_AA
#define KEY_GRAPH_AA 2005 |
Definition at line 114 of file graph_load.c.
Referenced by graph_load().
◆ KEY_GRAPH_OBSTACLES
#define KEY_GRAPH_OBSTACLES 2006 |
Definition at line 115 of file graph_load.c.
Referenced by graph_load().
◆ KEY_GRAPH_HOPLIMIT
#define KEY_GRAPH_HOPLIMIT 2007 |
Definition at line 116 of file graph_load.c.
Referenced by graph_load().
◆ KEY_TERMINALS_END
#define KEY_TERMINALS_END 3001 |
Definition at line 118 of file graph_load.c.
Referenced by graph_load().
◆ KEY_TERMINALS_TERMINALS
#define KEY_TERMINALS_TERMINALS 3002 |
Definition at line 119 of file graph_load.c.
Referenced by graph_load().
◆ KEY_TERMINALS_T
#define KEY_TERMINALS_T 3003 |
Definition at line 120 of file graph_load.c.
Referenced by graph_load().
◆ KEY_TERMINALS_TP
#define KEY_TERMINALS_TP 3004 |
Definition at line 121 of file graph_load.c.
Referenced by graph_load().
◆ KEY_TERMINALS_ROOT
#define KEY_TERMINALS_ROOT 3005 |
Definition at line 122 of file graph_load.c.
Referenced by graph_load().
◆ KEY_TERMINALS_ROOTP
#define KEY_TERMINALS_ROOTP 3006 |
Definition at line 123 of file graph_load.c.
Referenced by graph_load().
◆ KEY_TERMINALS_TG
#define KEY_TERMINALS_TG 3007 |
Definition at line 124 of file graph_load.c.
Referenced by graph_load().
◆ KEY_TERMINALS_GROUPS
#define KEY_TERMINALS_GROUPS 3008 |
Definition at line 125 of file graph_load.c.
Referenced by graph_load().
◆ KEY_TERMINALS_TR
#define KEY_TERMINALS_TR 3009 |
Definition at line 126 of file graph_load.c.
Referenced by graph_load().
◆ KEY_TERMINALS_TF
#define KEY_TERMINALS_TF 3010 |
Definition at line 127 of file graph_load.c.
Referenced by graph_load().
◆ KEY_TERMINALS_TL
#define KEY_TERMINALS_TL 3011 |
Definition at line 128 of file graph_load.c.
Referenced by graph_load().
◆ KEY_TERMINALS_TB
#define KEY_TERMINALS_TB 3012 |
Definition at line 129 of file graph_load.c.
Referenced by graph_load().
◆ KEY_TERMINALS_RB
#define KEY_TERMINALS_RB 3013 |
Definition at line 130 of file graph_load.c.
Referenced by graph_load().
◆ KEY_COORDINATES_DD
#define KEY_COORDINATES_DD 4001 |
Definition at line 132 of file graph_load.c.
Referenced by graph_load().
◆ KEY_COORDINATES_DDD
#define KEY_COORDINATES_DDD 4002 |
Definition at line 133 of file graph_load.c.
Referenced by graph_load().
◆ KEY_COORDINATES_DDDD
#define KEY_COORDINATES_DDDD 4003 |
Definition at line 134 of file graph_load.c.
Referenced by graph_load().
◆ KEY_COORDINATES_DDDDD
#define KEY_COORDINATES_DDDDD 4004 |
Definition at line 135 of file graph_load.c.
Referenced by graph_load().
◆ KEY_COORDINATES_DDDDDD
#define KEY_COORDINATES_DDDDDD 4005 |
Definition at line 136 of file graph_load.c.
Referenced by graph_load().
◆ KEY_COORDINATES_DDDDDDD
#define KEY_COORDINATES_DDDDDDD 4006 |
Definition at line 137 of file graph_load.c.
Referenced by graph_load().
◆ KEY_COORDINATES_DDDDDDDD
#define KEY_COORDINATES_DDDDDDDD 4007 |
Definition at line 138 of file graph_load.c.
Referenced by graph_load().
◆ KEY_COORDINATES_END
#define KEY_COORDINATES_END 4011 |
Definition at line 140 of file graph_load.c.
Referenced by graph_load().
◆ KEY_COORDINATES_GRID
#define KEY_COORDINATES_GRID 4012 |
Definition at line 141 of file graph_load.c.
Referenced by graph_load().
◆ KEY_SOLUTION_VALUE
#define KEY_SOLUTION_VALUE 4021 |
Definition at line 143 of file graph_load.c.
◆ KEY_SOLUTION_DATE
#define KEY_SOLUTION_DATE 4022 |
Definition at line 144 of file graph_load.c.
◆ KEY_SOLUTION_TIME
#define KEY_SOLUTION_TIME 4023 |
Definition at line 145 of file graph_load.c.
◆ KEY_SOLUTION_STEINER
#define KEY_SOLUTION_STEINER 4024 |
Definition at line 146 of file graph_load.c.
◆ KEY_SOLUTION_S
#define KEY_SOLUTION_S 4025 |
Definition at line 147 of file graph_load.c.
◆ KEY_PRESOLVE_DATE
#define KEY_PRESOLVE_DATE 5001 |
Definition at line 149 of file graph_load.c.
Referenced by graph_load().
◆ KEY_PRESOLVE_FIXED
#define KEY_PRESOLVE_FIXED 5002 |
Definition at line 150 of file graph_load.c.
Referenced by graph_load().
◆ KEY_PRESOLVE_LOWER
#define KEY_PRESOLVE_LOWER 5003 |
Definition at line 151 of file graph_load.c.
Referenced by graph_load().
◆ KEY_PRESOLVE_UPPER
#define KEY_PRESOLVE_UPPER 5004 |
Definition at line 152 of file graph_load.c.
Referenced by graph_load().
◆ KEY_PRESOLVE_TIME
#define KEY_PRESOLVE_TIME 5005 |
Definition at line 153 of file graph_load.c.
Referenced by graph_load().
◆ KEY_PRESOLVE_EA
#define KEY_PRESOLVE_EA 5006 |
Definition at line 154 of file graph_load.c.
Referenced by graph_load().
◆ KEY_PRESOLVE_EC
#define KEY_PRESOLVE_EC 5007 |
Definition at line 155 of file graph_load.c.
Referenced by graph_load().
◆ KEY_PRESOLVE_ED
#define KEY_PRESOLVE_ED 5008 |
Definition at line 156 of file graph_load.c.
Referenced by graph_load().
◆ KEY_PRESOLVE_ES
#define KEY_PRESOLVE_ES 5009 |
Definition at line 157 of file graph_load.c.
Referenced by graph_load().
◆ KEY_NODEWEIGHTS_NW
#define KEY_NODEWEIGHTS_NW 6000 |
Definition at line 160 of file graph_load.c.
Referenced by graph_load().
◆ KEY_NODEWEIGHTS_END
#define KEY_NODEWEIGHTS_END 6001 |
Definition at line 161 of file graph_load.c.
Referenced by graph_load().
◆ KEY_MAXDEGS_MD
#define KEY_MAXDEGS_MD 8000 |
Definition at line 163 of file graph_load.c.
Referenced by graph_load().
◆ KEY_OBSTACLES_RR
#define KEY_OBSTACLES_RR 9000 |
Definition at line 165 of file graph_load.c.
Referenced by graph_load().
◆ KEY_OBSTACLES_END
#define KEY_OBSTACLES_END 9001 |
Definition at line 166 of file graph_load.c.
Referenced by graph_load().
◆ KEY_HOPCONS_LIM
#define KEY_HOPCONS_LIM 10000 |
Definition at line 168 of file graph_load.c.
◆ KEY_HOPCONS_FACTOR
#define KEY_HOPCONS_FACTOR 10001 |
Definition at line 169 of file graph_load.c.
◆ KEY_TREE_S
#define KEY_TREE_S 11000 |
Definition at line 171 of file graph_load.c.
Referenced by graph_load().
◆ KEY_BUDGET_B
#define KEY_BUDGET_B 12000 |
Definition at line 173 of file graph_load.c.
Referenced by graph_load().
◆ FLAG_OPTIONAL
#define FLAG_OPTIONAL 1 |
Definition at line 269 of file graph_load.c.
◆ FLAG_REQUIRED
#define FLAG_REQUIRED 2 |
Definition at line 270 of file graph_load.c.
Referenced by graph_load(), and start_section().
◆ SECTION_MISSING
#define SECTION_MISSING 0 |
Definition at line 272 of file graph_load.c.
Referenced by graph_load().
◆ SECTION_EXISTEND
#define SECTION_EXISTEND 1 |
Definition at line 273 of file graph_load.c.
Referenced by graph_load(), and start_section().
Typedef Documentation
◆ CURF
typedef struct current_file CURF |
◆ PARA
Function Documentation
◆ strlower()
|
static |
Definition at line 318 of file graph_load.c.
Referenced by open_file(), and start_section().
◆ check_inputgraph()
|
static |
checks input graph and return possible read error
- Parameters
-
scip SCIP data structure nterms number of terminals graph graph
Definition at line 333 of file graph_load.c.
References graph_hasMultiEdges(), graph_typeIsSpgLike(), graph_validInput(), reduce_unconnectedInfeas(), SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_READERROR, SCIPerrorMessage, GRAPH::terms, and TRUE.
Referenced by graph_load().
◆ message()
|
static |
Definition at line 381 of file graph_load.c.
References current_file::filename, current_file::line, NULL, and VERBOSE.
Referenced by get_arguments(), graph_load(), open_file(), SCIP_DECL_DIALOGEXEC(), and start_section().
◆ key_cmp()
|
static |
Definition at line 417 of file graph_load.c.
References key::keyword, and NULL.
◆ sec_cmp()
|
static |
◆ get_arguments()
|
static |
Definition at line 452 of file graph_load.c.
References FAILURE, FALSE, MAX_STRING_LEN, message(), MSG_DEBUG, MSG_WARN, parameter::n, NULL, parameter::s, SCIP_Bool, SUCCESS, and TRUE.
Referenced by graph_load().
◆ open_file()
|
static |
Definition at line 565 of file graph_load.c.
References section::extension, FAILURE, current_file::filename, current_file::fp, current_file::line, MAX_PATH_LEN, message(), MSG_FATAL, MSG_WARN, NULL, current_file::section, STP_FILE_MAGIC, STP_FILE_VERSION_MAJOR, STP_FILE_VERSION_MINOR, strlower(), and SUCCESS.
Referenced by graph_load(), and start_section().
◆ start_section()
|
static |
Definition at line 661 of file graph_load.c.
References section::extension, EXTSEP, FAILURE, FALSE, current_file::filename, section::flag, FLAG_REQUIRED, section::mark, MAX_KEYWORD_LEN, MAX_PATH_LEN, message(), MSG_FATAL, NULL, open_file(), sec_cmp(), current_file::section, SECTION_EXISTEND, section_table, strlower(), and SUCCESS.
Referenced by graph_load().
◆ init_coordinates()
|
static |
Definition at line 759 of file graph_load.c.
References NULL, SCIP_CALL, SCIP_OKAY, and SCIPallocMemoryArray.
Referenced by graph_load().
◆ get_scale_order()
|
static |
Definition at line 797 of file graph_load.c.
References SCIP_MAXSTRLEN, and SCIPsnprintf().
Referenced by scale_coords().
◆ scale_coords()
|
static |
Definition at line 835 of file graph_load.c.
References get_scale_order(), nnodes, NULL, SCIP_CALL, SCIP_OKAY, and SCIPallocMemoryArray.
Referenced by graph_load().
◆ graph_load()
SCIP_RETCODE graph_load | ( | SCIP * | scip, |
GRAPH ** | graph, | ||
const char * | file, | ||
PRESOL * | presol | ||
) |
- Parameters
-
scip SCIP data structure graph pointer to store the graph file file to load presol presolving struct
Definition at line 885 of file graph_load.c.
References BLOCKED, GRAPH::budget, check_inputgraph(), GRAPH::cost, GRAPH::costbudget, DIRSEP, EAT_LAST, GRAPH::edges, EXTSEP, FAILURE, FALSE, FARAWAY, current_file::filename, presolve_info::fixed, section::flag, FLAG_REQUIRED, key::format, current_file::fp, get_arguments(), GRAPH::grad, graph_edge_add(), graph_get_nNodes(), graph_grid_create(), graph_hasMultiEdges(), graph_init(), graph_knot_add(), graph_knot_chg(), graph_obstgrid_create(), graph_pc_initPrizes(), graph_transGstpClean(), graph_transMw(), graph_transNw(), graph_transPc(), graph_transPc2Spg(), graph_transRmw(), graph_transRpc(), graph_transRpc2FixedProper(), graph_valid(), GRAPH::hoplimit, GRAPH::ieat, init_coordinates(), GRAPH::inpbeg, Is_term, KEY_BUDGET_B, KEY_COMMENT_CREATOR, KEY_COMMENT_DATE, KEY_COMMENT_NAME, KEY_COMMENT_PROBLEM, KEY_COMMENT_REMARK, KEY_COORDINATES_DD, KEY_COORDINATES_DDD, KEY_COORDINATES_DDDD, KEY_COORDINATES_DDDDD, KEY_COORDINATES_DDDDDD, KEY_COORDINATES_DDDDDDD, KEY_COORDINATES_DDDDDDDD, KEY_COORDINATES_END, KEY_COORDINATES_GRID, KEY_END, KEY_EOF, KEY_GRAPH_A, KEY_GRAPH_AA, KEY_GRAPH_E, KEY_GRAPH_EDGES, KEY_GRAPH_HOPLIMIT, KEY_GRAPH_NODES, KEY_GRAPH_OBSTACLES, KEY_MAXDEGS_MD, KEY_NODEWEIGHTS_END, KEY_NODEWEIGHTS_NW, KEY_OBSTACLES_END, KEY_OBSTACLES_RR, KEY_PRESOLVE_DATE, KEY_PRESOLVE_EA, KEY_PRESOLVE_EC, KEY_PRESOLVE_ED, KEY_PRESOLVE_ES, KEY_PRESOLVE_FIXED, KEY_PRESOLVE_LOWER, KEY_PRESOLVE_TIME, KEY_PRESOLVE_UPPER, KEY_SECTION, KEY_TERMINALS_END, KEY_TERMINALS_GROUPS, KEY_TERMINALS_RB, KEY_TERMINALS_ROOT, KEY_TERMINALS_ROOTP, KEY_TERMINALS_T, KEY_TERMINALS_TB, KEY_TERMINALS_TERMINALS, KEY_TERMINALS_TF, KEY_TERMINALS_TG, KEY_TERMINALS_TL, KEY_TERMINALS_TP, KEY_TERMINALS_TR, KEY_TREE_S, key::keyword, GRAPH::knots, current_file::line, presolve_info::lower, section::mark, MAX_ARGUMENTS, MAX_KEYWORD_LEN, MAX_LINE_LEN, MAX_PATH_LEN, GRAPH::maxdeg, message(), MSG_DEBUG, MSG_ERROR, MSG_FATAL, MSG_INFO, parameter::n, section::name, nnodes, NULL, GRAPH::oeat, open_file(), GRAPH::outbeg, GRAPH::prize, scale_coords(), SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_READERROR, SCIPallocBufferArray, SCIPallocMemoryArray, SCIPerrorMessage, SCIPfreeBufferArrayNull, SCIPfreeMemoryArrayNull, SCIPgetBoolParam(), SCIPisGT(), SCIPsnprintf(), current_file::section, SECTION_EXISTEND, SECTION_MISSING, GRAPH::source, start_section(), STP_BRMWCSP, STP_DCSTP, STP_DHCSTP, STP_GSTP, STP_MWCSP, STP_NWPTSPG, STP_NWSPG, STP_OARSMT, STP_PCSPG, STP_RMWCSP, STP_RPCSPG, STP_RSMT, STP_SAP, STP_SPG, STP_TERM, GRAPH::stp_type, SUCCESS, key::sw_code, GRAPH::tail, GRAPH::term, GRAPH::terms, presolve_info::time, TRUE, UNKNOWN, and presolve_info::upper.
Referenced by SCIPprobdataCreate().
Variable Documentation
◆ keyword_table
|
static |
Definition at line 176 of file graph_load.c.
◆ section_table
|
static |