LP
Simple C/C++ interface to COIN-OR CBC, CPLEX, GLPK and GUROBI, with some interesting features
Macros | Typedefs | Functions
lp.h File Reference

Header for the C API of lp, including functions to create, modify and optimize Mixed Integer Linear Programming Problems. More...

Go to the source code of this file.

Macros

#define LP_ME_DEFAULT   0
 
#define LP_ME_OPTIMALITY   1
 
#define LP_ME_FEASIBILITY   2
 
#define LP_MIN   0
 
#define LP_MAX   1
 
#define LP_OPTIMAL   0
 
#define LP_INFEASIBLE   1
 
#define LP_UNBOUNDED   2
 
#define LP_FEASIBLE   3
 
#define LP_INTINFEASIBLE   4
 
#define LP_NO_SOL_FOUND   5
 
#define LP_ERROR   6
 
#define LP_CUT_TYPES   8
 
#define LPC_GOMORY   0
 
#define LPC_REDUCE   1
 
#define LPC_MIR   2
 
#define LPC_TWO_MIR   3
 
#define LPC_L_AND_P   4
 
#define LPC_ZERO_HALF   5
 
#define LPC_KNAPSACK   6
 
#define LPC_FLOW   7
 
#define CONS_PARTITIONING   0
 
#define CONS_PACKING   1
 
#define CONS_COVERING   2
 
#define CONS_CARDINALITY   3
 
#define CONS_KNAPSACK   4
 
#define CONS_INV_KNAPSACK   5
 
#define CONS_FLOW_BIN   6
 
#define CONS_FLOW_INT   7
 
#define CONS_FLOW_MX   8
 
#define CONS_VBOUND   9
 
#define CONS_OTHER   10
 
#define CONS_NUMBER   11 /* number of types */
 
#define LPCB_CUTS   0
 
#define LPCB_HEUR   1
 

Typedefs

typedef struct _LinearProgram LinearProgram
 
typedef LinearProgramLinearProgramPtr
 
typedef int(* lp_cb) (LinearProgram *lp, int whereFrom, const int *origCols, LinearProgram *origLP, void *data)
 

Functions

LinearProgramlp_create ()
 Creates an empty problem. More...
 
LinearProgramlp_clone (LinearProgram *lp)
 Clones the problem in lp.
 
void lp_read (LinearProgram *lp, const char *fileName)
 Reads a .lp or .mps file in fileName to object lp.
 
void lp_write_lp (LinearProgram *lp, const char *fileName)
 saves the problem in lp to file fileName. Use extension .lp or .mps to define file format.
 
void lp_add_col (LinearProgram *lp, double obj, double lb, double ub, char integer, char *name, int nz, int *rowIdx, double *rowCoef)
 adds a new column (variable) More...
 
void lp_add_cols (LinearProgram *lp, const int count, double *obj, double *lb, double *ub, char *integer, char **name)
 adds new columns (variables) More...
 
void lp_add_cols_same_bound (LinearProgram *lp, const int count, double *obj, double lb, double ub, char *integer, char **name)
 adds set of columns with the same bounds More...
 
void lp_add_bin_cols (LinearProgram *lp, const int count, double *obj, char **name)
 adds a set of binary variables More...
 
void lp_add_row (LinearProgram *lp, const int nz, int *indexes, double *coefs, const char *name, char sense, const double rhs)
 
void lp_add_rows (LinearProgram *lp, int nRows, int *starts, int *idx, double *coef, char *sense, double *rhs, const char **names)
 
void lp_remove_row (LinearProgram *lp, int idxRow)
 Removes a row from lp. More...
 
void lp_remove_rows (LinearProgram *lp, int nRows, int *rows)
 Removes a set of rows from lp Removes a set of rows from lp, calling this function is usually faster than to remove rows one-by-one. More...
 
void lp_set_direction (LinearProgram *lp, const char direction)
 sets optimization direction, maximization or minimization More...
 
