text:
# Automatically generated using Clang.jl

const CPX_H = 1
const CPXBAR_H = 1
const CPXMIP_H = 1

# Skipping MacroDefinition: CPXgetmipobjval ( env , lp , objval_p ) CPXgetobjval ( env , lp , objval_p )
# Skipping MacroDefinition: CPXgetmipqconstrslack ( env , lp , qcslack , begin , end ) CPXgetqconstrslack ( env , lp , qcslack , begin , end )
# Skipping MacroDefinition: CPXgetmipslack ( env , lp , slack , begin , end ) CPXgetslack ( env , lp , slack , begin , end )
# Skipping MacroDefinition: CPXgetmipx ( env , lp , x , begin , end ) CPXgetx ( env , lp , x , begin , end )

const CPXGC_H = 1
const CPXNET_H = 1
const CPXQP_H = 1
const CPXSOCP_H = 1
const CPX_FEATURES_H = 1
const CPX_FEATURE_REMOTE_OBJECT = 1
const CPX_FEATURE_DISTRIBUTED_MIP = 1
const CPX_CPXAUTOINTTYPES_H_H = 1
const CPXBYTE_DEFINED = 1
const CPXINT_DEFINED = 1
const CPXLONG_DEFINED = 1
const CPXSHORT_DEFINED = 1
const CPXSIZE_BITS = 64
const CPXULONG_DEFINED = 1
const CPXINT_MAX = 2147483647
const CPXINT_MIN = -2147483648
const CPXDEPRECATEDAPI = nothing
const CPXDEPRECATED = nothing
const CPXDEPRECATEDENUMVAL = nothing
const CPX_STR_PARAM_MAX = 512

# Skipping MacroDefinition: CPX_STATIC_INLINE static inline
# Skipping MacroDefinition: CALLBACK_BRANCH_ARGS CPXCENVptr xenv , void * cbdata , int wherefrom , void * cbhandle , int brtype , int brset , int nodecnt , int bdcnt , const int * nodebeg , const int * xindex , const char * lu , const double * bd , const double * nodeest , int * useraction_p
# Skipping MacroDefinition: CALLBACK_NODE_ARGS CPXCENVptr xenv , void * cbdata , int wherefrom , void * cbhandle , int * nodeindex , int * useraction
# Skipping MacroDefinition: CALLBACK_HEURISTIC_ARGS CPXCENVptr xenv , void * cbdata , int wherefrom , void * cbhandle , double * objval_p , double * x , int * checkfeas_p , int * useraction_p
# Skipping MacroDefinition: CALLBACK_SOLVE_ARGS CPXCENVptr xenv , void * cbdata , int wherefrom , void * cbhandle , int * useraction
# Skipping MacroDefinition: CALLBACK_CUT_ARGS CPXCENVptr xenv , void * cbdata , int wherefrom , void * cbhandle , int * useraction_p
# Skipping MacroDefinition: CALLBACK_INCUMBENT_ARGS CPXCENVptr xenv , void * cbdata , int wherefrom , void * cbhandle , double objval , double * x , int * isfeas_p , int * useraction_p
# Skipping MacroDefinition: CALLBACK_DELETENODE_ARGS CPXCENVptr xenv , int wherefrom , void * cbhandle , int seqnum , void * handle

