# Changes from version 4 to version 5.1

### Main features and changes to v5.1 compared to v4

Overall, the v5 code is faster and more robust than v4. This robustness is for example proven by the fact that many more models can now be solved even without scaling. However, scaling should still be considered. The API has also routine to do a crash of basis (determine a starting point so that solving goes faster). The lp_solve program has been extended with options to handle the new functionality. It now also has options to write the model in the different file formats.

- The modularization started in v4 has been significantly enhanced.
- Internal logic and naming is much more in compliance with conventional usage.
- Advanced pricing using Devex and Steepest Edge for both primal and dual simplexes.
- Scaling behavior is made more consistent and many more options are available.
- Presolve has been radically expanded.
- A crash basis routine has been added to determine a starting point. This can improve solving time.
- It is now possible to select desired combinations of primal and dual phases 1 and 2.
- The native etaPFI/inverse has been improved with optimization of column ordering.
- Alternative inverse/re-factorization libraries can be used by lp_solve. See Basis Factorization Packages
- Alternative model readers and writers possible via the XLI implementation. See External Language Interfaces
- B&B code has been made non-recursive (no more stack overflows!).
- MIP contains many more variable selection and branching strategies, including pseudo-costs.
- SOS and SC handling is faster (more branches avoided).
- LP file support is expanded and now also includes full CPLEX LP format support.
- Building the model via the API interface row by row can be improved spectacular by calling the new API call set_add_rowmode.

### Changes in lp_solve program

The lp_solve program has many new options to make use of as many as possible possibilities of lpsolve. There are several extra options, some are extended and some are removed because they are obsolete. See lp_solve for a list of all possible options. Note that on this link there is also a reference to the API call(s) that are used for this option. There you can find more information on the option. See the list above for some of the new features.

### What happened with lp2mps, mps2lp ?

These programs are removed. But don't panic, there is another way to convert from one format to another. This via the lp_solve program. This is done because of the support of a new format: The CPLEX-format. Because there are now 3 formats supported, it would have required 6 programs to convert from one format to another. Instead of doing this, lp_solve has new parameters to be able to write the model to a file, and that in all formats. So, lp_solve can read the model in any format and write it back in any format. In that case, it is most likely not whished to also calculate the model and therefore the parameter -parse_only can be used. Here some examples how to convert from one format to another:
lp to mps: lp_solve -parse_only -lp lpfile -wmps mpsfile
mps to lp: lp_solve -parse_only -mps mpsfile -wlp lpfile
It is even possible to generate several formats at the same time:
lp to all formats: lp_solve -parse_only -lp lpfile -wlp lpfile -wmps mpsfile

### Changes in API calls

The API is not that much changed, but has been expanded to handle new functionality. Some simplification has taken place, for example in scaling, and a call to auto_scale is not necessary any more.
However the changes in some routines is big enough to break compatibility with version 4. Be aware of this. You must review your source code for the mentioned functions. Especially those with a (!) behind are very important to check. That is also the reason why the Windows dll will be called lpsolve51.dll compared to lpsolve.dll for version 4. Don't just rename this dll and expect that your program will work then.

#### Changed API calls

- add_column, str_add_column
  - Return value is now unsigned char instead of int

- add_constraint, str_add_constraint (!)
  - Return value is now unsigned char instead of int
  - Variable constr_type is now int instead of short
  - The constant LE has now value 1 instead of 0
    The constant EQ has now value 3 instead of 1

- add_lag_con, str_add_lag_con (!)
  - Return value is now unsigned char instead of int
  - Variable constr_type is now int instead of short
  - The constant LE has now value 1 instead of 0
    The constant EQ has now value 3 instead of 1

- add_sos (!)
  - Variable sostype is now int instead of short

- column_in_lp (!)
  - Return value is now int instead of unsigned char

- del_column
  - Return value is now unsigned char instead of int

- del_constraint
  - Return value is now unsigned char instead of int

- get_basis (!)
  - An extra variable is added to the argument list: nonbasic

- get_bb_floorfirst (!)
  - This function is renamed. Before it was called get_floor_first
  - Return value is now int instead of short