int lp_get_direction (LinearProgram *lp)
 returns optimization direction, minimization (LP_MIN) or maximization (LP_MAX) More...
 
void lp_set_obj (LinearProgram *lp, double obj[])
 sets objective function coefficients More...
 
void lp_chg_obj (LinearProgram *lp, int count, int idx[], double obj[])
 changes a set of objective function coefficients More...
 
void lp_set_rhs (LinearProgram *lp, int row, double rhs)
 modifies the right-hand-side of a constraint More...
 
void lp_set_col_bounds (LinearProgram *lp, int col, const double lb, const double ub)
 changes lower and upper bound of a column More...
 
void lp_fix_col (LinearProgram *lp, int col, double val)
 fixed a column to a value More...
 
void lp_set_integer (LinearProgram *lp, int nCols, int cols[])
 sets the type of some variables to integer More...
 
void lp_write_sol (LinearProgram *lp, const char *fileName)
 Saves the incumbent solution in for lp in fileName. More...
 
void lp_load_mip_start (LinearProgram *lp, int count, const char **colNames, const double *colValues)
 Enters a initial feasible solution for the problem. Variables are referenced by their names. Only the main decision variables need to be informed. More...
 
void lp_load_mip_starti (LinearProgram *lp, int count, const int *colIndexes, const double *colValues)
 Enters a initial feasible solution for the problem using column indexes. Only the main decision variables need to be informed. More...
 
int lp_read_mip_start (LinearProgram *lp, const char *fileName)
 Loads from fileName an initial feasible solution. More...
 
void lp_save_mip_start (LinearProgram *lp, const char *fileName)
 saves the solution entered as MIPStart More...
 
void lp_mipstart_debug (LinearProgram *lp)
 tries to discover the source of infeasibility in MIPStart More...
 
void lp_fix_mipstart (LinearProgram *lp)
 For debugging purposes: fixes mipstart variables one by one and optimizes (if initial solution is invalid at some point an infeasible LP will appear) More...
 
void lp_free (LinearProgramPtr *lp)
 releases from memory the problem stored in lp More...
 
void lp_close_env ()
 frees environment static memory at the end of the program More...
 
int lp_optimize (LinearProgram *lp)
 Optimizes your Mixed Integer Program. More...
 
int lp_optimize_as_continuous (LinearProgram *lp)
 optimizes only the linear programming relaxation of your MIP More...
 
double lp_obj_value (LinearProgram *lp)
 objective value of your optimization More...
 
double lp_best_bound (LinearProgram *lp)
 returns the best dual bound found during the search More...
 
double * lp_x (LinearProgram *lp)
 returns the vector of solution values More...
 
double * lp_row_slack (LinearProgram *lp)
 
double * lp_row_price (LinearProgram *lp)
 
double * lp_reduced_cost (LinearProgram *lp)
 reduced cost for columns - only available when solving continous models More...
 
int lp_num_saved_sols (LinearProgram *lp)
 number of solutions stored in the solution pool More...
 
double lp_saved_sol_obj (LinearProgram *lp, int isol)
 objective value for the isol-th solution of the solution pool More...
 
double * lp_saved_sol_x (LinearProgram *lp, int isol)
 objective value for the isol-th solution of the solution pool More...
 
LinearProgramlp_pre_process (LinearProgram *lp)
 
void lp_add_cutoff (LinearProgram *lp, double cutoff, char addConstraint)
 
void lp_set_branching_priorities (LinearProgram *lp, int *priorities)
 
void lp_set_branching_direction (LinearProgram *lp, int direction)
 
void lp_set_mip_emphasis (LinearProgram *lp, const int mipEmphasis)
 
int lp_get_mip_emphasis (LinearProgram *lp)
 
char * lp_status_str (int status, char *statusStr)
 
double lp_solution_time (LinearProgram *lp)
 
int lp_strengthen_with_cuts (LinearProgram *lp, const int maxRoundsCuts[])
 