const CPX_VERSION = 20010000
const CPX_VERSION_VERSION = 20
const CPX_VERSION_RELEASE = 1
const CPX_VERSION_MODIFICATION = 0
const CPX_VERSION_FIX = 0
const CPX_INFBOUND = 1.0e20
const CPX_MINBOUND = 1.0e-13
const CPX_PWL_MAXSLOPE = 1.0e6
const CPX_PWL_MINSLOPE = 1.0e-6
const CPX_PARAMTYPE_NONE = 0
const CPX_PARAMTYPE_INT = 1
const CPX_PARAMTYPE_DOUBLE = 2
const CPX_PARAMTYPE_STRING = 3
const CPX_PARAMTYPE_LONG = 4
const CPX_NO_SOLN = 0
const CPX_AUTO_SOLN = 0
const CPX_BASIC_SOLN = 1
const CPX_NONBASIC_SOLN = 2
const CPX_PRIMAL_SOLN = 3
const CPX_PRECOL_LOW = -1
const CPX_PRECOL_UP = -2
const CPX_PRECOL_FIX = -3
const CPX_PRECOL_AGG = -4
const CPX_PRECOL_OTHER = -5
const CPX_PREROW_RED = -1
const CPX_PREROW_AGG = -2
const CPX_PREROW_OTHER = -3
const CPX_AUTO = -1
const CPX_ON = 1
const CPX_OFF = 0
const CPX_MAX = -1
const CPX_MIN = 1
const CPX_DATACHECK_OFF = 0
const CPX_DATACHECK_WARN = 1
const CPX_DATACHECK_ASSIST = 2
const CPX_PPRIIND_PARTIAL = -1
const CPX_PPRIIND_AUTO = 0
const CPX_PPRIIND_DEVEX = 1
const CPX_PPRIIND_STEEP = 2
const CPX_PPRIIND_STEEPQSTART = 3
const CPX_PPRIIND_FULL = 4
const CPX_DPRIIND_AUTO = 0
const CPX_DPRIIND_FULL = 1
const CPX_DPRIIND_STEEP = 2
const CPX_DPRIIND_FULLSTEEP = 3
const CPX_DPRIIND_STEEPQSTART = 4
const CPX_DPRIIND_DEVEX = 5
const CPX_PARALLEL_DETERMINISTIC = 1
const CPX_PARALLEL_AUTO = 0
const CPX_PARALLEL_OPPORTUNISTIC = -1
const CPX_WRITELEVEL_AUTO = 0
const CPX_WRITELEVEL_ALLVARS = 1
const CPX_WRITELEVEL_DISCRETEVARS = 2
const CPX_WRITELEVEL_NONZEROVARS = 3
const CPX_WRITELEVEL_NONZERODISCRETEVARS = 4
const CPX_OPTIMALITYTARGET_AUTO = 0
const CPX_OPTIMALITYTARGET_OPTIMALCONVEX = 1
const CPX_OPTIMALITYTARGET_FIRSTORDER = 2
const CPX_OPTIMALITYTARGET_OPTIMALGLOBAL = 3
const CPX_ALG_NONE = -1
const CPX_ALG_AUTOMATIC = 0
const CPX_ALG_PRIMAL = 1
const CPX_ALG_DUAL = 2
const CPX_ALG_NET = 3
const CPX_ALG_BARRIER = 4
const CPX_ALG_SIFTING = 5
const CPX_ALG_CONCURRENT = 6
const CPX_ALG_BAROPT = 7
const CPX_ALG_PIVOTIN = 8
const CPX_ALG_PIVOTOUT = 9
const CPX_ALG_PIVOT = 10
const CPX_ALG_FEASOPT = 11
const CPX_ALG_MIP = 12
const CPX_ALG_BENDERS = 13
const CPX_ALG_MULTIOBJ = 14
const CPX_ALG_ROBUST = 15
const CPX_AT_LOWER = 0
const CPX_BASIC = 1
const CPX_AT_UPPER = 2
const CPX_FREE_SUPER = 3
const CPX_NO_VARIABLE = 2100000000
const CPX_CONTINUOUS = 'C'
const CPX_BINARY = 'B'
const CPX_INTEGER = 'I'
const CPX_SEMICONT = 'S'
const CPX_SEMIINT = 'N'
const CPX_PREREDUCE_PRIMALANDDUAL = 3
const CPX_PREREDUCE_DUALONLY = 2
const CPX_PREREDUCE_PRIMALONLY = 1
const CPX_PREREDUCE_NOPRIMALORDUAL = 0
const CPX_PREREFORM_ALL = 3
const CPX_PREREFORM_INTERFERE_CRUSH = 1
const CPX_PREREFORM_INTERFERE_UNCRUSH = 2
const CPX_PREREFORM_NONE = 0
const CPX_CONFLICT_EXCLUDED = -1
const CPX_CONFLICT_POSSIBLE_MEMBER = 0
const CPX_CONFLICT_POSSIBLE_LB = 1
const CPX_CONFLICT_POSSIBLE_UB = 2
const CPX_CONFLICT_MEMBER = 3
const CPX_CONFLICT_LB = 4
const CPX_CONFLICT_UB = 5
const CPX_CONFLICTALG_AUTO = 0
const CPX_CONFLICTALG_FAST = 1
const CPX_CONFLICTALG_PROPAGATE = 2
const CPX_CONFLICTALG_PRESOLVE = 3
const CPX_CONFLICTALG_IIS = 4
const CPX_CONFLICTALG_LIMITSOLVE = 5
const CPX_CONFLICTALG_SOLVE = 6
const CPXPROB_LP = 0
const CPXPROB_MILP = 1
const CPXPROB_FIXEDMILP = 3
const CPXPROB_NODELP = 4
const CPXPROB_QP = 5
const CPXPROB_MIQP = 7
const CPXPROB_FIXEDMIQP = 8
const CPXPROB_NODEQP = 9
const CPXPROB_QCP = 10
const CPXPROB_MIQCP = 11
const CPXPROB_NODEQCP = 12
const CPX_LPREADER_LEGACY = 0
const CPX_LPREADER_NEW = 1
const CPX_PARAM_ALL_MIN = 1000
const CPX_PARAM_ALL_MAX = 6000
const CPX_CALLBACK_PRIMAL = 1
const CPX_CALLBACK_DUAL = 2
const CPX_CALLBACK_NETWORK = 3
const CPX_CALLBACK_PRIMAL_CROSSOVER = 4
const CPX_CALLBACK_DUAL_CROSSOVER = 5
const CPX_CALLBACK_BARRIER = 6
const CPX_CALLBACK_PRESOLVE = 7
const CPX_CALLBACK_QPBARRIER = 8
const CPX_CALLBACK_QPSIMPLEX = 9
const CPX_CALLBACK_TUNING = 10
const CPX_CALLBACK_INFO_PRIMAL_OBJ = 1
const CPX_CALLBACK_INFO_DUAL_OBJ = 2
const CPX_CALLBACK_INFO_PRIMAL_INFMEAS = 3
const CPX_CALLBACK_INFO_DUAL_INFMEAS = 4
const CPX_CALLBACK_INFO_PRIMAL_FEAS = 5
const CPX_CALLBACK_INFO_DUAL_FEAS = 6
const CPX_CALLBACK_INFO_ITCOUNT = 7
const CPX_CALLBACK_INFO_CROSSOVER_PPUSH = 8
const CPX_CALLBACK_INFO_CROSSOVER_PEXCH = 9
const CPX_CALLBACK_INFO_CROSSOVER_DPUSH = 10
const CPX_CALLBACK_INFO_CROSSOVER_DEXCH = 11
const CPX_CALLBACK_INFO_CROSSOVER_SBCNT = 12
const CPX_CALLBACK_INFO_PRESOLVE_ROWSGONE = 13
const CPX_CALLBACK_INFO_PRESOLVE_COLSGONE = 14
const CPX_CALLBACK_INFO_PRESOLVE_AGGSUBST = 15
const CPX_CALLBACK_INFO_PRESOLVE_COEFFS = 16
const CPX_CALLBACK_INFO_USER_PROBLEM = 17
const CPX_CALLBACK_INFO_TUNING_PROGRESS = 18
const CPX_CALLBACK_INFO_ENDTIME = 19
const CPX_CALLBACK_INFO_ITCOUNT_LONG = 20
const CPX_CALLBACK_INFO_CROSSOVER_PPUSH_LONG = 21
const CPX_CALLBACK_INFO_CROSSOVER_PEXCH_LONG = 22
const CPX_CALLBACK_INFO_CROSSOVER_DPUSH_LONG = 23
const CPX_CALLBACK_INFO_CROSSOVER_DEXCH_LONG = 24
const CPX_CALLBACK_INFO_PRESOLVE_AGGSUBST_LONG = 25
const CPX_CALLBACK_INFO_PRESOLVE_COEFFS_LONG = 26
const CPX_CALLBACK_INFO_ENDDETTIME = 27
const CPX_CALLBACK_INFO_STARTTIME = 28
const CPX_CALLBACK_INFO_STARTDETTIME = 29
const CPX_TUNE_AVERAGE = 1
const CPX_TUNE_MINMAX = 2
const CPX_TUNE_ABORT = 1
const CPX_TUNE_TILIM = 2
const CPX_TUNE_DETTILIM = 3
const CPX_FEASOPT_MIN_SUM = 0
const CPX_FEASOPT_OPT_SUM = 1
const CPX_FEASOPT_MIN_INF = 2
const CPX_FEASOPT_OPT_INF = 3
const CPX_FEASOPT_MIN_QUAD = 4
const CPX_FEASOPT_OPT_QUAD = 5
const CPX_BENDERSSTRATEGY_OFF = -1
const CPX_BENDERSSTRATEGY_AUTO = 0
const CPX_BENDERSSTRATEGY_USER = 1
const CPX_BENDERSSTRATEGY_WORKERS = 2
const CPX_BENDERSSTRATEGY_FULL = 3
const CPX_ANNOTATIONDATA_LONG = 1
const CPX_ANNOTATIONDATA_DOUBLE = 2
const CPX_ANNOTATIONOBJ_OBJ = 0
const CPX_ANNOTATIONOBJ_COL = 1
const CPX_ANNOTATIONOBJ_ROW = 2
const CPX_ANNOTATIONOBJ_SOS = 3
const CPX_ANNOTATIONOBJ_IND = 4
const CPX_ANNOTATIONOBJ_QC = 5
const CPX_ANNOTATIONOBJ_LAST = 6
const CPXIIS_COMPLETE = 1
const CPXIIS_PARTIAL = 2
const CPXIIS_AT_LOWER = 0
const CPXIIS_FIXED = 1
const CPXIIS_AT_UPPER = 2
const CPX_BARORDER_AUTO = 0
const CPX_BARORDER_AMD = 1
const CPX_BARORDER_AMF = 2
const CPX_BARORDER_ND = 3
const CPX_MIPEMPHASIS_BALANCED = 0
const CPX_MIPEMPHASIS_FEASIBILITY = 1
const CPX_MIPEMPHASIS_OPTIMALITY = 2
const CPX_MIPEMPHASIS_BESTBOUND = 3
const CPX_MIPEMPHASIS_HIDDENFEAS = 4
const CPX_MIPEMPHASIS_HEURISTIC = 5
const CPX_TYPE_VAR = '0'
const CPX_TYPE_SOS1 = '1'
const CPX_TYPE_SOS2 = '2'
const CPX_TYPE_USER = 'X'
const CPX_TYPE_ANY = 'A'
const CPX_VARSEL_MININFEAS = -1
const CPX_VARSEL_DEFAULT = 0
const CPX_VARSEL_MAXINFEAS = 1
const CPX_VARSEL_PSEUDO = 2
const CPX_VARSEL_STRONG = 3
const CPX_VARSEL_PSEUDOREDUCED = 4
const CPX_NODESEL_DFS = 0
const CPX_NODESEL_BESTBOUND = 1
const CPX_NODESEL_BESTEST = 2
const CPX_NODESEL_BESTEST_ALT = 3
const CPX_MIPORDER_COST = 1
const CPX_MIPORDER_BOUNDS = 2
const CPX_MIPORDER_SCALEDCOST = 3
const CPX_BRANCH_GLOBAL = 0
const CPX_BRANCH_DOWN = -1
const CPX_BRANCH_UP = 1
const CPX_BRDIR_DOWN = -1
const CPX_BRDIR_AUTO = 0
const CPX_BRDIR_UP = 1
const CPX_CUT_COVER = 0
const CPX_CUT_GUBCOVER = 1
const CPX_CUT_FLOWCOVER = 2
const CPX_CUT_CLIQUE = 3
const CPX_CUT_FRAC = 4
const CPX_CUT_MIR = 5
const CPX_CUT_FLOWPATH = 6
const CPX_CUT_DISJ = 7
const CPX_CUT_IMPLBD = 8
const CPX_CUT_ZEROHALF = 9
const CPX_CUT_MCF = 10
const CPX_CUT_LOCALCOVER = 11
const CPX_CUT_TIGHTEN = 12
const CPX_CUT_OBJDISJ = 13
const CPX_CUT_LANDP = 14
const CPX_CUT_USER = 15
const CPX_CUT_TABLE = 16
const CPX_CUT_SOLNPOOL = 17
const CPX_CUT_LOCALIMPLBD = 18
const CPX_CUT_BQP = 19
const CPX_CUT_RLT = 20
const CPX_CUT_BENDERS = 21
const CPX_CUT_NUM_TYPES = 22
const CPX_MIPSEARCH_AUTO = 0
const CPX_MIPSEARCH_TRADITIONAL = 1
const CPX_MIPSEARCH_DYNAMIC = 2
const CPX_MIPKAPPA_OFF = -1
const CPX_MIPKAPPA_AUTO = 0
const CPX_MIPKAPPA_SAMPLE = 1
const CPX_MIPKAPPA_FULL = 2
const CPX_MIPSTART_AUTO = 0
const CPX_MIPSTART_CHECKFEAS = 1
const CPX_MIPSTART_SOLVEFIXED = 2
const CPX_MIPSTART_SOLVEMIP = 3
const CPX_MIPSTART_REPAIR = 4
const CPX_MIPSTART_NOCHECK = 5
const CPX_CALLBACK_MIP = 101
const CPX_CALLBACK_MIP_BRANCH = 102
const CPX_CALLBACK_MIP_NODE = 103
const CPX_CALLBACK_MIP_HEURISTIC = 104
const CPX_CALLBACK_MIP_SOLVE = 105
const CPX_CALLBACK_MIP_CUT_LOOP = 106
const CPX_CALLBACK_MIP_PROBE = 107
const CPX_CALLBACK_MIP_FRACCUT = 108
const CPX_CALLBACK_MIP_DISJCUT = 109
const CPX_CALLBACK_MIP_FLOWMIR = 110
const CPX_CALLBACK_MIP_INCUMBENT_NODESOLN = 111
const CPX_CALLBACK_MIP_DELETENODE = 112
const CPX_CALLBACK_MIP_BRANCH_NOSOLN = 113
const CPX_CALLBACK_MIP_CUT_LAST = 114
const CPX_CALLBACK_MIP_CUT_FEAS = 115
const CPX_CALLBACK_MIP_CUT_UNBD = 116
const CPX_CALLBACK_MIP_INCUMBENT_HEURSOLN = 117
const CPX_CALLBACK_MIP_INCUMBENT_USERSOLN = 118
const CPX_CALLBACK_MIP_INCUMBENT_MIPSTART = 119
const CPX_CALLBACK_INFO_BEST_INTEGER = 101
const CPX_CALLBACK_INFO_BEST_REMAINING = 102
const CPX_CALLBACK_INFO_NODE_COUNT = 103
const CPX_CALLBACK_INFO_NODES_LEFT = 104
const CPX_CALLBACK_INFO_MIP_ITERATIONS = 105
const CPX_CALLBACK_INFO_CUTOFF = 106
const CPX_CALLBACK_INFO_CLIQUE_COUNT = 107
const CPX_CALLBACK_INFO_COVER_COUNT = 108
const CPX_CALLBACK_INFO_MIP_FEAS = 109
const CPX_CALLBACK_INFO_FLOWCOVER_COUNT = 110
const CPX_CALLBACK_INFO_GUBCOVER_COUNT = 111
const CPX_CALLBACK_INFO_IMPLBD_COUNT = 112
const CPX_CALLBACK_INFO_PROBE_PHASE = 113
const CPX_CALLBACK_INFO_PROBE_PROGRESS = 114
const CPX_CALLBACK_INFO_FRACCUT_COUNT = 115
const CPX_CALLBACK_INFO_FRACCUT_PROGRESS = 116
const CPX_CALLBACK_INFO_DISJCUT_COUNT = 117
const CPX_CALLBACK_INFO_DISJCUT_PROGRESS = 118
const CPX_CALLBACK_INFO_FLOWPATH_COUNT = 119
const CPX_CALLBACK_INFO_MIRCUT_COUNT = 120
const CPX_CALLBACK_INFO_FLOWMIR_PROGRESS = 121
const CPX_CALLBACK_INFO_ZEROHALFCUT_COUNT = 122
const CPX_CALLBACK_INFO_MY_THREAD_NUM = 123
const CPX_CALLBACK_INFO_USER_THREADS = 124
const CPX_CALLBACK_INFO_MIP_REL_GAP = 125
const CPX_CALLBACK_INFO_MCFCUT_COUNT = 126
const CPX_CALLBACK_INFO_KAPPA_STABLE = 127
const CPX_CALLBACK_INFO_KAPPA_SUSPICIOUS = 128
const CPX_CALLBACK_INFO_KAPPA_UNSTABLE = 129
const CPX_CALLBACK_INFO_KAPPA_ILLPOSED = 130
const CPX_CALLBACK_INFO_KAPPA_MAX = 131
const CPX_CALLBACK_INFO_KAPPA_ATTENTION = 132
const CPX_CALLBACK_INFO_LANDPCUT_COUNT = 133
const CPX_CALLBACK_INFO_USERCUT_COUNT = 134
const CPX_CALLBACK_INFO_TABLECUT_COUNT = 135
const CPX_CALLBACK_INFO_SOLNPOOLCUT_COUNT = 136
const CPX_CALLBACK_INFO_BENDERS_COUNT = 137
const CPX_CALLBACK_INFO_NODE_COUNT_LONG = 140
const CPX_CALLBACK_INFO_NODES_LEFT_LONG = 141
const CPX_CALLBACK_INFO_MIP_ITERATIONS_LONG = 142
const CPX_CALLBACK_INFO_LAZY_SOURCE = 143
const CPX_CALLBACK_INFO_NODE_SIINF = 201
const CPX_CALLBACK_INFO_NODE_NIINF = 202
const CPX_CALLBACK_INFO_NODE_ESTIMATE = 203
const CPX_CALLBACK_INFO_NODE_DEPTH = 204
const CPX_CALLBACK_INFO_NODE_OBJVAL = 205
const CPX_CALLBACK_INFO_NODE_TYPE = 206
const CPX_CALLBACK_INFO_NODE_VAR = 207
const CPX_CALLBACK_INFO_NODE_SOS = 208
const CPX_CALLBACK_INFO_NODE_SEQNUM = 209
const CPX_CALLBACK_INFO_NODE_USERHANDLE = 210
const CPX_CALLBACK_INFO_NODE_NODENUM = 211
const CPX_CALLBACK_INFO_NODE_SEQNUM_LONG = 220
const CPX_CALLBACK_INFO_NODE_NODENUM_LONG = 221
const CPX_CALLBACK_INFO_NODE_DEPTH_LONG = 222
const CPX_CALLBACK_INFO_SOS_TYPE = 240
const CPX_CALLBACK_INFO_SOS_SIZE = 241
const CPX_CALLBACK_INFO_SOS_IS_FEASIBLE = 242
const CPX_CALLBACK_INFO_SOS_MEMBER_INDEX = 244
const CPX_CALLBACK_INFO_SOS_MEMBER_REFVAL = 246
const CPX_CALLBACK_INFO_SOS_NUM = 247
const CPX_CALLBACK_INFO_IC_NUM = 260
const CPX_CALLBACK_INFO_IC_IMPLYING_VAR = 261
const CPX_CALLBACK_INFO_IC_IMPLIED_VAR = 262
const CPX_CALLBACK_INFO_IC_SENSE = 263
const CPX_CALLBACK_INFO_IC_COMPL = 264
const CPX_CALLBACK_INFO_IC_RHS = 265
const CPX_CALLBACK_INFO_IC_IS_FEASIBLE = 266
const CPX_INCUMBENT_ID = -1
const CPX_RAMPUP_DISABLED = -1
const CPX_RAMPUP_AUTO = 0
const CPX_RAMPUP_DYNAMIC = 1
const CPX_RAMPUP_INFINITE = 2
const CPX_CALLBACK_DEFAULT = 0
const CPX_CALLBACK_FAIL = 1
const CPX_CALLBACK_SET = 2
const CPX_CALLBACK_ABORT_CUT_LOOP = 3
const CPX_USECUT_FORCE = 0
const CPX_USECUT_PURGE = 1
const CPX_USECUT_FILTER = 2
const CPX_INTEGER_FEASIBLE = 0
const CPX_INTEGER_INFEASIBLE = 1
const CPX_IMPLIED_INTEGER_FEASIBLE = 2
const CPX_CON_LOWER_BOUND = 1
const CPX_CON_UPPER_BOUND = 2
const CPX_CON_LINEAR = 3
const CPX_CON_QUADRATIC = 4
const CPX_CON_SOS = 5
const CPX_CON_INDICATOR = 6
const CPX_CON_PWL = 7
const CPX_CON_ABS = 7
const CPX_CON_MINEXPR = 8
const CPX_CON_MAXEXPR = 9
const CPX_CON_LAST_CONTYPE = 10
const CPX_INDICATOR_IF = 1
const CPX_INDICATOR_ONLYIF = 2
const CPX_INDICATOR_IFANDONLYIF = 3
const CPXNET_NO_DISPLAY_OBJECTIVE = 0
const CPXNET_TRUE_OBJECTIVE = 1
const CPXNET_PENALIZED_OBJECTIVE = 2
const CPXNET_PRICE_AUTO = 0
const CPXNET_PRICE_PARTIAL = 1
const CPXNET_PRICE_MULT_PART = 2
const CPXNET_PRICE_SORT_MULT_PART = 3
const CPX_NETFIND_PURE = 1
const CPX_NETFIND_REFLECT = 2
const CPX_NETFIND_SCALE = 3
const CPX_QCPDUALS_NO = 0
const CPX_QCPDUALS_IFPOSSIBLE = 1
const CPX_QCPDUALS_FORCE = 2
const CPX_CPXAUTOCONSTANTS_H_H = 1
const CPX_BENDERS_ANNOTATION = "cpxBendersPartition"
const CPX_BENDERS_MASTERVALUE = 0
const CPX_BIGINT = 2100000000
const CPX_BIGLONG = Int64(9223372036800000000)
const CPX_CALLBACKCONTEXT_BRANCHING = 0x0080
const CPX_CALLBACKCONTEXT_CANDIDATE = 0x0020
const CPX_CALLBACKCONTEXT_GLOBAL_PROGRESS = 0x0010
const CPX_CALLBACKCONTEXT_LOCAL_PROGRESS = 0x0008
const CPX_CALLBACKCONTEXT_RELAXATION = 0x0040
const CPX_CALLBACKCONTEXT_THREAD_DOWN = 0x0004
const CPX_CALLBACKCONTEXT_THREAD_UP = 0x0002
const CPX_DUAL_OBJ = 41
const CPX_EXACT_KAPPA = 51
const CPX_KAPPA = 39
const CPX_KAPPA_ATTENTION = 57
const CPX_KAPPA_ILLPOSED = 55
const CPX_KAPPA_MAX = 56
const CPX_KAPPA_STABLE = 52
const CPX_KAPPA_SUSPICIOUS = 53
const CPX_KAPPA_UNSTABLE = 54
const CPX_LAZYCONSTRAINTCALLBACK_HEUR = CPX_CALLBACK_MIP_INCUMBENT_HEURSOLN
const CPX_LAZYCONSTRAINTCALLBACK_MIPSTART = CPX_CALLBACK_MIP_INCUMBENT_MIPSTART
const CPX_LAZYCONSTRAINTCALLBACK_NODE = CPX_CALLBACK_MIP_INCUMBENT_NODESOLN
const CPX_LAZYCONSTRAINTCALLBACK_USER = CPX_CALLBACK_MIP_INCUMBENT_USERSOLN
const CPX_MAX_COMP_SLACK = 19
const CPX_MAX_DUAL_INFEAS = 5
const CPX_MAX_DUAL_RESIDUAL = 15
const CPX_MAX_INDSLACK_INFEAS = 49
const CPX_MAX_INT_INFEAS = 9
const CPX_MAX_PI = 25
const CPX_MAX_PRIMAL_INFEAS = 1
const CPX_MAX_PRIMAL_RESIDUAL = 11
const CPX_MAX_PWLSLACK_INFEAS = 58
const CPX_MAX_QCPRIMAL_RESIDUAL = 43
const CPX_MAX_QCSLACK = 47
const CPX_MAX_QCSLACK_INFEAS = 45
const CPX_MAX_RED_COST = 29
const CPX_MAX_SCALED_DUAL_INFEAS = 6
const CPX_MAX_SCALED_DUAL_RESIDUAL = 16
const CPX_MAX_SCALED_PI = 26
const CPX_MAX_SCALED_PRIMAL_INFEAS = 2
const CPX_MAX_SCALED_PRIMAL_RESIDUAL = 12
const CPX_MAX_SCALED_RED_COST = 30
const CPX_MAX_SCALED_SLACK = 28
const CPX_MAX_SCALED_X = 24
const CPX_MAX_SLACK = 27
const CPX_MAX_X = 23
const CPX_MULTIOBJ_BARITCNT = 4
const CPX_MULTIOBJ_BESTOBJVAL = 15
const CPX_MULTIOBJ_BLEND = 20
const CPX_MULTIOBJ_DEGCNT = 7
const CPX_MULTIOBJ_DETTIME = 3
const CPX_MULTIOBJ_DEXCH = 13
const CPX_MULTIOBJ_DPUSH = 12
const CPX_MULTIOBJ_ERROR = 0
const CPX_MULTIOBJ_ITCNT = 8
const CPX_MULTIOBJ_METHOD = 18
const CPX_MULTIOBJ_NODECNT = 16
const CPX_MULTIOBJ_NODELEFTCNT = 19
const CPX_MULTIOBJ_OBJVAL = 14
const CPX_MULTIOBJ_PEXCH = 11
const CPX_MULTIOBJ_PHASE1CNT = 9
const CPX_MULTIOBJ_PPUSH = 10
const CPX_MULTIOBJ_PRIORITY = 17
const CPX_MULTIOBJ_SIFTITCNT = 5
const CPX_MULTIOBJ_SIFTPHASE1CNT = 6
const CPX_MULTIOBJ_STATUS = 1
const CPX_MULTIOBJ_TIME = 2
const CPX_NO_ABSTOL_CHANGE = NaN
const CPX_NO_OFFSET_CHANGE = NaN
const CPX_NO_PRIORITY_CHANGE = -1
const CPX_NO_RELTOL_CHANGE = NaN
const CPX_NO_WEIGHT_CHANGE = NaN
const CPX_OBJ_GAP = 40
const CPX_PRIMAL_OBJ = 42
const CPX_RELAXATION_FLAG_NOSOLVE = 0x0001
const CPX_SOLNPOOL_DIV = 2
const CPX_SOLNPOOL_FIFO = 0
const CPX_SOLNPOOL_FILTER_DIVERSITY = 1
const CPX_SOLNPOOL_FILTER_RANGE = 2
const CPX_SOLNPOOL_OBJ = 1
const CPX_STAT_ABORT_DETTIME_LIM = 25
const CPX_STAT_ABORT_DUAL_OBJ_LIM = 22
const CPX_STAT_ABORT_IT_LIM = 10
const CPX_STAT_ABORT_OBJ_LIM = 12
const CPX_STAT_ABORT_PRIM_OBJ_LIM = 21
const CPX_STAT_ABORT_TIME_LIM = 11
const CPX_STAT_ABORT_USER = 13
const CPX_STAT_BENDERS_NUM_BEST = 41
const CPX_STAT_CONFLICT_ABORT_CONTRADICTION = 32
const CPX_STAT_CONFLICT_ABORT_DETTIME_LIM = 39
const CPX_STAT_CONFLICT_ABORT_IT_LIM = 34
const CPX_STAT_CONFLICT_ABORT_MEM_LIM = 37
const CPX_STAT_CONFLICT_ABORT_NODE_LIM = 35
const CPX_STAT_CONFLICT_ABORT_OBJ_LIM = 36
const CPX_STAT_CONFLICT_ABORT_TIME_LIM = 33
const CPX_STAT_CONFLICT_ABORT_USER = 38
const CPX_STAT_CONFLICT_FEASIBLE = 30
const CPX_STAT_CONFLICT_MINIMAL = 31
const CPX_STAT_FEASIBLE = 23
const CPX_STAT_FEASIBLE_RELAXED_INF = 16
const CPX_STAT_FEASIBLE_RELAXED_QUAD = 18
const CPX_STAT_FEASIBLE_RELAXED_SUM = 14
const CPX_STAT_FIRSTORDER = 24
const CPX_STAT_INFEASIBLE = 3
const CPX_STAT_INForUNBD = 4
const CPX_STAT_MULTIOBJ_INFEASIBLE = 302
const CPX_STAT_MULTIOBJ_INForUNBD = 303
const CPX_STAT_MULTIOBJ_NON_OPTIMAL = 305
const CPX_STAT_MULTIOBJ_OPTIMAL = 301
const CPX_STAT_MULTIOBJ_STOPPED = 306
const CPX_STAT_MULTIOBJ_UNBOUNDED = 304
const CPX_STAT_NUM_BEST = 6
const CPX_STAT_OPTIMAL = 1
const CPX_STAT_OPTIMAL_FACE_UNBOUNDED = 20
const CPX_STAT_OPTIMAL_INFEAS = 5
const CPX_STAT_OPTIMAL_RELAXED_INF = 17
const CPX_STAT_OPTIMAL_RELAXED_QUAD = 19
const CPX_STAT_OPTIMAL_RELAXED_SUM = 15
const CPX_STAT_UNBOUNDED = 2
const CPX_SUM_COMP_SLACK = 21
const CPX_SUM_DUAL_INFEAS = 7
const CPX_SUM_DUAL_RESIDUAL = 17
const CPX_SUM_INDSLACK_INFEAS = 50
const CPX_SUM_INT_INFEAS = 10
const CPX_SUM_PI = 33
const CPX_SUM_PRIMAL_INFEAS = 3
const CPX_SUM_PRIMAL_RESIDUAL = 13
const CPX_SUM_PWLSLACK_INFEAS = 59
const CPX_SUM_QCPRIMAL_RESIDUAL = 44
const CPX_SUM_QCSLACK = 48
const CPX_SUM_QCSLACK_INFEAS = 46
const CPX_SUM_RED_COST = 37
const CPX_SUM_SCALED_DUAL_INFEAS = 8
const CPX_SUM_SCALED_DUAL_RESIDUAL = 18
const CPX_SUM_SCALED_PI = 34
const CPX_SUM_SCALED_PRIMAL_INFEAS = 4
const CPX_SUM_SCALED_PRIMAL_RESIDUAL = 14
const CPX_SUM_SCALED_RED_COST = 38
const CPX_SUM_SCALED_SLACK = 36
const CPX_SUM_SCALED_X = 32
const CPX_SUM_SLACK = 35
const CPX_SUM_X = 31
const CPXERR_ABORT_STRONGBRANCH = 1263
const CPXERR_ADJ_SIGN_QUAD = 1606
const CPXERR_ADJ_SIGN_SENSE = 1604
const CPXERR_ADJ_SIGNS = 1602
const CPXERR_ARC_INDEX_RANGE = 1231
const CPXERR_ARRAY_BAD_SOS_TYPE = 3009
const CPXERR_ARRAY_NOT_ASCENDING = 1226
const CPXERR_ARRAY_TOO_LONG = 1208
const CPXERR_BAD_ARGUMENT = 1003
const CPXERR_BAD_BOUND_SENSE = 1622
const CPXERR_BAD_BOUND_TYPE = 1457
const CPXERR_BAD_CHAR = 1537
const CPXERR_BAD_CTYPE = 3021
const CPXERR_BAD_DECOMPOSITION = 2002
const CPXERR_BAD_DIRECTION = 3012
const CPXERR_BAD_EXPO_RANGE = 1435
const CPXERR_BAD_EXPONENT = 1618
const CPXERR_BAD_FILETYPE = 1424
const CPXERR_BAD_ID = 1617
const CPXERR_BAD_INDCONSTR = 1439
const CPXERR_BAD_INDICATOR = 1551
const CPXERR_BAD_INDTYPE = 1216
const CPXERR_BAD_LAZY_UCUT = 1438
const CPXERR_BAD_LUB = 1229
const CPXERR_BAD_METHOD = 1292
const CPXERR_BAD_MULTIOBJ_ATTR = 1488
const CPXERR_BAD_NAME = 1220
const CPXERR_BAD_NUMBER = 1434
const CPXERR_BAD_OBJ_SENSE = 1487
const CPXERR_BAD_PARAM_NAME = 1028
const CPXERR_BAD_PARAM_NUM = 1013
const CPXERR_BAD_PIVOT = 1267
const CPXERR_BAD_PRIORITY = 3006
const CPXERR_BAD_PROB_TYPE = 1022
const CPXERR_BAD_ROW_ID = 1532
const CPXERR_BAD_SECTION_BOUNDS = 1473
const CPXERR_BAD_SECTION_ENDATA = 1462
const CPXERR_BAD_SECTION_QMATRIX = 1475
const CPXERR_BAD_SENSE = 1215
const CPXERR_BAD_SOS_TYPE = 1442
const CPXERR_BAD_STATUS = 1253
const CPXERR_BAS_FILE_SHORT = 1550
const CPXERR_BAS_FILE_SIZE = 1555
const CPXERR_BENDERS_MASTER_SOLVE = 2001
const CPXERR_CALLBACK = 1006
const CPXERR_CALLBACK_INCONSISTENT = 1060
const CPXERR_CAND_NOT_POINT = 3025
const CPXERR_CAND_NOT_RAY = 3026
const CPXERR_CNTRL_IN_NAME = 1236
const CPXERR_COL_INDEX_RANGE = 1201
const CPXERR_COL_REPEAT_PRINT = 1478
const CPXERR_COL_REPEATS = 1446
const CPXERR_COL_ROW_REPEATS = 1443
const CPXERR_COL_UNKNOWN = 1449
const CPXERR_CONFLICT_UNSTABLE = 1720
const CPXERR_COUNT_OVERLAP = 1228
const CPXERR_COUNT_RANGE = 1227
const CPXERR_CPUBINDING_FAILURE = 3700
const CPXERR_DBL_MAX = 1233
const CPXERR_DECOMPRESSION = 1027
const CPXERR_DETTILIM_STRONGBRANCH = 1270
const CPXERR_DUP_ENTRY = 1222
const CPXERR_DYNFUNC = 1815
const CPXERR_DYNLOAD = 1814
const CPXERR_ENCODING_CONVERSION = 1235
const CPXERR_EXTRA_BV_BOUND = 1456
const CPXERR_EXTRA_FR_BOUND = 1455
const CPXERR_EXTRA_FX_BOUND = 1454
const CPXERR_EXTRA_INTEND = 1481
const CPXERR_EXTRA_INTORG = 1480
const CPXERR_EXTRA_SOSEND = 1483
const CPXERR_EXTRA_SOSORG = 1482
const CPXERR_FAIL_OPEN_READ = 1423
const CPXERR_FAIL_OPEN_WRITE = 1422
const CPXERR_FILE_ENTRIES = 1553
const CPXERR_FILE_FORMAT = 1563
const CPXERR_FILE_IO = 1426
const CPXERR_FILTER_VARIABLE_TYPE = 3414
const CPXERR_ILL_DEFINED_PWL = 1213
const CPXERR_IN_INFOCALLBACK = 1804
const CPXERR_INDEX_NOT_BASIC = 1251
const CPXERR_INDEX_RANGE = 1200
const CPXERR_INDEX_RANGE_HIGH = 1206
const CPXERR_INDEX_RANGE_LOW = 1205
const CPXERR_INT_TOO_BIG = 3018
const CPXERR_INT_TOO_BIG_INPUT = 1463
const CPXERR_INVALID_NUMBER = 1650
const CPXERR_LIMITS_TOO_BIG = 1012
const CPXERR_LINE_TOO_LONG = 1465
const CPXERR_LO_BOUND_REPEATS = 1459
const CPXERR_LOCK_CREATE = 1808
const CPXERR_LP_NOT_IN_ENVIRONMENT = 1806
const CPXERR_LP_PARSE = 1427
const CPXERR_MASTER_SOLVE = 2005
const CPXERR_MIPSEARCH_WITH_CALLBACKS = 1805
const CPXERR_MISS_SOS_TYPE = 3301
const CPXERR_MSG_NO_CHANNEL = 1051
const CPXERR_MSG_NO_FILEPTR = 1052
const CPXERR_MSG_NO_FUNCTION = 1053
const CPXERR_MULTIOBJ_SUBPROB_SOLVE = 1300
const CPXERR_MULTIPLE_PROBS_IN_REMOTE_ENVIRONMENT = 1816
const CPXERR_NAME_CREATION = 1209
const CPXERR_NAME_NOT_FOUND = 1210
const CPXERR_NAME_TOO_LONG = 1464
const CPXERR_NAN = 1225
const CPXERR_NEED_OPT_SOLN = 1252
const CPXERR_NEGATIVE_SURPLUS = 1207
const CPXERR_NET_DATA = 1530
const CPXERR_NET_FILE_SHORT = 1538
const CPXERR_NO_BARRIER_SOLN = 1223
const CPXERR_NO_BASIC_SOLN = 1261
const CPXERR_NO_BASIS = 1262
const CPXERR_NO_BOUND_SENSE = 1621
const CPXERR_NO_BOUND_TYPE = 1460
const CPXERR_NO_COLUMNS_SECTION = 1472
const CPXERR_NO_CONFLICT = 1719
const CPXERR_NO_DECOMPOSITION = 2000
const CPXERR_NO_DUAL_SOLN = 1232
const CPXERR_NO_ENDATA = 1552
const CPXERR_NO_ENVIRONMENT = 1002
const CPXERR_NO_FILENAME = 1421
const CPXERR_NO_ID = 1616
const CPXERR_NO_ID_FIRST = 1609
const CPXERR_NO_INT_X = 3023
const CPXERR_NO_KAPPASTATS = 1269
const CPXERR_NO_LU_FACTOR = 1258
const CPXERR_NO_MEMORY = 1001
const CPXERR_NO_MIPSTART = 3020
const CPXERR_NO_NAME_SECTION = 1441
const CPXERR_NO_NAMES = 1219
const CPXERR_NO_NORMS = 1264
const CPXERR_NO_NUMBER = 1615
const CPXERR_NO_NUMBER_BOUND = 1623
const CPXERR_NO_NUMBER_FIRST = 1611
const CPXERR_NO_OBJ_NAME = 1489
const CPXERR_NO_OBJ_SENSE = 1436
const CPXERR_NO_OBJECTIVE = 1476
const CPXERR_NO_OP_OR_SENSE = 1608
const CPXERR_NO_OPERATOR = 1607
const CPXERR_NO_ORDER = 3016
const CPXERR_NO_PROBLEM = 1009
const CPXERR_NO_QP_OPERATOR = 1614
const CPXERR_NO_QUAD_EXP = 1612
const CPXERR_NO_RHS_COEFF = 1610
const CPXERR_NO_RHS_IN_OBJ = 1211
const CPXERR_NO_ROW_NAME = 1486
const CPXERR_NO_ROW_SENSE = 1453
const CPXERR_NO_ROWS_SECTION = 1471
const CPXERR_NO_SENSIT = 1260
const CPXERR_NO_SOLN = 1217
const CPXERR_NO_SOLNPOOL = 3024
const CPXERR_NO_SOS = 3015
const CPXERR_NO_TREE = 3412
const CPXERR_NO_VECTOR_SOLN = 1556
const CPXERR_NODE_INDEX_RANGE = 1230
const CPXERR_NODE_ON_DISK = 3504
const CPXERR_NOT_DUAL_UNBOUNDED = 1265
const CPXERR_NOT_FIXED = 1221
const CPXERR_NOT_FOR_BENDERS = 2004
const CPXERR_NOT_FOR_DISTMIP = 1071
const CPXERR_NOT_FOR_MIP = 1017
const CPXERR_NOT_FOR_MULTIOBJ = 1070
const CPXERR_NOT_FOR_QCP = 1031
const CPXERR_NOT_FOR_QP = 1018
const CPXERR_NOT_MILPCLASS = 1024
const CPXERR_NOT_MIN_COST_FLOW = 1531
const CPXERR_NOT_MIP = 3003
const CPXERR_NOT_MIQPCLASS = 1029
const CPXERR_NOT_ONE_PROBLEM = 1023
const CPXERR_NOT_QP = 5004
const CPXERR_NOT_SAV_FILE = 1560
const CPXERR_NOT_UNBOUNDED = 1254
const CPXERR_NULL_POINTER = 1004
const CPXERR_ORDER_BAD_DIRECTION = 3007
const CPXERR_OVERFLOW = 1810
const CPXERR_PARAM_INCOMPATIBLE = 1807
const CPXERR_PARAM_TOO_BIG = 1015
const CPXERR_PARAM_TOO_SMALL = 1014
const CPXERR_PRESLV_ABORT = 1106
const CPXERR_PRESLV_BAD_PARAM = 1122
const CPXERR_PRESLV_BASIS_MEM = 1107
const CPXERR_PRESLV_COPYORDER = 1109
const CPXERR_PRESLV_COPYSOS = 1108
const CPXERR_PRESLV_CRUSHFORM = 1121
const CPXERR_PRESLV_DETTIME_LIM = 1124
const CPXERR_PRESLV_DUAL = 1119
const CPXERR_PRESLV_FAIL_BASIS = 1114
const CPXERR_PRESLV_INF = 1117
const CPXERR_PRESLV_INForUNBD = 1101
const CPXERR_PRESLV_NO_BASIS = 1115
const CPXERR_PRESLV_NO_PROB = 1103
const CPXERR_PRESLV_SOLN_MIP = 1110
const CPXERR_PRESLV_SOLN_QP = 1111
const CPXERR_PRESLV_START_LP = 1112
const CPXERR_PRESLV_TIME_LIM = 1123
const CPXERR_PRESLV_UNBD = 1118
const CPXERR_PRESLV_UNCRUSHFORM = 1120
const CPXERR_PRIIND = 1257
const CPXERR_PRM_DATA = 1660
const CPXERR_PROTOCOL = 1812
const CPXERR_Q_DIVISOR = 1619
const CPXERR_Q_DUP_ENTRY = 5011
const CPXERR_Q_NOT_INDEF = 5014
const CPXERR_Q_NOT_POS_DEF = 5002
const CPXERR_Q_NOT_SYMMETRIC = 5012
const CPXERR_QCP_SENSE = 6002
const CPXERR_QCP_SENSE_FILE = 1437
const CPXERR_QUAD_EXP_NOT_2 = 1613
const CPXERR_QUAD_IN_ROW = 1605
const CPXERR_RANGE_SECTION_ORDER = 1474
const CPXERR_RESTRICTED_VERSION = 1016
const CPXERR_RHS_IN_OBJ = 1603
const CPXERR_RIM_REPEATS = 1447
const CPXERR_RIM_ROW_REPEATS = 1444
const CPXERR_RIMNZ_REPEATS = 1479
const CPXERR_ROW_INDEX_RANGE = 1203
const CPXERR_ROW_REPEAT_PRINT = 1477
const CPXERR_ROW_REPEATS = 1445
const CPXERR_ROW_UNKNOWN = 1448
const CPXERR_SAV_FILE_DATA = 1561
const CPXERR_SAV_FILE_VALUE = 1564
const CPXERR_SAV_FILE_WRITE = 1562
const CPXERR_SBASE_ILLEGAL = 1554
const CPXERR_SBASE_INCOMPAT = 1255
const CPXERR_SINGULAR = 1256
const CPXERR_STR_PARAM_TOO_LONG = 1026
const CPXERR_SUBPROB_SOLVE = 3019
const CPXERR_SYNCPRIM_CREATE = 1809
const CPXERR_SYSCALL = 1813
const CPXERR_THREAD_FAILED = 1234
const CPXERR_TILIM_CONDITION_NO = 1268
const CPXERR_TILIM_STRONGBRANCH = 1266
const CPXERR_TOO_MANY_COEFFS = 1433
const CPXERR_TOO_MANY_COLS = 1432
const CPXERR_TOO_MANY_RIMNZ = 1485
const CPXERR_TOO_MANY_RIMS = 1484
const CPXERR_TOO_MANY_ROWS = 1431
const CPXERR_TOO_MANY_THREADS = 1020
const CPXERR_TREE_MEMORY_LIMIT = 3413
const CPXERR_TUNE_MIXED = 1730
const CPXERR_UNIQUE_WEIGHTS = 3010
const CPXERR_UNSUPPORTED_CONSTRAINT_TYPE = 1212
const CPXERR_UNSUPPORTED_OPERATION = 1811
const CPXERR_UP_BOUND_REPEATS = 1458
const CPXERR_WORK_FILE_OPEN = 1801
const CPXERR_WORK_FILE_READ = 1802
const CPXERR_WORK_FILE_WRITE = 1803
const CPXERR_XMLPARSE = 1425
const CPXMESSAGEBUFSIZE = 1024
const CPXMI_BIGM_COEF = 1040
const CPXMI_BIGM_TO_IND = 1041
const CPXMI_BIGM_VARBOUND = 1042
const CPXMI_CANCEL_TOL = 1045
const CPXMI_EPGAP_LARGE = 1038
const CPXMI_EPGAP_OBJOFFSET = 1037
const CPXMI_FEAS_TOL = 1043
const CPXMI_FRACTION_SCALING = 1047
const CPXMI_IND_NZ_LARGE_NUM = 1019
const CPXMI_IND_NZ_SMALL_NUM = 1020
const CPXMI_IND_RHS_LARGE_NUM = 1021
const CPXMI_IND_RHS_SMALL_NUM = 1022
const CPXMI_KAPPA_ILLPOSED = 1035
const CPXMI_KAPPA_SUSPICIOUS = 1033
const CPXMI_KAPPA_UNSTABLE = 1034
const CPXMI_LB_LARGE_NUM = 1003
const CPXMI_LB_SMALL_NUM = 1004
const CPXMI_LC_NZ_LARGE_NUM = 1023
const CPXMI_LC_NZ_SMALL_NUM = 1024
const CPXMI_LC_RHS_LARGE_NUM = 1025
const CPXMI_LC_RHS_SMALL_NUM = 1026
const CPXMI_MULTIOBJ_COEFFS = 1062
const CPXMI_MULTIOBJ_LARGE_NUM = 1058
const CPXMI_MULTIOBJ_MIX = 1063
const CPXMI_MULTIOBJ_OPT_TOL = 1060
const CPXMI_MULTIOBJ_SMALL_NUM = 1059
const CPXMI_NZ_LARGE_NUM = 1009
const CPXMI_NZ_SMALL_NUM = 1010
const CPXMI_OBJ_LARGE_NUM = 1001
const CPXMI_OBJ_SMALL_NUM = 1002
const CPXMI_OPT_TOL = 1044
const CPXMI_PWL_SLOPE_LARGE_NUM = 1064
const CPXMI_PWL_SLOPE_SMALL_NUM = 1065
const CPXMI_QC_LINNZ_LARGE_NUM = 1015
const CPXMI_QC_LINNZ_SMALL_NUM = 1016
const CPXMI_QC_QNZ_LARGE_NUM = 1017
const CPXMI_QC_QNZ_SMALL_NUM = 1018
const CPXMI_QC_RHS_LARGE_NUM = 1013
const CPXMI_QC_RHS_SMALL_NUM = 1014
const CPXMI_QOBJ_LARGE_NUM = 1011
const CPXMI_QOBJ_SMALL_NUM = 1012
const CPXMI_QOPT_TOL = 1046
const CPXMI_RHS_LARGE_NUM = 1007
const CPXMI_RHS_SMALL_NUM = 1008
const CPXMI_SAMECOEFF_COL = 1050
const CPXMI_SAMECOEFF_IND = 1051
const CPXMI_SAMECOEFF_LAZY = 1054
const CPXMI_SAMECOEFF_MULTIOBJ = 1061
const CPXMI_SAMECOEFF_OBJ = 1057
const CPXMI_SAMECOEFF_QLIN = 1052
const CPXMI_SAMECOEFF_QUAD = 1053
const CPXMI_SAMECOEFF_RHS = 1056
const CPXMI_SAMECOEFF_ROW = 1049
const CPXMI_SAMECOEFF_UCUT = 1055
const CPXMI_SINGLE_PRECISION = 1036
const CPXMI_SYMMETRY_BREAKING_INEQ = 1039
const CPXMI_UB_LARGE_NUM = 1005
const CPXMI_UB_SMALL_NUM = 1006
const CPXMI_UC_NZ_LARGE_NUM = 1027
const CPXMI_UC_NZ_SMALL_NUM = 1028
const CPXMI_UC_RHS_LARGE_NUM = 1029
const CPXMI_UC_RHS_SMALL_NUM = 1030
const CPXMI_WIDE_COEFF_RANGE = 1048
const CPXMIP_ABORT_FEAS = 113
const CPXMIP_ABORT_INFEAS = 114
const CPXMIP_ABORT_RELAXATION_UNBOUNDED = 133
const CPXMIP_ABORT_RELAXED = 126
const CPXMIP_DETTIME_LIM_FEAS = 131
const CPXMIP_DETTIME_LIM_INFEAS = 132
const CPXMIP_FAIL_FEAS = 109
const CPXMIP_FAIL_FEAS_NO_TREE = 116
const CPXMIP_FAIL_INFEAS = 110
const CPXMIP_FAIL_INFEAS_NO_TREE = 117
const CPXMIP_FEASIBLE = 127
const CPXMIP_FEASIBLE_RELAXED_INF = 122
const CPXMIP_FEASIBLE_RELAXED_QUAD = 124
const CPXMIP_FEASIBLE_RELAXED_SUM = 120
const CPXMIP_INFEASIBLE = 103
const CPXMIP_INForUNBD = 119
const CPXMIP_MEM_LIM_FEAS = 111
const CPXMIP_MEM_LIM_INFEAS = 112
const CPXMIP_NODE_LIM_FEAS = 105
const CPXMIP_NODE_LIM_INFEAS = 106
const CPXMIP_OPTIMAL = 101
const CPXMIP_OPTIMAL_INFEAS = 115
const CPXMIP_OPTIMAL_POPULATED = 129
const CPXMIP_OPTIMAL_POPULATED_TOL = 130
const CPXMIP_OPTIMAL_RELAXED_INF = 123
const CPXMIP_OPTIMAL_RELAXED_QUAD = 125
const CPXMIP_OPTIMAL_RELAXED_SUM = 121
const CPXMIP_OPTIMAL_TOL = 102
const CPXMIP_POPULATESOL_LIM = 128
const CPXMIP_SOL_LIM = 104
const CPXMIP_TIME_LIM_FEAS = 107
const CPXMIP_TIME_LIM_INFEAS = 108
const CPXMIP_UNBOUNDED = 118
const CPX_CPXAUTOENUMS_H_H = 1
const CPXPARAM_H = 1
const CPXPARAM_Advance = 1001
const CPXPARAM_Barrier_Algorithm = 3007
const CPXPARAM_Barrier_ColNonzeros = 3009
const CPXPARAM_Barrier_ConvergeTol = 3002
const CPXPARAM_Barrier_Crossover = 3018
const CPXPARAM_Barrier_Display = 3010
const CPXPARAM_Barrier_Limits_Corrections = 3013
const CPXPARAM_Barrier_Limits_Growth = 3003
const CPXPARAM_Barrier_Limits_Iteration = 3012
const CPXPARAM_Barrier_Limits_ObjRange = 3004
const CPXPARAM_Barrier_Ordering = 3014
const CPXPARAM_Barrier_QCPConvergeTol = 3020
const CPXPARAM_Barrier_StartAlg = 3017
const CPXPARAM_Benders_Strategy = 1501
const CPXPARAM_Benders_Tolerances_feasibilitycut = 1509
const CPXPARAM_Benders_Tolerances_FeasibilityCut = 1509
const CPXPARAM_Benders_Tolerances_optimalitycut = 1510
const CPXPARAM_Benders_Tolerances_OptimalityCut = 1510
const CPXPARAM_Benders_WorkerAlgorithm = 1500
const CPXPARAM_ClockType = 1006
const CPXPARAM_Conflict_Algorithm = 1073
const CPXPARAM_Conflict_Display = 1074
const CPXPARAM_CPUmask = 1144
const CPXPARAM_DetTimeLimit = 1127
const CPXPARAM_DistMIP_Rampup_DetTimeLimit = 2164
const CPXPARAM_DistMIP_Rampup_Duration = 2163
const CPXPARAM_DistMIP_Rampup_TimeLimit = 2165
const CPXPARAM_Emphasis_Memory = 1082
const CPXPARAM_Emphasis_MIP = 2058
const CPXPARAM_Emphasis_Numerical = 1083
const CPXPARAM_Feasopt_Mode = 1084
const CPXPARAM_Feasopt_Tolerance = 2073
const CPXPARAM_LPMethod = 1062
const CPXPARAM_MIP_Cuts_BQP = 2195
const CPXPARAM_MIP_Cuts_Cliques = 2003
const CPXPARAM_MIP_Cuts_Covers = 2005
const CPXPARAM_MIP_Cuts_Disjunctive = 2053
const CPXPARAM_MIP_Cuts_FlowCovers = 2040
const CPXPARAM_MIP_Cuts_Gomory = 2049
const CPXPARAM_MIP_Cuts_GUBCovers = 2044
const CPXPARAM_MIP_Cuts_Implied = 2041
const CPXPARAM_MIP_Cuts_LiftProj = 2152
const CPXPARAM_MIP_Cuts_LocalImplied = 2181
const CPXPARAM_MIP_Cuts_MCFCut = 2134
const CPXPARAM_MIP_Cuts_MIRCut = 2052
const CPXPARAM_MIP_Cuts_Nodecuts = 2157
const CPXPARAM_MIP_Cuts_PathCut = 2051
const CPXPARAM_MIP_Cuts_RLT = 2196
const CPXPARAM_MIP_Cuts_ZeroHalfCut = 2111
const CPXPARAM_MIP_Display = 2012
const CPXPARAM_MIP_Interval = 2013
const CPXPARAM_MIP_Limits_AggForCut = 2054
const CPXPARAM_MIP_Limits_AuxRootThreads = 2139
const CPXPARAM_MIP_Limits_CutPasses = 2056
const CPXPARAM_MIP_Limits_CutsFactor = 2033
const CPXPARAM_MIP_Limits_EachCutLimit = 2102
const CPXPARAM_MIP_Limits_GomoryCand = 2048
const CPXPARAM_MIP_Limits_GomoryPass = 2050
const CPXPARAM_MIP_Limits_Nodes = 2017
const CPXPARAM_MIP_Limits_PolishTime = 2066
const CPXPARAM_MIP_Limits_Populate = 2108
const CPXPARAM_MIP_Limits_ProbeDetTime = 2150
const CPXPARAM_MIP_Limits_ProbeTime = 2065
const CPXPARAM_MIP_Limits_RepairTries = 2067
const CPXPARAM_MIP_Limits_Solutions = 2015
const CPXPARAM_MIP_Limits_StrongCand = 2045
const CPXPARAM_MIP_Limits_StrongIt = 2046
const CPXPARAM_MIP_Limits_TreeMemory = 2027
const CPXPARAM_MIP_OrderType = 2032
const CPXPARAM_MIP_PolishAfter_AbsMIPGap = 2126
const CPXPARAM_MIP_PolishAfter_DetTime = 2151
const CPXPARAM_MIP_PolishAfter_MIPGap = 2127
const CPXPARAM_MIP_PolishAfter_Nodes = 2128
const CPXPARAM_MIP_PolishAfter_Solutions = 2129
const CPXPARAM_MIP_PolishAfter_Time = 2130
const CPXPARAM_MIP_Pool_AbsGap = 2106
const CPXPARAM_MIP_Pool_Capacity = 2103
const CPXPARAM_MIP_Pool_Intensity = 2107
const CPXPARAM_MIP_Pool_RelGap = 2105
const CPXPARAM_MIP_Pool_Replace = 2104
const CPXPARAM_MIP_Strategy_Backtrack = 2002
const CPXPARAM_MIP_Strategy_BBInterval = 2039
const CPXPARAM_MIP_Strategy_Branch = 2001
const CPXPARAM_MIP_Strategy_CallbackReducedLP = 2055
const CPXPARAM_MIP_Strategy_Dive = 2060
const CPXPARAM_MIP_Strategy_File = 2016
const CPXPARAM_MIP_Strategy_FPHeur = 2098
const CPXPARAM_MIP_Strategy_HeuristicEffort = 2120
const CPXPARAM_MIP_Strategy_HeuristicFreq = 2031
const CPXPARAM_MIP_Strategy_KappaStats = 2137
const CPXPARAM_MIP_Strategy_LBHeur = 2063
const CPXPARAM_MIP_Strategy_MIQCPStrat = 2110
const CPXPARAM_MIP_Strategy_NodeSelect = 2018
const CPXPARAM_MIP_Strategy_Order = 2020
const CPXPARAM_MIP_Strategy_PresolveNode = 2037
const CPXPARAM_MIP_Strategy_Probe = 2042
const CPXPARAM_MIP_Strategy_RINSHeur = 2061
const CPXPARAM_MIP_Strategy_Search = 2109
const CPXPARAM_MIP_Strategy_StartAlgorithm = 2025
const CPXPARAM_MIP_Strategy_SubAlgorithm = 2026
const CPXPARAM_MIP_Strategy_VariableSelect = 2028
const CPXPARAM_MIP_SubMIP_StartAlg = 2205
const CPXPARAM_MIP_SubMIP_SubAlg = 2206
const CPXPARAM_MIP_SubMIP_NodeLimit = 2212
const CPXPARAM_MIP_SubMIP_Scale = 2207
const CPXPARAM_MIP_Tolerances_AbsMIPGap = 2008
const CPXPARAM_MIP_Tolerances_Linearization = 2068
const CPXPARAM_MIP_Tolerances_Integrality = 2010
const CPXPARAM_MIP_Tolerances_LowerCutoff = 2006
const CPXPARAM_MIP_Tolerances_MIPGap = 2009
const CPXPARAM_MIP_Tolerances_ObjDifference = 2019
const CPXPARAM_MIP_Tolerances_RelObjDifference = 2022
const CPXPARAM_MIP_Tolerances_UpperCutoff = 2007
const CPXPARAM_MultiObjective_Display = 1600
const CPXPARAM_Network_Display = 5005
const CPXPARAM_Network_Iterations = 5001
const CPXPARAM_Network_NetFind = 1022
const CPXPARAM_Network_Pricing = 5004
const CPXPARAM_Network_Tolerances_Feasibility = 5003
const CPXPARAM_Network_Tolerances_Optimality = 5002
const CPXPARAM_OptimalityTarget = 1131
const CPXPARAM_Output_CloneLog = 1132
const CPXPARAM_Output_IntSolFilePrefix = 2143
const CPXPARAM_Output_MPSLong = 1081
const CPXPARAM_Output_WriteLevel = 1114
const CPXPARAM_Parallel = 1109
const CPXPARAM_ParamDisplay = 1163
const CPXPARAM_Preprocessing_Aggregator = 1003
const CPXPARAM_Preprocessing_BoundStrength = 2029
const CPXPARAM_Preprocessing_CoeffReduce = 2004
const CPXPARAM_Preprocessing_Dependency = 1008
const CPXPARAM_Preprocessing_Dual = 1044
const CPXPARAM_Preprocessing_Fill = 1002
const CPXPARAM_Preprocessing_Folding = 1164
const CPXPARAM_Preprocessing_Linear = 1058
const CPXPARAM_Preprocessing_NumPass = 1052
const CPXPARAM_Preprocessing_Presolve = 1030
const CPXPARAM_Preprocessing_QCPDuals = 4003
const CPXPARAM_Preprocessing_QPMakePSD = 4010
const CPXPARAM_Preprocessing_QToLin = 4012
const CPXPARAM_Preprocessing_Reduce = 1057
const CPXPARAM_Preprocessing_Reformulations = 1167
const CPXPARAM_Preprocessing_Relax = 2034
const CPXPARAM_Preprocessing_RepeatPresolve = 2064
const CPXPARAM_Preprocessing_SOS1Reform = 2230
const CPXPARAM_Preprocessing_SOS2Reform = 2231
const CPXPARAM_Preprocessing_Symmetry = 2059
const CPXPARAM_QPMethod = 1063
const CPXPARAM_RandomSeed = 1124
const CPXPARAM_Read_APIEncoding = 1130
const CPXPARAM_Read_Constraints = 1021
const CPXPARAM_Read_DataCheck = 1056
const CPXPARAM_Read_FileEncoding = 1129
const CPXPARAM_Read_Nonzeros = 1024
const CPXPARAM_Read_QPNonzeros = 4001
const CPXPARAM_Read_Scale = 1034
const CPXPARAM_Read_Variables = 1023
const CPXPARAM_Read_WarningLimit = 1157
const CPXPARAM_Record = 1162
const CPXPARAM_ScreenOutput = 1035
const CPXPARAM_Sifting_Algorithm = 1077
const CPXPARAM_Sifting_Simplex = 1158
const CPXPARAM_Sifting_Display = 1076
const CPXPARAM_Sifting_Iterations = 1078
const CPXPARAM_Simplex_Crash = 1007
const CPXPARAM_Simplex_DGradient = 1009
const CPXPARAM_Simplex_Display = 1019
const CPXPARAM_Simplex_DynamicRows = 1161
const CPXPARAM_Simplex_Limits_Iterations = 1020
const CPXPARAM_Simplex_Limits_LowerObj = 1025
const CPXPARAM_Simplex_Limits_Perturbation = 1028
const CPXPARAM_Simplex_Limits_Singularity = 1037
const CPXPARAM_Simplex_Limits_UpperObj = 1026
const CPXPARAM_Simplex_Perturbation_Constant = 1015
const CPXPARAM_Simplex_Perturbation_Indicator = 1027
const CPXPARAM_Simplex_PGradient = 1029
const CPXPARAM_Simplex_Pricing = 1010
const CPXPARAM_Simplex_Refactor = 1031
const CPXPARAM_Simplex_Tolerances_Feasibility = 1016
const CPXPARAM_Simplex_Tolerances_Markowitz = 1013
const CPXPARAM_Simplex_Tolerances_Optimality = 1014
const CPXPARAM_SolutionType = 1147
const CPXPARAM_Threads = 1067
const CPXPARAM_TimeLimit = 1039
const CPXPARAM_Tune_DetTimeLimit = 1139
const CPXPARAM_Tune_Display = 1113
const CPXPARAM_Tune_Measure = 1110
const CPXPARAM_Tune_Repeat = 1111
const CPXPARAM_Tune_TimeLimit = 1112
const CPXPARAM_WorkDir = 1064
const CPXPARAM_WorkMem = 1065
const CPXPUBLICPARAMS_H = 1
const CPX_PARAM_ADVIND = 1001
const CPX_PARAM_AGGFILL = 1002
const CPX_PARAM_AGGIND = 1003
const CPX_PARAM_CLOCKTYPE = 1006
const CPX_PARAM_CRAIND = 1007
const CPX_PARAM_DEPIND = 1008
const CPX_PARAM_DPRIIND = 1009
const CPX_PARAM_PRICELIM = 1010
const CPX_PARAM_EPMRK = 1013
const CPX_PARAM_EPOPT = 1014
const CPX_PARAM_EPPER = 1015
const CPX_PARAM_EPRHS = 1016
const CPX_PARAM_SIMDISPLAY = 1019
const CPX_PARAM_ITLIM = 1020
const CPX_PARAM_ROWREADLIM = 1021
const CPX_PARAM_NETFIND = 1022
const CPX_PARAM_COLREADLIM = 1023
const CPX_PARAM_NZREADLIM = 1024
const CPX_PARAM_OBJLLIM = 1025
const CPX_PARAM_OBJULIM = 1026
const CPX_PARAM_PERIND = 1027
const CPX_PARAM_PERLIM = 1028
const CPX_PARAM_PPRIIND = 1029
const CPX_PARAM_PREIND = 1030
const CPX_PARAM_REINV = 1031
const CPX_PARAM_SCAIND = 1034
const CPX_PARAM_SCRIND = 1035
const CPX_PARAM_SINGLIM = 1037
const CPX_PARAM_TILIM = 1039
const CPX_PARAM_PREDUAL = 1044
const CPX_PARAM_PREPASS = 1052
const CPX_PARAM_DATACHECK = 1056
const CPX_PARAM_REDUCE = 1057
const CPX_PARAM_PRELINEAR = 1058
const CPX_PARAM_LPMETHOD = 1062
const CPX_PARAM_QPMETHOD = 1063
const CPX_PARAM_WORKDIR = 1064
const CPX_PARAM_WORKMEM = 1065
const CPX_PARAM_THREADS = 1067
const CPX_PARAM_CONFLICTALG = 1073
const CPX_PARAM_CONFLICTDISPLAY = 1074
const CPX_PARAM_SIFTDISPLAY = 1076
const CPX_PARAM_SIFTALG = 1077
const CPX_PARAM_SIFTITLIM = 1078
const CPX_PARAM_MPSLONGNUM = 1081
const CPX_PARAM_MEMORYEMPHASIS = 1082
const CPX_PARAM_NUMERICALEMPHASIS = 1083
const CPX_PARAM_FEASOPTMODE = 1084
const CPX_PARAM_PARALLELMODE = 1109
const CPX_PARAM_TUNINGMEASURE = 1110
const CPX_PARAM_TUNINGREPEAT = 1111
const CPX_PARAM_TUNINGTILIM = 1112
const CPX_PARAM_TUNINGDISPLAY = 1113
const CPX_PARAM_WRITELEVEL = 1114
const CPX_PARAM_RANDOMSEED = 1124
const CPX_PARAM_DETTILIM = 1127
const CPX_PARAM_FILEENCODING = 1129
const CPX_PARAM_APIENCODING = 1130
const CPX_PARAM_OPTIMALITYTARGET = 1131
const CPX_PARAM_CLONELOG = 1132
const CPX_PARAM_TUNINGDETTILIM = 1139
const CPX_PARAM_CPUMASK = 1144
const CPX_PARAM_SOLUTIONTYPE = 1147
const CPX_PARAM_WARNLIM = 1157
const CPX_PARAM_SIFTSIM = 1158
const CPX_PARAM_DYNAMICROWS = 1161
const CPX_PARAM_RECORD = 1162
const CPX_PARAM_PARAMDISPLAY = 1163
const CPX_PARAM_FOLDING = 1164
const CPX_PARAM_PREREFORM = 1167
const CPX_PARAM_WORKERALG = 1500
const CPX_PARAM_BENDERSSTRATEGY = 1501
const CPX_PARAM_BENDERSFEASCUTTOL = 1509
const CPX_PARAM_BENDERSOPTCUTTOL = 1510
const CPX_PARAM_MULTIOBJDISPLAY = 1600
const CPX_PARAM_BRDIR = 2001
const CPX_PARAM_BTTOL = 2002
const CPX_PARAM_CLIQUES = 2003
const CPX_PARAM_COEREDIND = 2004
const CPX_PARAM_COVERS = 2005
const CPX_PARAM_CUTLO = 2006
const CPX_PARAM_CUTUP = 2007
const CPX_PARAM_EPAGAP = 2008
const CPX_PARAM_EPGAP = 2009
const CPX_PARAM_EPINT = 2010
const CPX_PARAM_MIPDISPLAY = 2012
const CPX_PARAM_MIPINTERVAL = 2013
const CPX_PARAM_INTSOLLIM = 2015
const CPX_PARAM_NODEFILEIND = 2016
const CPX_PARAM_NODELIM = 2017
const CPX_PARAM_NODESEL = 2018
const CPX_PARAM_OBJDIF = 2019
const CPX_PARAM_MIPORDIND = 2020
const CPX_PARAM_RELOBJDIF = 2022
const CPX_PARAM_STARTALG = 2025
const CPX_PARAM_SUBALG = 2026
const CPX_PARAM_TRELIM = 2027
const CPX_PARAM_VARSEL = 2028
const CPX_PARAM_BNDSTRENIND = 2029
const CPX_PARAM_HEURFREQ = 2031
const CPX_PARAM_MIPORDTYPE = 2032
const CPX_PARAM_CUTSFACTOR = 2033
const CPX_PARAM_RELAXPREIND = 2034
const CPX_PARAM_PRESLVND = 2037
const CPX_PARAM_BBINTERVAL = 2039
const CPX_PARAM_FLOWCOVERS = 2040
const CPX_PARAM_IMPLBD = 2041
const CPX_PARAM_PROBE = 2042
const CPX_PARAM_GUBCOVERS = 2044
const CPX_PARAM_STRONGCANDLIM = 2045
const CPX_PARAM_STRONGITLIM = 2046
const CPX_PARAM_FRACCAND = 2048
const CPX_PARAM_FRACCUTS = 2049
const CPX_PARAM_FRACPASS = 2050
const CPX_PARAM_FLOWPATHS = 2051
const CPX_PARAM_MIRCUTS = 2052
const CPX_PARAM_DISJCUTS = 2053
const CPX_PARAM_AGGCUTLIM = 2054
const CPX_PARAM_MIPCBREDLP = 2055
const CPX_PARAM_CUTPASS = 2056
const CPX_PARAM_MIPEMPHASIS = 2058
const CPX_PARAM_SYMMETRY = 2059
const CPX_PARAM_DIVETYPE = 2060
const CPX_PARAM_RINSHEUR = 2061
const CPX_PARAM_LBHEUR = 2063
const CPX_PARAM_REPEATPRESOLVE = 2064
const CPX_PARAM_PROBETIME = 2065
const CPX_PARAM_POLISHTIME = 2066
const CPX_PARAM_REPAIRTRIES = 2067
const CPX_PARAM_EPLIN = 2068
const CPX_PARAM_EPRELAX = 2073
const CPX_PARAM_FPHEUR = 2098
const CPX_PARAM_EACHCUTLIM = 2102
const CPX_PARAM_SOLNPOOLCAPACITY = 2103
const CPX_PARAM_SOLNPOOLREPLACE = 2104
const CPX_PARAM_SOLNPOOLGAP = 2105
const CPX_PARAM_SOLNPOOLAGAP = 2106
const CPX_PARAM_SOLNPOOLINTENSITY = 2107
const CPX_PARAM_POPULATELIM = 2108
const CPX_PARAM_MIPSEARCH = 2109
const CPX_PARAM_MIQCPSTRAT = 2110
const CPX_PARAM_ZEROHALFCUTS = 2111
const CPX_PARAM_HEUREFFORT = 2120
const CPX_PARAM_POLISHAFTEREPAGAP = 2126
const CPX_PARAM_POLISHAFTEREPGAP = 2127
const CPX_PARAM_POLISHAFTERNODE = 2128
const CPX_PARAM_POLISHAFTERINTSOL = 2129
const CPX_PARAM_POLISHAFTERTIME = 2130
const CPX_PARAM_MCFCUTS = 2134
const CPX_PARAM_MIPKAPPASTATS = 2137
const CPX_PARAM_AUXROOTTHREADS = 2139
const CPX_PARAM_INTSOLFILEPREFIX = 2143
const CPX_PARAM_PROBEDETTIME = 2150
const CPX_PARAM_POLISHAFTERDETTIME = 2151
const CPX_PARAM_LANDPCUTS = 2152
const CPX_PARAM_NODECUTS = 2157
const CPX_PARAM_RAMPUPDURATION = 2163
const CPX_PARAM_RAMPUPDETTILIM = 2164
const CPX_PARAM_RAMPUPTILIM = 2165
const CPX_PARAM_LOCALIMPLBD = 2181
const CPX_PARAM_BQPCUTS = 2195
const CPX_PARAM_RLTCUTS = 2196
const CPX_PARAM_SUBMIPSTARTALG = 2205
const CPX_PARAM_SUBMIPSUBALG = 2206
const CPX_PARAM_SUBMIPSCAIND = 2207
const CPX_PARAM_SUBMIPNODELIMIT = 2212
const CPX_PARAM_SOS1REFORM = 2230
const CPX_PARAM_SOS2REFORM = 2231
const CPX_PARAM_BAREPCOMP = 3002
const CPX_PARAM_BARGROWTH = 3003
const CPX_PARAM_BAROBJRNG = 3004
const CPX_PARAM_BARALG = 3007
const CPX_PARAM_BARCOLNZ = 3009
const CPX_PARAM_BARDISPLAY = 3010
const CPX_PARAM_BARITLIM = 3012
const CPX_PARAM_BARMAXCOR = 3013
const CPX_PARAM_BARORDER = 3014
const CPX_PARAM_BARSTARTALG = 3017
const CPX_PARAM_BARCROSSALG = 3018
const CPX_PARAM_BARQCPEPCOMP = 3020
const CPX_PARAM_QPNZREADLIM = 4001
const CPX_PARAM_CALCQCPDUALS = 4003
const CPX_PARAM_QPMAKEPSDIND = 4010
const CPX_PARAM_QTOLININD = 4012
const CPX_PARAM_NETITLIM = 5001
const CPX_PARAM_NETEPOPT = 5002
const CPX_PARAM_NETEPRHS = 5003
const CPX_PARAM_NETPPRIIND = 5004
const CPX_PARAM_NETDISPLAY = 5005
const CPX_CPXAUTOTYPES_H_H = 1
const CPX_CPXAUTOSTRUCTS_H_H = 1
const CPXBYTE = UInt8
const CPXINT = Cint
const CPXLONG = Clonglong
const CPXSHORT = Int16
const CPXSIZE = CPXLONG
const CPXULONG = Culonglong
const CPXBYTE_TEST = NTuple{1, Cint}
const CPXSHORT_TEST = NTuple{1, Cint}
const CPXINT_TEST = NTuple{1, Cint}
const CPXLONG_TEST = NTuple{1, Cint}
const CPXULONG_TEST = NTuple{1, Cint}
const CPXSIZE_BITS_TEST = NTuple{1, Cint}
const cpxenv = Cvoid
const CPXENVptr = Ptr{cpxenv}
const CPXCENVptr = Ptr{cpxenv}
const cpxchannel = Cvoid
const CPXCHANNELptr = Ptr{cpxchannel}
const paramset = Cvoid
const CPXPARAMSETptr = Ptr{paramset}
const CPXCPARAMSETptr = Ptr{paramset}
const cpxlp = Cvoid
const CPXLPptr = Ptr{cpxlp}
const CPXCLPptr = Ptr{cpxlp}
const cpxnet = Cvoid
const CPXNETptr = Ptr{cpxnet}
const CPXCNETptr = Ptr{cpxnet}
const CPXCHARptr = Cstring
const CPXCCHARptr = Cstring
const CPXVOIDptr = Ptr{Cvoid}