- get_bb_rule (!)
  - Return value is now int instead of short
  - The function returns different constants for different rules.

- get_bounds_tighter
  - Return value is now unsigned char instead of int

- get_col_name
  - When no name is set, the function now returns Cx instead of v_x

- get_column
  - Return value is now unsigned char instead of int

- get_constr_type (!)
  - The constant LE has now value 1 instead of 0
    The constant EQ has now value 3 instead of 1

- get_constraints, get_ptr_constraints
  - Return value is now unsigned char instead of int

- get_improve (!)
  - Return value is now int instead of short
  - Constant IMPROVE_FULL is renamed to IMPROVE_SOLVE
  - New constant IMPROVE_INVERSE

- get_infinite (!)
  - The new default infinite value is 1e30 instead of 1e24

- get_lambda, get_ptr_lambda
  - Return value is now unsigned char instead of int

- get_maxpivot
  - This function is renamed. Before it was called get_max_num_inv

- get_mip_gap (!)
  - An extra variable is added to the argument list: absolute

- get_pivoting (!)
  - This function is renamed. Before it was called get_piv_rule
  - Return value is now int instead of short
  - The function returns different constants for different rules.

- get_presolve (!)
  - This function is renamed. Before it was called is_do_presolve
  - Return value is now int instead of short
  - The function now returns constants instead of FALSE or TRUE.

- get_primal_solution, get_ptr_primal_solution
  - Return value is now unsigned char instead of int

- get_print_sol (!)
  - This function is renamed. Before it was called is_print_sol
  - Return value is now int instead of short
  - The function now also returns the constant AUTOMATIC.

- get_rh_range (!)
  - The new default range value is 1e30 instead of 1e24

- get_row
  - Return value is now unsigned char instead of int

- get_row_name
  - When no name is set, the function now returns Rx instead of r_x

- get_scaling (!)
  - This function is renamed. Before it was called get_scalemode
  - Return value is now int instead of short
  - The function returns different constants.

- get_sensitivity_obj, get_ptr_sensitivity_obj, get_sensitivity_objex, get_ptr_sensitivity_objex (!)
  - Return value is now unsigned char instead of int
  - If there are integer variables, then these functions only work if set_presolve is called with parameter PRESOLVE_SENSDUALS before solve.

- get_sensitivity_rhs, get_ptr_sensitivity_rhs, get_dual_solution, get_ptr_dual_solution (!)
  - Return value is now unsigned char instead of int
  - If there are integer variables, then these functions only work if set_presolve is called with parameter PRESOLVE_SENSDUALS before solve.
  - get_dual_solution is renamed. Before it was called get_reduced_costs
  - get_ptr_dual_solution is renamed. Before it was called get_ptr_reduced_costs

- get_upbo (!)
  - The new default upper bound is 1e30 instead of 1e24

- get_var_branch
  - Return value is now int instead of short

- get_var_priority (!)
  - This function is renamed. Before it was called get_varpriority

- get_variables, get_ptr_variables
  - Return value is now unsigned char instead of int

- get_verbose (!)
  - Return value is now int instead of short
  - Return value can now also be NEUTRAL

- is_anti_degen (!)
  - Return value is now unsigned char instead of short
  - An extra variable is added to the argument list: testmask

- is_break_at_first
  - Return value is now unsigned char instead of short

- is_debug
  - Return value is now unsigned char instead of short

- is_feasible (!)
  - Return value is now unsigned char instead of int
  - An extra variable is added to the argument list: threshold

- is_int
  - Return value is now unsigned char instead of int

- is_lag_trace
  - Return value is now unsigned char instead of short

- is_presolve (!)
  - This function is renamed. Before it was called is_do_presolve
  - Return value is now unsigned char instead of short
  - An extra variable is added to the argument list: testmask

- is_SOS_var
  - Return value is now unsigned char instead of int

- is_trace
  - Return value is now unsigned char instead of short

- print_constraints (!)
  - An extra variable is added to the argument list: columns

- print_solution (!)
  - An extra variable is added to the argument list: columns

- read_lp, read_LP
  - Variable verbose is now int instead of short

- read_mps, read_MPS
  - Variable verbose is now int instead of short