void lp_add_cut (LinearProgram *lp, int nz, int *cutIdx, double *cutCoef, const char *name, char sense, double rhs)
 
void lp_parse_options (LinearProgram *lp, int argc, const char **argv)
 
void lp_help_options ()
 
void lp_set_sol_out_file_name (LinearProgram *lp, const char *sfn)
 
void lp_set_sol_in_file_name (LinearProgram *lp, const char *sfn)
 
void lp_set_heur_proximity (LinearProgram *lp, char onOff)
 
void lp_set_heur_fp_passes (LinearProgram *lp, int passes)
 
void lp_set_cuts (LinearProgram *lp, char onOff)
 
void lp_set_print_messages (LinearProgram *lp, char onOff)
 
void lp_set_max_seconds (LinearProgram *lp, int _max)
 
void lp_set_max_solutions (LinearProgram *lp, int _max)
 
void lp_set_max_nodes (LinearProgram *lp, int _max)
 
void lp_set_max_saved_sols (LinearProgram *lp, int _max)
 
void lp_set_abs_mip_gap (LinearProgram *lp, const double _value)
 
void lp_set_rel_mip_gap (LinearProgram *lp, const double _value)
 
void lp_set_parallel (LinearProgram *lp, char onOff)
 
char lp_is_mip (LinearProgram *lp)
 checks if there are integer variables in this program More...
 
char lp_is_integer (LinearProgram *lp, const int j)
 checks if a given variable is integer or continuous More...
 
char lp_is_binary (LinearProgram *lp, const int j)
 checks if a given variable is binary or not More...
 
void lp_cols_by_type (LinearProgram *lp, int *binaries, int *integers, int *continuous)
 counts the number of binary, general integer and continuous variables in this problem More...
 
int lp_cols (LinearProgram *lp)
 returns the numbef of columns (variables) in a given problem More...
 
int lp_rows (LinearProgram *lp)
 returns the numbef of rows (linear constraints) in a given problem More...
 
int lp_nz (LinearProgram *lp)
 returns the numbef of non-zero coefficients in the linear program rows More...
 
int lp_row (LinearProgram *lp, int row, int *idx, double *coef)
 gets the contents of a given row (linear constraint) More...
 
int lp_col (LinearProgram *lp, int col, int *idx, double *coef)
 gets the contents of a given column (variable) More...
 
double lp_rhs (LinearProgram *lp, int row)
 return the right hand side of a given row More...
 
char lp_sense (LinearProgram *lp, int row)
 returns the sense of a given constraints More...
 
char * lp_row_name (LinearProgram *lp, int row, char *dest)
 queries a row name More...
 
char * lp_col_name (LinearProgram *lp, int col, char *dest)
 queries a column name More...
 
double lp_col_lb (LinearProgram *lp, int col)
 queries a column lower bound More...
 
double lp_col_ub (LinearProgram *lp, int col)
 queries a column upper bound More...
 
int lp_col_index (LinearProgram *lp, const char *name)
 returns the column (variable) index of a given column name More...
 
int lp_row_index (LinearProgram *lp, const char *name)
 returns the row (linear constraint) index of a given row name More...
 
const double * lp_obj_coef (LinearProgram *lp)
 return the vector with objective coefficients More...
 
int lp_row_type (LinearProgram *lp, const int row)
 returns the constraint type of a given row More...
 
void lp_rows_by_type (LinearProgram *lp, int rtype[])
 fills the constraint types vector More...
 
int * lp_original_colummns (LinearProgram *lp)
 if this is a pre-processed problem, returns indexes of respective original columns More...
 
void lp_set_callback (LinearProgram *lp, lp_cb callback, void *data)
 
void lp_set_store_names (bool store)
 

Detailed Description

Header for the C API of lp, including functions to create, modify and optimize Mixed Integer Linear Programming Problems.

Author
D.Sc. Haroldo G. Santos
Date
8/2/2016