struct cpxiodevice
    cpxiodev_eof::Ptr{Cvoid}
    cpxiodev_error::Ptr{Cvoid}
    cpxiodev_rewind::Ptr{Cvoid}
    cpxiodev_flush::Ptr{Cvoid}
    cpxiodev_close::Ptr{Cvoid}
    cpxiodev_putc::Ptr{Cvoid}
    cpxiodev_puts::Ptr{Cvoid}
    cpxiodev_read::Ptr{Cvoid}
    cpxiodev_write::Ptr{Cvoid}
end

const CPXIODEVICE = cpxiodevice
const CPXIODEVICEptr = Ptr{cpxiodevice}

const CPXNAMEFUNCTION = Ptr{Cvoid}

@cenum CPXCALLBACKINFO::UInt32 begin
    CPXCALLBACKINFO_THREADID = 0
    CPXCALLBACKINFO_NODECOUNT = 1
    CPXCALLBACKINFO_ITCOUNT = 2
    CPXCALLBACKINFO_BEST_SOL = 3
    CPXCALLBACKINFO_BEST_BND = 4
    CPXCALLBACKINFO_THREADS = 5
    CPXCALLBACKINFO_FEASIBLE = 6
    CPXCALLBACKINFO_TIME = 7
    CPXCALLBACKINFO_DETTIME = 8
    CPXCALLBACKINFO_NODEUID = 9
    CPXCALLBACKINFO_NODEDEPTH = 10
    CPXCALLBACKINFO_CANDIDATE_SOURCE = 11
    CPXCALLBACKINFO_RESTARTS = 12
    CPXCALLBACKINFO_AFTERCUTLOOP = 13
    CPXCALLBACKINFO_NODESLEFT = 14