- set_anti_degen (!)
  - Variable anti_degen is now int instead of short. Instead of FALSE/TRUE it takes new constants.

- set_basis (!)
  - An extra variable is added to the argument list: nonbasic

- set_bb_floorfirst (!)
  - This function is renamed. Before it was called set_floor_first
  - Variable branch_mode is now int instead of short

- set_bb_rule (!)
  - Variable bb_rule is now int instead of short
  - Variable bb_rule now takes other constants.

- set_bounds
  - Return value is now unsigned char instead of int

- set_bounds_tighter
  - Variable tighten is now unsigned char instead of int

- set_break_at_first
  - Variable break_at_first is now unsigned char instead of short

- set_col_name
  - Return value is now unsigned char instead of int

- set_constr_type (!)
  - Return value is now unsigned char instead of int
  - Variable constr_type is now int instead of short
  - The constant LE has now value 1 instead of 0
    The constant EQ has now value 3 instead of 1

- set_debug
  - Variable debug is now unsigned char instead of short

- set_epsint (!)
  - This function is renamed. Before it was called set_epsilon

- set_improve (!)
  - Variable improve is now int instead of short
  - Constant IMPROVE_FULL is renamed to IMPROVE_SOLVE
  - New constant IMPROVE_INVERSE

- set_int
  - Return value is now unsigned char instead of int
  - Variable must_be_int is now unsigned char instead of short

- set_lag_trace
  - Variable lag_trace is now unsigned char instead of short

- set_lowbo
  - Return value is now unsigned char instead of int

- set_lp_name
  - Return value is now unsigned char instead of int

- set_mat
  - Return value is now unsigned char instead of int

- set_maxpivot
  - This function is renamed. Before it was called set_max_num_inv

- set_mip_gap (!)
  - An extra variable is added to the argument list: absolute

- set_obj_fn, str_set_obj_fn
  - Return value is now unsigned char instead of int

- set_outputstream, set_outputfile (!)
  - The function set_outputfile is renamed. Before it was called print_file
  - Variable lp is added. Output is now set per lp.
  - The function set_outputstream is new

- set_pivoting (!)
  - This function is renamed. Before it was called set_piv_rule
  - Variable pivot_rule is now int instead of short
  - The function uses different constants for different rules.

- set_presolve (!)
  - This function is renamed. Before it was called set_do_presolve
  - Variable do_presolve is now int instead of short
  - The function uses different constants for different rules.

- set_print_sol (!)
  - Variable print_sol is now int instead of short
  - Variable print_sol now also takes the value AUTOMATIC.

- set_rh
  - Return value is now unsigned char instead of int

- set_rh_range
  - Return value is now unsigned char instead of int

- str_set_rh_vec
  - Return value is now unsigned char instead of int

- set_row_name
  - Return value is now unsigned char instead of int

- set_scaling (!)
  - This function is renamed. Before it was called set_scalemode
  - Variable scalemode is now int instead of short
  - The function uses different constants for different rules

- set_semicont
  - Return value is now unsigned char instead of int
  - Variable must_be_sc is now unsigned char instead of short

- set_trace (!)
  - Variable trace is now unsigned char instead of short

- set_upbo
  - Return value is now unsigned char instead of int

- set_var_branch
  - Return value is now unsigned char instead of int
  - Variable branch_mode is now int instead of short

- set_var_weights (!)
  - This function is renamed. Before it was called set_varweights
  - Return value is now unsigned char instead of int

- set_verbose (!)
  - Variable verbose is now int instead of short
  - Variable verbose can now also be NEUTRAL.

- solve (!)
  - The return values of this function have changed.

- write_lp, write_LP
  - Return value is now unsigned char instead of int

- write_mps, write_MPS
  - Return value is now unsigned char instead of int

#### New API calls

- add_columnex

- add_constraintex

- default_basis

- free_lp

- get_anti_degen

- get_basiscrash

- get_bb_depthlimit

- get_bb_floorfirst
  - This function is renamed. Before it was called get_floor_first

- get_origcol_name

