GOBNILP  f164d83
utils.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * GOBNILP Copyright (C) 2012-2017 James Cussens, Mark Bartlett *
3  * *
4  * This program is free software; you can redistribute it and/or *
5  * modify it under the terms of the GNU General Public License as *
6  * published by the Free Software Foundation; either version 3 of the *
7  * License, or (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12  * General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License *
15  * along with this program; if not, see *
16  * <http://www.gnu.org/licenses>. *
17  * *
18  * Additional permission under GNU GPL version 3 section 7 *
19  * *
20  * If you modify this Program, or any covered work, by linking or *
21  * combining it with SCIP (or a modified version of that library), *
22  * containing parts covered by the terms of the ZIB Academic License, *
23  * the licensors of this Program grant you additional permission to *
24  * convey the resulting work. *
25  * *
26  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
27 
32 #ifndef __UTILS_H__
33 #define __UTILS_H__
34 
35 #include <scip/scipdefplugins.h>
36 #include "parent_set_data.h"
37 
38 extern SCIP_RETCODE hashtableCreateArrow(SCIP* scip, ParentSetData* psd);
39 extern SCIP_RETCODE hashtablefreeArrow(SCIP* scip, ParentSetData* psd);
40 extern SCIP_VAR* get_arrowedge(const ParentSetData* psd, const int i, const int j, SCIP_Bool arrow);
41 extern SCIP_VAR* get_arrow(const ParentSetData* psd, const int i, const int j);
42 extern SCIP_RETCODE put_arrow(SCIP* scip, ParentSetData* psd, const int i, const int j, SCIP_VAR* arrow_i_j);
43 extern SCIP_VAR* get_edge(const ParentSetData* psd, const int i, const int j);
44 extern SCIP_RETCODE put_edge(SCIP* scip, ParentSetData* psd, const int i, const int j, SCIP_VAR* edge_i_j);
45 
46 extern char* SCIPstrdup(SCIP* scip, const char* str);
47 
48 extern SCIP_RETCODE allsubsets(SCIP* scip, const int* set, const int n, int*** subsets_ptr);
49 extern SCIP_RETCODE free_allsubsets(SCIP* scip, int*** subsets_ptr);
50 
51 
52 /* Some convenient wrappers for creating new parameters that set many values to sensible defaults */
53 extern SCIP_RETCODE UT_addBoolParam(SCIP* scip, const char* name, const char* desc, SCIP_Bool value);
54 extern SCIP_RETCODE UT_addIntParam(SCIP* scip, const char* name, const char* desc, int value, int min, int max);
55 extern SCIP_RETCODE UT_addLongintParam(SCIP* scip, const char* name, const char* desc, SCIP_Longint value, SCIP_Longint min, SCIP_Longint max);
56 extern SCIP_RETCODE UT_addRealParam(SCIP* scip, const char* name, const char* desc, SCIP_Real value, SCIP_Real min, SCIP_Real max);
57 extern SCIP_RETCODE UT_addStringParam(SCIP* scip, const char* name, const char* desc, const char* value);
58 
59 /* Some convenient wrappers for creating empty linear constraints that set many values to sensible defaults */
60 extern SCIP_RETCODE UT_createEmptyLinearConstraint(SCIP* scip, SCIP_CONS** cons, const char* name, SCIP_Real lhs, SCIP_Real rhs);
61 extern SCIP_RETCODE UT_createEmptyGTEConstraint(SCIP* scip, SCIP_CONS** cons, const char* name, SCIP_Real rhs);
62 extern SCIP_RETCODE UT_createEmptyLTEConstraint(SCIP* scip, SCIP_CONS** cons, const char* name, SCIP_Real lhs);
63 
64 /* Functions and constants for writing and parsing items */
65 #define UT_LIST_START '['
66 #define UT_LIST_END ']'
67 #define UT_LIST_SEP ','
68 
69 extern SCIP_RETCODE UT_writeStringArray(SCIP* scip, FILE* file, char** input_array, int length);
70 extern SCIP_RETCODE UT_writeIntArray(SCIP* scip, FILE* file, int* input_array, int length);
71 extern SCIP_RETCODE UT_writeCharArray(SCIP* scip, FILE* file, char* input_array, int length);
72 extern SCIP_RETCODE UT_writeVarArray(SCIP* scip, FILE* file, SCIP_VAR** input_array, int length);
73 extern SCIP_RETCODE UT_writeIntArrayArray(SCIP* scip, FILE* file, int** input_array, int* lengths, int length);
74 extern SCIP_RETCODE UT_writeVarArrayArray(SCIP* scip, FILE* file, SCIP_VAR*** input_array, int* lengths, int length);
75 extern SCIP_RETCODE UT_writeIntArrayArrayArray(SCIP* scip, FILE* file, int*** input_array, int** lengths, int* lengths_of_lengths, int length);
76 
77 extern SCIP_RETCODE UT_parseArray(char* input_string, char*** output_array);
78 extern SCIP_RETCODE UT_parseStringArray(char* input_string, char*** output_array, int length);
79 extern SCIP_RETCODE UT_parseIntArray(char* input_string, int** output_array, int length);
80 extern SCIP_RETCODE UT_parseCharArray(char* input_string, char** output_array, int length);
81 extern SCIP_RETCODE UT_parseVarArray(SCIP* scip, char* input_string, SCIP_VAR*** output_array, int length);
82 extern SCIP_RETCODE UT_parseIntArrayArray(char* input_string, int*** output_array, int* lengths, int length);
83 extern SCIP_RETCODE UT_parseVarArrayArray(SCIP* scip, char* input_string, SCIP_VAR**** output_array, int* lengths, int length);
84 extern SCIP_RETCODE UT_parseIntArrayArrayArray(char* input_string, int**** output_array, int** lengths, int* lengths_of_lengths, int length);
85 
86 /* Functions for reading from a file */
87 extern SCIP_RETCODE UT_readFileAndSplit(SCIP* scip, FILE* file, char* splitters, int num_splitters, SCIP_Bool multiple_splitters_as_one, char**** lines, int* num_lines, int** line_lengths);
88 
89 extern int get_index(char* nodeName, ParentSetData* psd);
90 
91 extern SCIP_Bool is_dr_feasible(SCIP* scip, const ParentSetData* psd, SCIP_SOL* sol, SCIP_Bool constructing, SCIP_SOL* dr_sol);
92 
93 #endif
SCIP_RETCODE UT_writeCharArray(SCIP *scip, FILE *file, char *input_array, int length)
Writes an array of characters to a file.
Definition: utils.c:759
Function and type declarations for parent_set_data.c.
SCIP_Bool is_dr_feasible(SCIP *scip, const ParentSetData *psd, SCIP_SOL *sol, SCIP_Bool constructing, SCIP_SOL *dr_sol)
Definition: utils.c:1606
SCIP_RETCODE UT_createEmptyLinearConstraint(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_Real lhs, SCIP_Real rhs)
Creates an initially empty linear constraint with most options set to sensible defaults.
Definition: utils.c:561
SCIP_RETCODE UT_parseIntArrayArray(char *input_string, int ***output_array, int *lengths, int length)
Parses an array of integer arrays from a string.
Definition: utils.c:1295
SCIP_RETCODE UT_parseIntArray(char *input_string, int **output_array, int length)
Parses an integer array from a string.
Definition: utils.c:1201
SCIP_RETCODE put_edge(SCIP *scip, ParentSetData *psd, const int i, const int j, SCIP_VAR *edge_i_j)
Store an edge variable for specified child and parent.
Definition: utils.c:413
SCIP_RETCODE UT_addStringParam(SCIP *scip, const char *name, const char *desc, const char *value)
Adds a string parameter to those recognised by SCIP.
Definition: utils.c:541
SCIP_RETCODE UT_writeIntArray(SCIP *scip, FILE *file, int *input_array, int length)
Writes an array of integers to a file.
Definition: utils.c:726
The basic data needed to record a collection of parent sets associated with a problem.
Definition: parent_set_data.h:48
SCIP_RETCODE UT_parseStringArray(char *input_string, char ***output_array, int length)
Parses a string array from a string.
Definition: utils.c:1172
SCIP_RETCODE hashtablefreeArrow(SCIP *scip, ParentSetData *psd)
Frees memory (previously) used by a hash table.
Definition: utils.c:190
SCIP_RETCODE UT_createEmptyGTEConstraint(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_Real rhs)
Creates an initially empty greater than or equal to linear constraint with most options set to sensib...
Definition: utils.c:600
SCIP_RETCODE UT_writeIntArrayArray(SCIP *scip, FILE *file, int **input_array, int *lengths, int length)
Writes an array of arrays of integers to a file.
Definition: utils.c:828
SCIP_RETCODE UT_createEmptyLTEConstraint(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_Real lhs)
Creates an initially empty less than or equal to linear constraint with most options set to sensible ...
Definition: utils.c:582
SCIP_RETCODE allsubsets(SCIP *scip, const int *set, const int n, int ***subsets_ptr)
Definition: utils.c:121
SCIP_RETCODE UT_parseIntArrayArrayArray(char *input_string, int ****output_array, int **lengths, int *lengths_of_lengths, int length)
Parses an array of arrays of integer arrays from a string.
Definition: utils.c:1365
int get_index(char *nodeName, ParentSetData *psd)
Gets the index of a named variable.
Definition: utils.c:73
SCIP_VAR * get_arrowedge(const ParentSetData *psd, const int i, const int j, SCIP_Bool arrow)
Retrieve an arrow or edge variable for specified child and parent or NULL if none exists...
Definition: utils.c:265
SCIP_RETCODE UT_writeStringArray(SCIP *scip, FILE *file, char **input_array, int length)
Writes an array of strings to a file.
Definition: utils.c:694
SCIP_RETCODE UT_parseCharArray(char *input_string, char **output_array, int length)
Parses a character array from a string.
Definition: utils.c:1229
SCIP_RETCODE put_arrow(SCIP *scip, ParentSetData *psd, const int i, const int j, SCIP_VAR *arrow_i_j)
Store an arrow variable for specified child and parent.
Definition: utils.c:401
SCIP_RETCODE UT_writeVarArray(SCIP *scip, FILE *file, SCIP_VAR **input_array, int length)
Writes the names of an array of variables to a file.
Definition: utils.c:792
SCIP_RETCODE UT_writeVarArrayArray(SCIP *scip, FILE *file, SCIP_VAR ***input_array, int *lengths, int length)
Writes an array of arrays of variables to a file.
Definition: utils.c:858
SCIP_RETCODE UT_addIntParam(SCIP *scip, const char *name, const char *desc, int value, int min, int max)
Adds an integer parameter to those recognised by SCIP.
Definition: utils.c:468
SCIP_RETCODE free_allsubsets(SCIP *scip, int ***subsets_ptr)
Definition: utils.c:103
SCIP_RETCODE UT_readFileAndSplit(SCIP *scip, FILE *file, char *splitters, int num_splitters, SCIP_Bool multiple_splitters_as_one, char ****lines, int *num_lines, int **line_lengths)
Reads a file and splits it into lines, which are themselves split into white space delimited tokens...
Definition: utils.c:1495
SCIP_RETCODE UT_addRealParam(SCIP *scip, const char *name, const char *desc, SCIP_Real value, SCIP_Real min, SCIP_Real max)
Adds a real valued parameter to those recognised by SCIP.
Definition: utils.c:518
SCIP_RETCODE UT_writeIntArrayArrayArray(SCIP *scip, FILE *file, int ***input_array, int **lengths, int *lengths_of_lengths, int length)
Writes an array of arrays of arrays of integers to a file.
Definition: utils.c:889
SCIP_VAR * get_edge(const ParentSetData *psd, const int i, const int j)
Retrieve an edge variable for specified child and parent or NULL if none exists.
Definition: utils.c:326
SCIP_RETCODE UT_parseArray(char *input_string, char ***output_array)
Parses an array from a string.
Definition: utils.c:921
SCIP_VAR * get_arrow(const ParentSetData *psd, const int i, const int j)
Retrieve an arrow variable for specified child and parent or NULL if none exists. ...
Definition: utils.c:314
SCIP_RETCODE UT_addBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool value)
Adds a boolean parameter to those recognised by SCIP.
Definition: utils.c:445
SCIP_RETCODE hashtableCreateArrow(SCIP *scip, ParentSetData *psd)
Creates a hash table.
Definition: utils.c:227
SCIP_RETCODE UT_addLongintParam(SCIP *scip, const char *name, const char *desc, SCIP_Longint value, SCIP_Longint min, SCIP_Longint max)
Adds a long integer parameter to those recognised by SCIP.
Definition: utils.c:493
SCIP_RETCODE UT_parseVarArray(SCIP *scip, char *input_string, SCIP_VAR ***output_array, int length)
Parses a variable array from a string.
Definition: utils.c:1264
SCIP_RETCODE UT_parseVarArrayArray(SCIP *scip, char *input_string, SCIP_VAR ****output_array, int *lengths, int length)
Parses an array of variable arrays from a string.
Definition: utils.c:1332