end

@cenum CPXCALLBACKSOLUTIONSTRATEGY::Int32 begin
    CPXCALLBACKSOLUTION_NOCHECK = -1
    CPXCALLBACKSOLUTION_CHECKFEAS = 0
    CPXCALLBACKSOLUTION_PROPAGATE = 1
    CPXCALLBACKSOLUTION_SOLVE = 2
end

@cenum CPXINFOTYPE::UInt32 begin
    CPXINFO_BYTE = 0
    CPXINFO_SHORT = 1
    CPXINFO_INT = 2
    CPXINFO_LONG = 3
    CPXINFO_DOUBLE = 4
end

const cpxasynchandle = Cvoid
const CPXASYNCptr = Ptr{cpxasynchandle}
const cpxcallbackcontext = Cvoid
const CPXCALLBACKCONTEXTptr = Ptr{cpxcallbackcontext}

const CPXCALLBACKFUNC = Ptr{Cvoid}

const CPXCASYNCptr = Ptr{cpxasynchandle}

struct cpxdeserializer
    getbyte::Ptr{Cvoid}
    getshort::Ptr{Cvoid}
    getint::Ptr{Cvoid}
    getlong::Ptr{Cvoid}
    getfloat::Ptr{Cvoid}
    getdouble::Ptr{Cvoid}
    getbytes::Ptr{Cvoid}
    getshorts::Ptr{Cvoid}
    getints::Ptr{Cvoid}
    getlongs::Ptr{Cvoid}
    getfloats::Ptr{Cvoid}
    getdoubles::Ptr{Cvoid}