- get_dual_solution, get_ptr_dual_solution
  - These functions are renamed. Before they were called get_reduced_costs, get_ptr_reduced_costs

- get_maxpivot
  - This function is renamed. Before it was called get_max_num_inv

- get_nameindex

- get_nonzeros

- get_pivoting
  - This function is renamed. Before it was called get_piv_rule

- get_presolve
  - This function is renamed. Before it was called is_do_presolve

- get_var_primalresult

- get_print_sol
  - This function is renamed. Before it was called is_print_sol

- get_origrow_name

- get_simplextype

- get_scalelimit

- get_scaling
  - The function get_scaling is renamed. Before it was called get_scalemode

- get_scaling
  - The function get_scaling is renamed. Before it was called get_scalemode

- get_var_dualresult

- get_solutioncount

- get_solutionlimit

- get_status

- get_statustext

- get_var_priority
  - This function is renamed. Before it was called get_varpriority

- get_working_objective

- has_BFP

- has_XLI

- is_add_rowmode

- is_binary

- is_constr_type

- is_unbounded

- is_infinite

- is_integerscaling

- is_maxim

- is_nativeBFP

- is_nativeXLI

- is_negative

- is_piv_rule

- is_piv_mode
  - This function is renamed. Before it was called is_piv_strategy

- is_presolve
  - This function is renamed. Before it was called is_do_presolve

- is_scalemode

- is_scaletype

- is_semicont

- print_str

- print_tableau

- put_msgfunc

- read_basis

- read_freemps, read_freeMPS

- read_XLI

- set_add_rowmode

- set_basiscrash

- set_bb_depthlimit

- set_bb_floorfirst
  - This function is renamed. Before it was called set_floor_first

- set_BFP

- set_column, set_columnex

- set_XLI

- set_binary

- set_unbounded

- set_epsint
  - The function set_epsint is renamed. Before it was called set_epsilon

- set_maxpivot
  - This function is renamed. Before it was called set_max_num_inv

- set_obj

- set_obj_fnex

- set_outputstream, set_outputfile
  - The function set_outputfile is renamed. Before it was called print_file
  - The function set_outputstream is new

- set_pivoting
  - This function is renamed. Before it was called set_piv_rule

- set_preferdual

- set_presolve
  - This function is renamed. Before it was called set_do_presolve

- set_row, set_rowex

- set_scalelimit

- set_scaling
  - The function set_scaling is renamed. Before it was called set_scalemode

- set_sense

- set_simplextype

- set_solutionlimit

- set_var_weights
  - This function is renamed. Before it was called set_varweights

- time_elapsed

- print_debugdump

- write_freemps, write_freeMPS

- write_XLI

#### Removed API calls

- auto_scale
  - This function is no longer required to be called. lpsolve calls it automatically when set_scaling was called to specify a scaling mode. Therefore, this function is no longer exported from the lpsolve library.

- copy_lp

- get_floor_first
  - Use get_bb_floorfirst instead

- get_max_num_inv
  - Use get_maxpivot instead

- get_pivot_rule
  - Use get_pivoting instead

- get_ptr_work_solution

- get_splitnegvars

- get_reduced_costs, get_ptr_reduced_costs
  - Use get_dual_solution, get_ptr_dual_solution instead

- get_varpriority
  - Use get_var_priority instead

- get_work_solution

- is_do_presolve
  - Use get_presolve instead

- is_print_at_invert

- is_print_sol
  - Use get_print_sol instead

- is_do_presolve
  - Use is_presolve instead

- is_piv_strategy
  - Use is_piv_mode instead

- read_lp_file
  - Use read_lp instead

- mat_elm
  - Use get_mat instead

- print_file
  - Use set_outputfile instead

- set_do_presolve
  - Use set_presolve instead

- set_floor_first
  - Use set_bb_floorfirst instead

- set_lowrange
  - Use set_rh_range instead

- set_max_num_inv
  - Use set_maxpivot instead

- set_pivot_rule
  - Use set_pivoting instead

- set_print_at_invert

- set_scalemode
  - Use set_scaling instead

- set_splitnegvars

- set_uprange
  - Use set_rh_range instead

- set_varweights
  - Use set_var_weights instead