end

const CPXCDESERIALIZERptr = Ptr{cpxdeserializer}
const cpxenvgroup = Cvoid
const CPXCENVGROUPptr = Ptr{cpxenvgroup}
const messagehandler = Cvoid
const CPXCMESSAGEHANDLERptr = Ptr{messagehandler}

struct cpxserializer
    addbyte::Ptr{Cvoid}
    addshort::Ptr{Cvoid}
    addint::Ptr{Cvoid}
    addlong::Ptr{Cvoid}
    addfloat::Ptr{Cvoid}
    adddouble::Ptr{Cvoid}
    addbytes::Ptr{Cvoid}
    addshorts::Ptr{Cvoid}
    addints::Ptr{Cvoid}
    addlongs::Ptr{Cvoid}
    addfloats::Ptr{Cvoid}
    adddoubles::Ptr{Cvoid}
end

const CPXCSERIALIZERptr = Ptr{cpxserializer}
const CPXDESERIALIZERptr = Ptr{cpxdeserializer}
const CPXENVGROUPptr = Ptr{cpxenvgroup}

const CPXINFOHANDLER = Ptr{Cvoid}

const CPXMESSAGEHANDLERptr = Ptr{messagehandler}

const CPXMODELASSTCALLBACKFUNC = Ptr{Cvoid}

const CPXSERIALIZERptr = Ptr{cpxserializer}

const CPXUSERFUNCTION = Ptr{Cvoid}


text:
__precompile__()
module KernelRidgeRegression

using Reexport
using Random
using Distributed
using LinearAlgebra
using Clustering

@reexport using KernelFunctions

export KRR,
    FastKRR,
    RandomFourierFeatures,
    TruncatedNewtonKRR,
    NystromKRR,
    SubsetRegressorsKRR,
    fitPar,
    fit, predict, fit_and_predict

import Base: show, display # showcompact
import StatsBase
import StatsBase: fit, fitted, predict, nobs, predict!, RegressionModel, sample, weights

abstract type AbstractKRR{T} <: RegressionModel end

function fit(::Type{AbstractKRR}) error("not implemented") end

StatsBase.fitted(KRR::AbstractKRR) = predict(KRR, KRR.X)

include("krr.jl")
include("util.jl")

end # module KernelRidgeRegression

ext: jl


text:
using WaterReservoir
using Test

@testset "WaterReservoir.jl" begin
    # Write your tests here.
end


text:
module Tests

using IntModN, Base.Test

export tests

# --- integer rings and fields

function test_z_constructor()

    @test string(ZR(3, 2, Int)) == "2 mod 3"
    @test string(ZR(3, 2)) == "2 mod 3"
    @test sprint(show, ZR(3, 2)) == "ZRing{Int64,3,Int64}(2)"
    @test string(ZF(3, 2, Int)) == "2 mod 3"
    @test string(ZF(3, 2)) == "2 mod 3"
    @test sprint(show, ZF(3, 2)) == "ZField{Int64,3,Int64}(2)"

    Z2 = ZF(2)
    @test GF2(1) == Z2(1) == ZField{Int,2,Int}(1) == ZF(2, 1)

    @test isa(ZR(4, 0x3).i, UInt8)

    try
        bad = ZR(256, 0x0)
        error("expected failure")
    catch e
        @test isa(e, ErrorException)
        @test search(string(e), "too large") != 0:-1
    end

    @test one(ZField{Int,2,Int}) == one(GF2(0)) == GF2(1)

    println("test_z_constructor ok")
end

function test_z_random()
    @test isa(rand(ZRing{Int,3,UInt}), ZRing{Int,3,UInt})
    a = rand(ZField{Int,5,UInt8}, 2, 3)
    @test size(a) == (2, 3)
    @test isa(a, Array{ZField{Int,5,UInt8},2})
    println("test_z_random ok")
end

function test_z_arithmetic()

    @test GF2(1) + GF2(1) == GF2(0)
    @test zero(ZRing{Int,5,Int}) - one(ZRing{Int,5,Int}) == ZR(5, 4)
    @test zero(ZField{Int,5,Int}) - one(ZField{Int,5,Int}) == ZF(5, 4)
    @test inv(ZF(5, 3)) == ZF(5, 2)
    @test ZF(5, 3) * ZF(5, 2) == one(ZField{Int, 5, Int})
    @test GF2(0)^0 == GF2(1)

    for i in 1:10
        z1, z2 = ZF(5, rand(1:5)), ZF(5, rand(1:5))
        @test (z1 - z2) + z2 == z1
        @test z1 - (z2 - z2) == z1
        @test z2 + (z1 - z2) == z1
    end
    @test ZF(5, 1) - ZF(5, 4) == ZF(5, 2)

    @test modulus(GF2(1)) == order(GF2(0)) == 2

    try
        inv(ZR(6, 2))
        error("expected failure")
    catch e
        @test isa(e, ErrorException)
        @test search(string(e), "not invertible") != 0:-1
    end

    @test ZR(4, 2) / ZR(4, 2) == ZR(4, 1)
    @test ZR(4, 2) / ZR(4, 3) == ZR(4, 2)
    @test_throws ErrorException ZR(4, 3) / ZR(4, 2)

    @test ZF(5, 2) / ZF(5, 2) == ZF(5, 1)
    @test ZF(5, 2) / ZF(5, 3) == ZF(5, 4)
    @test ZF(5, 3) / ZF(5, 2) == ZF(5, 4)

    println("test_z_arithmetic ok")
end

function test_z_matrix_inverse()

    @zfield 2 begin
        A = [1 1;
             0 1]
        b = [1, 1]
        x = A\b
        @test x == [0, 1]
    end

    # http://math.stackexchange.com/questions/169921/how-to-solve-system-of-linear-equations-of-xor-operation
    @zfield 2 begin
        A = [1 1 1 0;
             1 1 0 1;
             1 0 1 1;
             0 1 1 1]
        b = [1, 1, 0, 1]
        x = A\b
        @test x == [0, 1, 0, 0]
    end

    println("test_z_matrix_inverse ok")
end

function test_z_power()

    # http://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange#Explanation_including_encryption_mathematics
    base = ZF(23, 5)
    @test (base^6).i == 8
    @test (base^15).i == 19
    @test ((base^15)^6).i == 2
    @test ((base^6)^15).i == 2

    println("test_z_power ok")
end

function test_z_macros()
    begin
        b = 7
    end
    @test b == 7
    @zfield 5  begin
        b = 1 + 2 * 3
        a = b / 3
    end
    @test a == ZF(5, 4)
    @test ZR(3, 2) == @zring 3 1 + 4
    println("test_z_macros ok")
end

function test_z_coverage()
    println("Integer", methodswithdescendants(Integer, lim=20))
    println("ZRing", methodswithdescendants(ZRing, lim=20))
    println("test_z_coverage ok")
end

function tests_z()
    test_z_constructor()
    test_z_random()
    test_z_arithmetic()
    test_z_matrix_inverse()
    test_z_power()
    test_z_macros()
#    test_z_coverage()
end

# --- polynomials

function test_p_constructor()

    x = ZP(GF2(1), GF2(0))
    @test ZP(GF2(1), GF2(0), GF2(1), GF2(0)) == x^3 + x
    x = X(ZF(5))
    @test ZP(ZF(5,2), ZF(5,3), ZF(5,4)) == 2x^2 + 3x + 4
    x = X(ZField{Int, 3, Int})
    @test x + 1 == ZP([ZF(3,1), ZF(3,1)])
    @test x + 1 == ZP(ZF(3,1), ZF(3,1))
    @test x + 1 == ZP(ZField{Int, 3, Int}, [1, 1])
    @test x + 1 == ZP(ZField{Int, 3, Int}, 1, 1)

    x = X(GF2)
    @test ZP(GF2, 1, 1, 0) == x^2 + x
    @test ZP(ZF(2), [0, 1, 1]) == x^2 + x
    @test ZP(ZField{Int,2,Int}, [0, 1, 1]) == x^2 + x

    println("test_p_constructor ok")
end

function test_p_show()

    x = X(Int)
    @test string(3x^2 + 1) == "3x^2 + 1"
    @test sprint(show, 3x^2 + 1) == "ZP(Int64,3,0,1)"

    x = X(ZF(5))
    @test string(3x^2 + 1) == "3x^2 + 1 mod 5"
    @test sprint(show, 3x^2 + 1) in
    ("ZP(ZField{Int64,5,Int64},3,0,1)", "ZP(IntModN.ZField{Int64,5,Int64},3,0,1)")

    println("test_p_show ok")
end

function test_p_comparison()

    x = X(Int)
    @test x + 1 == x + 1
    @test x^2 + 1 != x + 1

    for i in 1:10
        a = ZP(rand!(Array(ZField{Int, 5, Int}, rand(0:2))))
        b = ZP(rand!(Array(ZField{Int, 5, Int}, rand(0:2))))
        @test a == b || ((a < b) $ (b < a))
        if a < b || a == b
            @test a <= b
        end
        if a > b || a == b
            @test a >= b
        end
        if a == b
            @test !(a != b)
        else
            @test a != b
        end
    end

    println("test_p_comparison ok")
end

function test_p_arithmetic()

    x = X(GF2)
    a = x^3 + x^2 + 1
    b = x^2 + 1
    p, q = divrem(a, b)
    @test string(p * b + q) == "x^3 + x^2 + 1 mod 2"

    @test divrem(x,one(x)) == (x, zero(x))
    @test divrem(x,x) == (one(x), zero(x))
    @test_throws ErrorException divrem(x,zero(x))

    x = X(ZF(5))
    p1 =  x^5 + 3x^4 + 4x^3 + 2x^2      + 1
    p2 = 4x^5        + 2x^3 + 3x^2 +  x + 4
    ex = 2x^5 + 3x^4 + 2x^3 + 4x^2 + 4x + 2
    r = p1 - p2
    @test r == ex

    @test divrem(x,one(x)) == (x, zero(x))
    @test divrem(x,x) == (one(x), zero(x))
    @test_throws ErrorException divrem(x,zero(x))

    # http://www.math.umn.edu/~garrett/coding/Overheads/08_crcs.pdf
    # page 5
    x = X(GF2)
    @test (x^3 + x^2 + 1) + (x^3 + x + 1) == x^2 + x
    # page 6
    x = X(Int)
    @test (2x^3 + 3x^2 + x - 3) * (x^2 - 2x + 1) == (2x^5 - x^4 - 3x^3 - 2x^2 + 7x - 3)
    # page 7
    x = X(GF2)
    @test (x^3 + x + 1) * (x^2 + x + 1) == (x^5 + x^4 + 1)
    # page 8
    x = X(Int)
    @test divrem(x^8 + x^7 + x^4 + x^3 + x + 1, x^5 + x^3 + x + 1) == (x^3 + x^2 - x - 1, x^4 + 3x + 2)
    # page 9
    x = X(GF2)
    @test divrem(x^8 + x^7 + x^4 + x^3 + x + 1, x^5 + x^3 + x + 1) == (x^3 + x^2 + x + 1, x^4 + x)

    println("test_p_arithmetic ok")
end

function test_p_bitwise()
    @test ZP(3, 2, 1) & ZP(1, 1, 1) == ZP(1, 0, 1)
    @test ZP(3, 2, 1) | ZP(1, 1) == ZP(3, 3, 1)
    @test ZP(GF2(0), GF2(0)) $ ZP(GF2(1)) == ZP(GF2(0), GF2(1))
    @test ZP(1, 0) << 2 == ZP(1, 0, 0, 0)
    @test ZP(1, 0) >>> 1 == ZP(1)

    println("test_p_bitwise")
end

function test_p_array()

    x = X(GF2)
    p = x^2 + x
    @test p[2] == GF2(1)
    @test p[1] == GF2(0)
    @test length(p) == 3

    count = 0
    for (i, a) in enumerate(p)
        count = count + 1
        @test 0 < i < 4
        @test (i == 1 && a == GF2(0)) || (i != 1 && a == GF2(1))
    end
    @test count == 3

    println("test_p_array")
end

function tests_p()
    test_p_constructor()
    test_p_show()
    test_p_comparison()
    test_p_arithmetic()
    test_p_bitwise()
    test_p_array()
end

# --- fast polynomials in GF2

function test_p2_constructor()

    x = GF2X(UInt8)
    @test GF2P(0xa) == x^3 + x

    println("test_p2_constructor ok")
end

function test_p2_show()

    x = GF2X(UInt)
    @test string(3x^2 + 1) == "x^2 + 1 mod 2"
    @test sprint(show, 3x^2 + 1) in
    ("GF2Poly{UInt64}(5)", "GF2Poly{UInt64}(5)")

    println("test_p2_show ok")
end

function test_p2_comparison()

    x = GF2X(UInt)
    @test x + 1 == x + 1
    @test x^2 + 1 != x + 1

    for i in 1:10
        a = GF2P(rand(UInt8))
        b = GF2P(rand(UInt8))
        @test a == b || ((a < b) $ (b < a))
        if a < b || a == b
            @test a <= b
        end
        if a > b || a == b
            @test a >= b
        end
        if a == b
            @test !(a != b)
        else
            @test a != b
        end
    end

    println("test_p2_comparison ok")
end

function test_p2_arithmetic()

    x = GF2X(UInt8)
    a = x^3 + x^2 + 1
    b = x^2 + 1
    p, q = divrem(a, b)
    @test p*b+q == a
    @test string(p * b + q) == "x^3 + x^2 + 1 mod 2"

    p1 = x^5 + x^4 + x^3 + x^2     + 1
    p2 = x^5       + x^3 + x^2 + x
    ex =       x^4             + x + 1
    r = p1 - p2
    @test r == ex

    @test divrem(x,one(x)) == (x, zero(x))
    @test divrem(x,x) == (one(x), zero(x))
    @test_throws ErrorException divrem(x,zero(x))

    @test divrem(x^2, x) == (x, zero(x))
    @test divrem(x^2 + 1, x) == (x, one(x))
    @test divrem((x + 1) * (x^2 + 1) + 1, x + 1) == (x^2 + 1, one(x))
    @test divrem((x + 1) * (x^3 + 1) + x, x + 1) == (x^3, one(x))

    x = GF2X(UInt)  # x^8 ahead!
    # http://www.math.umn.edu/~garrett/coding/Overheads/08_crcs.pdf
    # page 5
    @test (x^3 + x^2 + 1) + (x^3 + x + 1) == x^2 + x
    # page 7
    @test (x^3 + x + 1) * (x^2 + x + 1) == (x^5 + x^4 + 1)
    # page 9
    @test divrem(x^8 + x^7 + x^4 + x^3 + x + 1, x^5 + x^3 + x + 1) == (x^3 + x^2 + x + 1, x^4 + x)

    println("test_p2_arithmetic ok")
end

function test_p2_bitwise()
    @test GF2P(0x5) & GF2P(0x7) == GF2P(0x5)
    @test GF2P(0x5) | GF2P(0x3) == GF2P(0x7)
    @test GF2P(0x0) $ GF2P(0x1) == GF2P(0x1)
    @test GF2P(0x2) << 2 == GF2P(0x8)
    @test GF2P(0x2) >>> 1 == GF2P(0x1)

    println("test_p2_bitwise")
end

function test_p2_array()

    x = GF2X()
    p = x^2 + x
    @test p[2] == GF2(1)
    @test p[1] == GF2(0)
    @test length(p) == 3

    count = 0
    for (i, a) in enumerate(p)
        count = count + 1
        @test 0 < i < 4
        @test (i == 1 && a == GF2(0)) || (i != 1 && a == GF2(1))
    end
    @test count == 3

    println("test_p2_array")
end

function tests_p2()
    test_p2_constructor()
    test_p2_show()
    test_p2_comparison()
    test_p2_arithmetic()
    test_p2_bitwise()
    test_p2_array()
end

# --- factor rings of polynomials

function test_f_rijndael()
    x = X(GF2)
    rij = x^8 + x^4 + x^3 + x + 1
    a = ZF(rij, x^7 + x^6 + x^3 + x)
    b = ZF(rij, x^6 + x^4 + x + 1)
    o = one(a)
    @test a * b == o
    # none of these work
    @test o / a == b
    @test o / b == a
    @test inv(a) == b

    println("test_f_rijndael ok")
end

function test_f_rijndael2()
    x = GF2X(UInt64)
    rij = x^8 + x^4 + x^3 + x + 1
    a = ZF(rij, x^7 + x^6 + x^3 + x)
    b = ZF(rij, x^6 + x^4 + x + 1)
    o = one(a)
    @test a * b == o
    @test inv(a) == b
    @test o / b == a
    @test o / a == b

    println("test_f_rijndael2 ok")
end

function test_f_rijndael3()
    x = X(GF2)
    rij = x^8 + x^4 + x^3 + x + 1
    a = ZR(rij, x^7 + x^6 + x^3 + x)
    b = ZR(rij, x^6 + x^4 + x + 1)
    o = one(a)
    @test a * b == o
    # none of these work
    @test o / a == b
    @test o / b == a
    @test inv(a) == b

    println("test_f_rijndael3 ok")
end

function test_f_inverse()
    x = X(GF2)
    rij = x^8 + x^4 + x^3 + x + 1
    a = x^7 + x^6 + x^3 + x
    b = x^6 + x^4 + x + 1
    c = extended_euclidean(a, rij)
    @test b == c

    println("test_f_inverse ok")
end

function tests_f()
    test_f_inverse()
    test_f_rijndael3()
# these require correct handling of inverses
# http://www.dtic.mil/dtic/tr/fulltext/u2/a218148.pdf
#    test_f_rijndael()
#    test_f_rijndael2()
end

function tests()
    tests_z()
    tests_p()
    tests_p2()
    tests_f()
end

end


text:
using RoadGraphs

let
    # TODO: output graph region hash in .json log as well
    R0 = ((-36.9323, 174.8616), (-36.8878, 174.9565))
    G = read_graph("graph.json", R0...)

    MP = ModelParams(
        lambda = 0.5,
        bidir = true,
        junctions = true,
        )
    SP = SolveParams(
        time_limit = 60,
        )

    # Could accept parameters via web requests - would help with compile times
    run_model(G, MP, SP, "test", draw = true)
end


text:
"""
    struct ParamNamesUnit{N1,N2}
        var::NTuple{N1,Symbol}
        var_aux::Vector{Tuple{Vararg{Symbol,_N} where _N}}
        updt::NTuple{N2,Pair{Int64,Symbol}}
        updt_aux::Vector{Tuple{Vararg{Pair{Int64,Symbol},_N} where _N}}
        updt_obs::Vector{Tuple{Vararg{Pair{Int64,Int64},_N} where _N}}
    end

Smallest unit storing information about the names of the parameters that are
supposed to be updated at a given step of the MCMC algorithm. It is pertinent
to a single block of a single recording only, and in particular, only to a
single collection of laws, out of:
- `PP`, i.e. those relevant to a given block
- `P_last`, i.e. the artificial law of the block associated with the last obs
- `P_excl`, i.e. the last, missed out `PP`, missed out due to use of `P_last`
- `PPb`, i.e. the collection of all remaining artificial laws that are not
         `P_last`
It stores lists of parameters that are supposed to be updated at various stages
of the call to a function `set_proposal_law!`, which sets the proposal parameter
`θ°` inside the proposal laws.

# Fields
- `var`: names of `P_target` that are checked and—if need be—equalized between
         proposal and accepted laws
- `var_aux`: names of `P_aux` that are checked and—if need be—equalized between
             proposal and accepted laws
- `updt`: list of params of `P_target` that are being updated at a given MCMC
          step; listed as pairs: `idx-of-θ-to-relevant-value` =>
          `name-of-param-inside-P_target-struct`
- `updt_aux`: as above, but for `P_aux`
- `updt_obs`: list of params of `obs` (i.e. terminal observation for each guid
              prop) that are being updated at a given MCMC step; listed as
              pairs: `idx-of-θ-to-relevant-value` => `idx-of-obs-inside-obs.θ`

    ParamNamesUnit(
        PP::AbstractArray{<:GuidProp}, θnames::Vector{Symbol}, pdep, odeps
    )

Base constructor.

# Arguments
- `PP`:
- `θnames`:
- `pdep`:
- `odeps`:
"""
struct ParamNamesUnit{N1,N2}
    var::NTuple{N1,Symbol}
    var_aux::Vector{Tuple{Vararg{Symbol,_N} where _N}}
    updt::NTuple{N2,Pair{Int64,Symbol}}
    updt_aux::Vector{Tuple{Vararg{Pair{Int64,Symbol},_N} where _N}}
    updt_obs::Vector{Tuple{Vararg{Pair{Int64,Int64},_N} where _N}}

    function ParamNamesUnit(
            PP::AbstractArray{<:GuidProp},
            θnames::Vector{Symbol},
            pdep,
            odeps,
        )
        updt = find_θ_names_for_MCMC_update(θnames, pdep)
        updt_aux = find_θ_aux_names_for_MCMC_update(updt, PP)
        updt_obs = find_θ_obs_idx_for_MCMC_update(θnames, odeps)

        var = find_var_names_not_in_MCMC_update(updt, PP)
        var_aux = find_var_aux_names_not_in_MCMC_update(updt_aux, PP)

        new{length(var), length(updt)}(var, var_aux, updt, updt_aux, updt_obs)
    end

    RecordingParamNames() = new{0,0}()
end

tuple_lengths(::ParamNamesUnit{N1,N2}) where {N1,N2} = (N1, N2)

"""
    find_θ_names_for_MCMC_update(θnames, pdep)

Parse through `θnames` i.e. a list of all parameter names that are relevant for
a given MCMC update and pick out only those that are relevant for a given
diffusion law. All information about the relevant parameters of the law should
be stored inside `pdep`. Return a list of relevant parameter names in a format:
`idx-of-θ-to-relevant-value` => `name-of-param-inside-P_target-struct`.
"""
find_θ_names_for_MCMC_update(θnames, pdep) = Tuple(
    map(
        gl_p_n->(
            findfirst(
                n->(n==gl_p_n[1]),
                θnames
            ) => gl_p_n[2]
        ), # substitute a global param name (gl_p_n[1]) with its index in θnames
        filter(
            p->(p[1] in θnames),
            pdep
        ) # remove all parameter names not featured in θnames
    )
)

"""
    find_θ_aux_names_for_MCMC_update(θ_names_for_MCMC_update, PP)

Parse through `PP` and for each `GuidProp` struct enter the auxiliary law
`P_aux` and pick out names from `θ_names_for_MCMC_update` that are relevant to
this `P_aux` law.
"""
find_θ_aux_names_for_MCMC_update(θ_names_for_MCMC_update, PP) = map(PP) do P
    filter(
        p->(p[2] in DD.var_parameter_names(P.P_aux)),
        θ_names_for_MCMC_update
    )
end

"""
    find_θ_obs_idx_for_MCMC_update(θnames, odeps)

Parse through `θnames` i.e. a list of all parameter names that are relevant for
a given MCMC update and for each observation pick out only those that are
relevant for it. All information about the relevant parameters of the
observations should be stored inside `odeps`. Return a list of relevant
parameter names in a format: `idx-of-θ-to-relevant-value` =>
`idx-of-obs-inside-obs.θ`.
"""
find_θ_obs_idx_for_MCMC_update(θnames, odeps) = map(
    odep->Tuple(
        map(
            gl_p_n->(
                findfirst(
                    n->(n==gl_p_n[1]),
                    θnames
                ) => gl_p_n[2]
            ), # substitute a global parameter name with its index in θnames
            filter(
                p->(p[1] in θnames),
                odep
            ) # remove all observation params not featured in θnames
        )
    ),
    odeps
)

"""
    find_var_names_not_in_MCMC_update(composite_names_in_updt, PP)

Parse through all variable names of `P_target` and remove all those names that
already feature in `composite_names_in_updt`.
"""
function find_var_names_not_in_MCMC_update(composite_names_in_updt, PP)
    names_in_updt = getindex.(composite_names_in_updt, 2)
    length(PP) > 0 || return tuple()
    filter(pn->!(pn in names_in_updt), DD.var_parameter_names(PP))
end

"""
    find_var_aux_names_not_in_MCMC_update(composite_names_in_updt, PP)

Parse through all `PP` and for each element look through variable names of
`P_aux` and remove all those names that already feature in
`composite_names_in_updt`.
"""
function find_var_aux_names_not_in_MCMC_update(composite_names_in_updt, PP)
    names_in_updt = map(n->getindex.(n, 2), composite_names_in_updt)
    #println(names_in_updt)
    [
        filter(
            pn->!(pn in n),
            DD.var_parameter_names(P.P_aux)
        ) for (n, P) in zip(names_in_updt, PP)
    ]
end

"""
    struct ParamNamesBlock{N1,N2}
        PP::ParamNamesUnit{N1,N2}
        P_last::ParamNamesUnit{N1,N2}
        P_excl::ParamNamesUnit{N1,N2}
        Pb_excl::ParamNamesUnit{N1,N2}
    end

Stores information relevant for a `Block` about the names of the parameters that
are supposed to be updated at a given step of the MCMC algorithm. It stores
lists of parameters that are supposed to be updated at various stages of the
call to a function `set_proposal_law!`, which sets the proposal parameter `θ°`
inside the proposal laws.

# Fields
- `PP`, i.e. those relevant to a given block
- `P_last`, i.e. the artificial law of the block associated with the last obs
- `P_excl`, i.e. the last, missed out `PP`, missed out due to use of `P_last`
- `Pb_excl`, i.e. the collection of all remaining artificial laws that are not
             `P_last`

    ParamNamesBlock(b::Block, θnames, pdep, odeps)

Base constructor.

# Arguments
- `b::Block`:
- `θnames`:
- `pdep`:
- `odeps`:
"""
struct ParamNamesBlock{N1,N2}
    PP::ParamNamesUnit{N1,N2}
    P_last::ParamNamesUnit{N1,N2}
    P_excl::ParamNamesUnit{N1,N2}
    Pb_excl::ParamNamesUnit{N1,N2}

    function ParamNamesBlock(b::Block, θnames, pdep, odeps)
        i1, i2 = _idx_split(b)

        PP = ParamNamesUnit(b.PP, θnames, pdep, odeps[i1])
        P_last = ParamNamesUnit(b.P_last, θnames, pdep, [tuple() for _ in i2])
        P_excl = ParamNamesUnit(b.P_excl, θnames, pdep, odeps[i2])
        Pb_excl = ParamNamesUnit(b.Pb_excl, θnames, pdep, [tuple() for _ in i1])
        N1, N2 = tuple_lengths(PP)
        new{N1,N2}(PP, P_last, P_excl, Pb_excl)
    end
end

function _idx_split(b::Block{false})
    bidx = first(b.PP.indices) # PP is a subarray
    bidx, [bidx[end]+1]
end

function _idx_split(b::Block{true})
    bidx = first(b.PP.indices) # PP is a subarray
    bidx, Int64[]
end

tuple_lengths(::ParamNamesBlock{N1,N2}) where {N1,N2} = (N1, N2)

"""
    struct ParamNamesRecording{N1,N2}
        blocks::Vector{ParamNamesBlock{N1,N2}}
    end

Stores information relevant for an entire, single recording about the names of
the parameters that are supposed to be updated at a given step of the MCMC
algorithm. It stores lists of parameters that are supposed to be updated at
various stages of the call to a function `set_proposal_law!`, which sets the
proposal parameter `θ°` inside the proposal laws.

    ParamNamesRecording(rb::BlockCollection, θnames, pdep, odeps)

Base constructor.
"""
struct ParamNamesRecording{N1,N2}
    blocks::Vector{ParamNamesBlock{N1,N2}}

    function ParamNamesRecording(bc::BlockCollection, θnames, pdep, odeps)
        blocks = map(bb->ParamNamesBlock(bb.b, θnames, pdep, odeps), bc.blocks)
        N1, N2 = tuple_lengths(first(blocks))
        new{N1,N2}(blocks)
    end
end

"""
    struct ParamNamesAllObs{T}
        recordings::Vector{T}
    end

Stores information relevant for multiple recordings about the names of the
parameters that are supposed to be updated at a given step of the MCMC
algorithm. It stores lists of parameters that are supposed to be updated at
various stages of the call to a function `set_proposal_law!`, which sets the
proposal parameter `θ°` inside the proposal laws.

    ParamNamesAllObs(be::BlockEnsemble, θnames, all_obs)

Base constructor.
"""
struct ParamNamesAllObs{T}
    recordings::Vector{T}

    function ParamNamesAllObs(be::BlockEnsemble, θnames, all_obs)
        recordings = map(1:length(be.recordings)) do i
            ParamNamesRecording(
                be.recordings[i],
                θnames,
                all_obs.param_depend_rev[i],
                all_obs.obs_depend_rev[i]
            )
        end
        new{eltype(recordings)}(recordings)
    end
end


text:
using Test
import IterTools

using FastRepl

@testset "FastRepl.jl" begin

@testset "" begin
end

end


text:
#################
# HessianResult #
#################

type HessianResult{V,G,H} <: ForwardDiffResult
    value::V
    gradient::G
    hessian::H
end

HessianResult(x) = HessianResult(first(x), similar(x), similar(x, length(x), length(x)))

value(result::HessianResult) = result.value
gradient(result::HessianResult) = result.gradient
hessian(result::HessianResult) = result.hessian

###############
# API methods #
###############

function hessian{N}(f, x, chunk::Chunk{N} = pickchunk(x);
                    multithread::Bool = false,
                    usecache::Bool = true)
    if N == length(x)
        return vector_mode_hessian(f, x, chunk, usecache)
    else
        return chunk_mode_hessian(f, x, chunk, multithread, usecache)
    end
end

function hessian!{N}(out, f, x, chunk::Chunk{N} = pickchunk(x);
                     multithread::Bool = false,
                     usecache::Bool = true)
    if N == length(x)
        vector_mode_hessian!(out, f, x, chunk, usecache)
    else
        chunk_mode_hessian!(out, f, x, chunk, multithread, usecache)
    end
    return out
end

#######################
# workhorse functions #
#######################

# result extraction #
#-------------------#

@inline load_hessian_value!(out, dual) = out

function load_hessian_value!(out::HessianResult, dual)
    out.value = value(value(dual))
    return out
end

@inline load_hessian_gradient!(out, dual) = out

function load_hessian_gradient!(out::HessianResult, dual)
    grad = out.gradient
    val = value(dual)
    for i in eachindex(grad)
        grad[i] = partials(val, i)
    end
    return out
end

function load_hessian!(out, dual)
    for col in 1:size(out, 2), row in 1:size(out, 1)
        out[row, col] = partials(dual, row, col)
    end
    return out
end

@inline function load_hessian!(out::HessianResult, dual)
    load_hessian!(out.hessian, dual)
    return out
end

# vector mode #
#-------------#

function compute_vector_mode_hessian(f, x, chunk, usecache)
    cache = hessian_cachefetch!(x, chunk, usecache)
    xdual = cache.duals
    seedhess!(xdual, x, cache.inseeds, cache.outseeds)
    return f(xdual)
end

function vector_mode_hessian(f, x, chunk, usecache)
    dual = compute_vector_mode_hessian(f, x, chunk, usecache)
    out = similar(x, numtype(numtype(dual)), length(x), length(x))
    return load_hessian!(out, dual)
end

function vector_mode_hessian!(out, f, x, chunk, usecache)
    dual = compute_vector_mode_hessian(f, x, chunk, usecache)
    load_hessian_value!(out, dual)
    load_hessian_gradient!(out, dual)
    load_hessian!(out, dual)
    return out
end

# chunk mode #
#------------#

function chunk_mode_hessian(f, x, chunk::Chunk, multithread::Bool, usecache::Bool)
    gradf = y -> ForwardDiff.gradient(f, y, chunk; multithread = multithread, usecache = usecache)
    return ForwardDiff.jacobian(gradf, x, chunk; usecache = usecache)
end

function chunk_mode_hessian!(out, f, x, chunk::Chunk, multithread::Bool, usecache::Bool)
    gradf = y -> ForwardDiff.gradient(f, y, chunk; multithread = multithread, usecache = usecache)
    ForwardDiff.jacobian!(out, gradf, x, chunk; usecache = usecache)
    return out
end

function chunk_mode_hessian!{T,N}(out::HessianResult{T}, f, x, chunk::Chunk{N},
                                  multithread::Bool, usecache::Bool)
    gradvec = similar(out.gradient, Dual{N,T})
    gradresult = GradientResult(first(gradvec), gradvec)
    gradf = y -> begin
        ForwardDiff.gradient!(gradresult, f, y, chunk; multithread = multithread, usecache = usecache)
        return ForwardDiff.gradient(gradresult)
    end
    ForwardDiff.jacobian!(out.hessian, gradf, x, chunk; usecache = usecache)
    out.value = ForwardDiff.value(ForwardDiff.value(gradresult))
    for i in eachindex(gradvec)
        out.gradient[i] = ForwardDiff.value(gradvec[i])
    end
    return out
end


text:
using vobs
using Test

@testset "vobs.jl" begin
    # Write your tests here.
end


text:
using Documenter
using DSAModels

makedocs(
    sitename = "DSAModels",
    format = Documenter.HTML(),
    modules = [DSAModels]
)

# Documenter can also automatically deploy documentation to gh-pages.
# See "Hosting Documentation" and deploydocs() in the Documenter manual
# for more information.

deploydocs(
    repo = "github.com/LudwigBoess/DSAModels.jl.git",
    devbranch = "main"
)


text:
@testset "Approximators" begin

    @testset "TabularApproximator" begin
        A = TabularVApproximator(; n_state = 2, opt = InvDecay(1.0))

        @test A(1) == 0.0
        @test A(2) == 0.0

        update!(A, 2 => A(2) - 3.0)
        @test A(2) == 1.5
        update!(A, 2 => A(2) - 6.0)
        @test A(2) == 3.0
    end

    @testset "NeuralNetworkApproximator" begin
        NN = NeuralNetworkApproximator(; model = Dense(2, 3), optimizer = Descent())

        q_values = NN(rand(2))
        @test size(q_values) == (3,)

        gs = gradient(params(NN)) do
            sum(NN(rand(2, 5)))
        end

        old_params = deepcopy(collect(params(NN).params))
        update!(NN, gs)
        new_params = collect(params(NN).params)

        @test old_params != new_params
    end

    @testset "ActorCritic" begin
        ac_cpu = ActorCritic(
            actor = NeuralNetworkApproximator(model = Dense(3, 2)),
            critic = NeuralNetworkApproximator(model = Dense(3, 1)),
        )

        ac = ac_cpu |> gpu

        # make sure optimizer is not changed
        @test ac_cpu.optimizer === ac.optimizer

        D = ac.actor.model |> gpu |> device
        @test D === device(ac) === device(ac.actor) == device(ac.critic)

        A = send_to_device(D, rand(3))
        ac.actor(A)
        ac.critic(A)
    end

    @testset "GaussianNetwork" begin
        @testset "identity normalizer" begin
            pre = Dense(20,15)
            μ = Dense(15,10)
            logσ = Dense(15,10)
            gn = GaussianNetwork(pre, μ, logσ, identity)
            @test Flux.params(gn) == Flux.Params([pre.W, pre.b, μ.W, μ.b, logσ.W, logσ.b])
            state = rand(20,3) #batch of 3 states
            m, s = gn(state)
            @test size(m) == size(s) == (10,3)
            a, logp = gn(state, is_sampling = true, is_return_log_prob = true)
            @test size(a) == (10,3)
            @test size(logp) == (1,3)
            @test logp ≈ sum(normlogpdf(m, exp.(s), a) .- (2.0f0 .* (log(2.0f0) .- a .- softplus.(-2.0f0 .* a))), dims = 1)
            @test logp ≈ gn(state, a)
            as, logps = gn(Flux.unsqueeze(state,2), 5) #sample 5 actions
            @test size(as) == (10,5,3)
            @test size(logps) == (1,5,3)
            logps2 = gn(Flux.unsqueeze(state,2), as)
            @test logps2 ≈ logps
            g = Flux.gradient(Flux.params(gn)) do
                a, logp = gn(state, is_sampling = true, is_return_log_prob = true)
                sum(logp)
            end
            g2 = Flux.gradient(Flux.params(gn)) do
                logp = gn(state, a)
                sum(logp)
            end
        end
        @testset "tanh normalizer" begin
            pre = Dense(20,15)
            μ = Dense(15,10)
            logσ = Dense(15,10)
            gn = GaussianNetwork(pre, μ, logσ)
            @test Flux.params(gn) == Flux.Params([pre.W, pre.b, μ.W, μ.b, logσ.W, logσ.b])
            state = rand(20,3) #batch of 3 states
            m, s = gn(state)
            @test size(m) == size(s) == (10,3)
            a, logp = gn(state, is_sampling = true, is_return_log_prob = true)
            @test size(a) == (10,3)
            @test size(logp) == (1,3)
            @test logp ≈ sum(normlogpdf(m, exp.(s), a) .- (2.0f0 .* (log(2.0f0) .- a .- softplus.(-2.0f0 .* a))), dims = 1)
            @test logp ≈ gn(state, a)
            as, logps = gn(Flux.unsqueeze(state,2), 5) #sample 5 actions
            @test size(as) == (10,5,3)
            @test size(logps) == (1,5,3)
            logps2 = gn(Flux.unsqueeze(state,2), as)
            @test logps2 ≈ logps
            g = Flux.gradient(Flux.params(gn)) do
                a, logp = gn(state, is_sampling = true, is_return_log_prob = true)
                sum(logp)
            end
            g2 = Flux.gradient(Flux.params(gn)) do
                logp = gn(state, a)
                sum(logp)
            end
        end
        @testset "CUDA" begin
            if CUDA.functional()
                pre = Dense(20,15) |> gpu
                μ = Dense(15,10) |> gpu
                logσ = Dense(15,10) |> gpu
                gn = GaussianNetwork(pre, μ, logσ)
                @test Flux.params(gn) == Flux.Params([pre.W, pre.b, μ.W, μ.b, logσ.W, logσ.b])
                state = rand(20,3)  |> gpu #batch of 3 states
                m, s = gn(state)
                @test size(m) == size(s) == (10,3)
                a, logp = gn(CUDA.CURAND.RNG(), state, is_sampling = true, is_return_log_prob = true)
                @test size(a) == (10,3)
                @test size(logp) == (1,3)
                @test logp ≈ sum(normlogpdf(m, exp.(s), a) .- (2.0f0 .* (log(2.0f0) .- a .- softplus.(-2.0f0 .* a))), dims = 1)
                @test logp ≈ gn(state, a)
                as, logps = gn(Flux.unsqueeze(state,2), 5) #sample 5 actions
                @test size(as) == (10,5,3)
                @test size(logps) == (1,5,3)
                logps2 = gn(Flux.unsqueeze(state,2), as)
                @test logps2 ≈ logps
                g = Flux.gradient(Flux.params(gn)) do
                    a, logp = gn(CUDA.CURAND.RNG(), state, is_sampling = true, is_return_log_prob = true)
                    sum(logp)
                end
                g2 = Flux.gradient(Flux.params(gn)) do
                    logp = gn(state, a)
                    sum(logp)
                end
            end
        end
    end
end


text:
module ExtractMacro

export @extract

"""
    @extract obj : exprs...

Extracts fields from composite types. E.g.

```julia
@extract x : a b

# is translated to:

a = x.a
b = x.b
```

The colon is optional: `@extract x a b` is the same as above.
Destination variable names can be changed, and arbitrary functions (including indexing) applied, e.g.:

```julia
@extract x : q=b a1=abs(a[1]) ai=abs(a[i]) y=max(a[1],b)

# is translated to:

q = x.b
a1 = abs(x.a[1])
ai = abs(x.a[i])
y = max(x.a[1], x.b)
```

Notice that the `i` within the indexing expression is left untouched: indexing is special in this regard.

In order to explicitly avoid symbol manipulation on the right hand side, use `esc()`, e.g.:

```julia
@extract x : y=abs(a[1] + esc(b))

# is translated to:

y = abs(x.a[1] + b) # b is left untouched
```
"""
macro extract(obj, vars...)
    ex = quote end
    # next block is to allow this syntax
    #   @extract X : a b c
    # (basically, we need to override the parsing precedence rules)
    if Meta.isexpr(obj, [:(=), :(=>), :(:=)]) && Meta.isexpr(obj.args[1], :(:))
        vars = Any[Expr(obj.head, obj.args[1].args[2:end]..., obj.args[2:end]...), vars...]
        obj = obj.args[1].args[1]
    elseif Meta.isexpr(obj, :(:))
        vars = Any[obj.args[2], vars...]
        obj = obj.args[1]
    end
    for v in vars
        if isa(v, Symbol)
            ex = quote
                $ex
                $(esc(v)) = $(prepend_obj(v, obj))
            end
        elseif isa(v, Expr)
            if v.head ∉ [:(=), :(=>), :(:=)]
                error("invalid @extract argument: expression `$(v)` out of an assigment")
            end
            va = v.args
            @assert length(va) == 2
            ex = quote
                $ex
                $(esc(va[1])) = $(prepend_obj(va[2], obj))
            end
        end
    end
    ex
end

update_skiplist!(x, skip) = nothing
update_skiplist!(x::Symbol, skip) = push!(skip, x)
function update_skiplist!(x::Expr, skip)
    Meta.isexpr(x, :tuple) || return
    for a in x.args
        update_skiplist!(a, skip)
    end
end

prepend_obj(x, obj, skip=[]) = x
prepend_obj(s::Symbol, obj, skip=[]) = s ∈ skip ? esc(s) : :($(esc(obj)).$s)
function prepend_obj(body::Expr, obj, skip=[])
    if Meta.isexpr(body, :call)
        if body.args[1] != :esc
            return Expr(body.head, Expr(:escape, body.args[1]), map(x->prepend_obj(x, obj, skip), body.args[2:end])...)
        else
            @assert length(body.args) == 2
            return Expr(:escape, body.args[2])
        end
    elseif Meta.isexpr(body, [:ref, :.])
        return Expr(body.head, prepend_obj(body.args[1], obj, skip), map(esc, body.args[2:end])...)
    elseif Meta.isexpr(body, [:comprehension, :generator])
        inner_generator = Meta.isexpr(body.args[1], :generator)
        args = inner_generator ? body.args[1].args : body.args
        length(args) == 2 || error("unsupported expression")
        Meta.isexpr(args[2], :(=)) || error("unsupported expression")

        iter = prepend_obj(args[2].args[2], obj, skip)

        var = args[2].args[1]
        update_skiplist!(var, skip)

        ex = prepend_obj(args[1], obj, skip)
        genargs = Expr(:(=), esc(var), iter)

        return inner_generator ?
                Expr(body.head, Expr(:generator, ex, genargs)) :
                Expr(body.head, ex, genargs)

    else
        return Expr(body.head, map(x->prepend_obj(x, obj, skip), body.args)...)
    end
end

end # module


text:
function main()
    println("Hello, world!")
end

main()


text:
using Test
using IncrementalInference

@testset "test multihypo chain example (see #462)..." begin

l1 = -10.0
l2 = +10.0
lnoise = 1.0
x1 = 0
x2 = 0
Onoise = 0.1

fg = initfg()

addVariable!(fg, :x1, ContinuousScalar)
addVariable!(fg, :x2, ContinuousScalar)
addVariable!(fg, :l1, ContinuousScalar)
addVariable!(fg, :l1_0, ContinuousScalar)
addVariable!(fg, :l2, ContinuousScalar)
addVariable!(fg, :l2_0, ContinuousScalar)

# priors on two landmarks only
addFactor!(fg, [:l1], Prior(Normal(l1, lnoise)))
addFactor!(fg, [:l2], Prior(Normal(l2, lnoise)))

# relative constraints
addFactor!(fg, [:x1;:l1;:l1_0], LinearRelative(Normal(l1-x1, lnoise)), multihypo=[1;1/2;1/2])
addFactor!(fg, [:x2;:l2;:l2_0], LinearRelative(Normal(l2-x2, lnoise)), multihypo=[1;1/2;1/2])
addFactor!(fg, [:x1;:x2], LinearRelative(Normal(0, Onoise)))

tree, smt, hist = solveTree!(fg)

# drawTree(tree, show=true)

# expect x1 x2 to have at least one mode at 0

@test getPPE(fg, :x1).suggested[1] - x1 |> abs < 1
@test getPPE(fg, :x2).suggested[1] - x2 |> abs < 1

@test getPPE(fg, :l1).suggested[1] - l1 |> abs < 1
@test getPPE(fg, :l2).suggested[1] - l2 |> abs < 1

# l1_0, l2_0 should be nearby around l1 and l2, but cannot confirm 100%
@test getPPE(fg, :l1_0).suggested[1] - l1 |> abs < 10
@test getPPE(fg, :l2_0).suggested[1] - l2 |> abs < 10

end

# using RoMEPlotting
# Gadfly.set_default_plot_size(35cm,25cm)
#
# plotKDE(fg, [:l1;:l2])
# plotKDE(fg, [:l1_0;:l2_0])
# plotKDE(fg, [:x1;:x2])

#


text:
@assert !@isdefined USE_GPU
const USE_GPU = length(ARGS) > 0 && ARGS[1] == "gpu"

using CUDA
import MPI
using ImplicitGlobalGrid
using ParallelStencil
using ParallelStencil.FiniteDifferences3D
using BenchmarkTools
using DataFrames
using CSV
using Statistics
using Pidfile

algorithm = ""
try
    global algorithm
    algorithm = ARGS[2]
catch
    println("Usage: julia --project scripts/part1_benchmark.jl [cpu/gpu] [array/kernel]")
    exit()
end

## Trick so we can include this file with cpu or gpu
if abspath(PROGRAM_FILE) == @__FILE__
    @static if USE_GPU
        @init_parallel_stencil(CUDA, Float64, 3)
        println("Init parallel stencil for GPU.")
    else
        @init_parallel_stencil(Threads, Float64, 3)
        println("Init parallel stencil for CPU.")
    end
end

include("part1_array_programming.jl")
include("part1_kernel_programming.jl")

BenchTask = @NamedTuple {nx::Int, ny::Int, nz::Int}
BenchResult = @NamedTuple {
    device::String,
    algorithm::String,
    MPI_world_size::Int,
    n_threads::Int,
    nx::Int,
    ny::Int,
    nz::Int,
    mean::Float64,
    median::Float64,
    min::Float64,
    max::Float64,
    std::Float64,
}
tasks = DataFrame([BenchTask(round.(Int, (2^e, 2^e, 2^e))) for e = 4:0.5:7])

MPI.Init()
for t in eachrow(tasks)
    nx_, ny_, nz_ = t

    b = begin
        if algorithm == "array"
            @benchmark diffusion_3D_array_programming(nx = $nx_, ny = $ny_, nz = $nz_, verbose= false, init_and_finalize_MPI = false)
        elseif algorithm == "kernel"
            @benchmark diffusion_3D_kernel_programming(nx = $nx_, ny = $ny_, nz = $nz_, verbose= false, init_and_finalize_MPI = false)
        end
    end

    if MPI.Comm_rank(MPI.COMM_WORLD) == 0
        bench_res = BenchResult((
            device = (USE_GPU ? "gpu" : "cpu"),
            algorithm = algorithm,
            MPI_world_size = MPI.Comm_size(MPI.COMM_WORLD),
            n_threads = Threads.nthreads(),
            nx = nx_,
            ny = ny_,
            nz = nz_,
            mean = mean(b).time * 1e-9,
            median = median(b).time * 1e-9,
            min = minimum(b).time * 1e-9,
            max = maximum(b).time * 1e-9,
            std = std(b).time * 1e-9,
        ))

        mkpidlock("bench_results.lck") do
            results_df = begin
                try
                    DataFrame(CSV.File("bench_results.csv"))
                catch
                    DataFrame()
                end
            end

            results_df = vcat(results_df, DataFrame([bench_res]))
            CSV.write("bench_results.csv", results_df)
        end
        println(results_df)
    end
end
MPI.Finalize()


text:
@testset "generic.jl" begin
    # alternative implementation of white kernel
    struct WhiteKernel2 <: Kernel end
    (::WhiteKernel2)(x, y) = x == y

    # alternative implementation TensorProductKernel
    struct TensorProduct2{K1<:Kernel,K2<:Kernel} <: Kernel
        kernel1::K1
        kernel2::K2
    end
    function (kernel::TensorProduct2)((x1, x2), (y1, y2))
        return kernel.kernel1(x1, y1) * kernel.kernel2(x2, y2)
    end

    @testset "binary classification" begin
        # probabilities and boolean targets
        p, p̃ = rand(2)
        y, ỹ = rand(Bool, 2)
        scale = rand()
        kernel = SqExponentialKernel() ∘ ScaleTransform(scale)
        val = unsafe_skce_eval(kernel ⊗ WhiteKernel(), p, y, p̃, ỹ)
        @test unsafe_skce_eval(kernel ⊗ WhiteKernel2(), p, y, p̃, ỹ) ≈ val
        @test unsafe_skce_eval(TensorProduct2(kernel, WhiteKernel()), p, y, p̃, ỹ) ≈ val
        @test unsafe_skce_eval(TensorProduct2(kernel, WhiteKernel2()), p, y, p̃, ỹ) ≈ val

        # corresponding values and kernel for full categorical distribution
        pfull = [p, 1 - p]
        yint = 2 - y
        p̃full = [p̃, 1 - p̃]
        ỹint = 2 - ỹ
        kernelfull = SqExponentialKernel() ∘ ScaleTransform(scale / sqrt(2))

        @test unsafe_skce_eval(kernelfull ⊗ WhiteKernel(), pfull, yint, p̃full, ỹint) ≈ val
        @test unsafe_skce_eval(kernelfull ⊗ WhiteKernel2(), pfull, yint, p̃full, ỹint) ≈
              val
        @test unsafe_skce_eval(
            TensorProduct2(kernelfull, WhiteKernel()), pfull, yint, p̃full, ỹint
        ) ≈ val
        @test unsafe_skce_eval(
            TensorProduct2(kernelfull, WhiteKernel2()), pfull, yint, p̃full, ỹint
        ) ≈ val
    end

    @testset "multi-class classification" begin
        n = 10
        p = rand(n)
        p ./= sum(p)
        y = rand(1:n)
        p̃ = rand(n)
        p̃ ./= sum(p̃)
        ỹ = rand(1:n)

        kernel = SqExponentialKernel() ∘ ScaleTransform(rand())
        val = unsafe_skce_eval(kernel ⊗ WhiteKernel(), p, y, p̃, ỹ)

        @test unsafe_skce_eval(kernel ⊗ WhiteKernel2(), p, y, p̃, ỹ) ≈ val
        @test unsafe_skce_eval(TensorProduct2(kernel, WhiteKernel()), p, y, p̃, ỹ) ≈ val
        @test unsafe_skce_eval(TensorProduct2(kernel, WhiteKernel2()), p, y, p̃, ỹ) ≈ val
    end
end


text:
module Retry

export @repeat, @protected

include("repeat_try.jl")
include("protected_try.jl")

end # module


text:
# partition function terms
partition_function(E, g, T) = g * exp(-E / (k_mhz * T))

partition_function(l::Level, temperature) = partition_function(l.E, l.g, T)

# evaluate the partition function based on levels
function partition_function(ls::Levels, temperature)
  @tullio q[i] := partition_function(ls[i].e, ls[i].g, temperature)
  return q, sum(q)
end

abstract type PartitionFunction end

struct InterpPartitionFunction
  interp_obj
end

"""Constructor method for interpolated partition function objects.
Takes in a vector of temperatures, and a vector of values of the
partition function at each temperature.
"""
function InterpPartitionFunction(temperatures::Vector{T}, values::Vector{T}) where T<:Real
  interpolant = LinearInterpolation(temperatures, values)
  InterpPartitionFunction(interpolant)
end

(interp::InterpPartitionFunction)(temperature) = interp.interp_obj(temperature)

"""Read in a qpart file in the molsim format; first line is a header
that specifies the type of partition function evaluation needed, which
is parsed and used with multiple dispatch to determine how to read
the rest of the qpart file.
"""
function read_qpart(filepath)
  open(filepath) do file
    header = readline(file)
    qpart_type = occursin("interp", header) ? :IsInterp : throw(MethodError(header, " qpart format not recognized."))
    read_qpart(file, Val(qpart_type))
  end
end

"""Read in an interpolated partition function
"""
function read_qpart(file, ::Val{:IsInterp})
  lines = readlines(file)
  # ignore comment lines
  data = filter(x->~startswith(lstrip(x), "#"), lines)
  # split by whitespace, then reduce into a 2xN matrix and convert to numbers
  values_matrix = mapreduce(split, hcat, data) .|> x -> parse(Float32, x)
  # sort the values in ascending order
  sort!(values_matrix, dims=2)
  return InterpPartitionFunction(values_matrix[1,:], values_matrix[2,:])
end