| 1 | # [Further features](@id guide-further) |
| 2 | |
| 3 | ## Model and solution management |
| 4 | |
| 5 | HiGHS has comprehensive tools for defining and extracting models. This can be |
| 6 | done either to/from MPS or (CPLEX) format LP files, or via method calls. HiGHS |
| 7 | also has methods that permit the incumbent model to be modified. Solutions can |
| 8 | be supplied and extracted using either files or method calls. |
| 9 | |
| 10 | ### Extracting model data |
| 11 | |
| 12 | The numbers of column, rows and nonzeros in the model are returned by the |
| 13 | methods [`getNumCols`](@ref Get-model-data), [`getNumRows`](@ref Get-model-data), |
| 14 | and [`getNumEntries`](@ref Get-model-data) respectively. |
| 15 | |
| 16 | Model data can be extracted for a single column or row by specifying the index |
| 17 | of the column or row and calling the methods [`getCol`](@ref Get-model-data) and |
| 18 | [`getRow`](@ref Get-model-data). |
| 19 | |
| 20 | As well as returning the value of the cost and bounds, these methods also return |
| 21 | the number of nonzeros in the corresponding column or row of the constraint |
| 22 | matrix. The indices and values of the nonzeros can be obtained using the methods |
| 23 | [`getColEntries`](@ref Get-model-data) and [`getRowEntries`](@ref Get-model-data). |
| 24 | |
| 25 | For multiple columns and rows defined by a set of indices, the corresponding |
| 26 | data can be extracted using the methods [`getCols`](@ref Get-model-data), |
| 27 | [`getRows`](@ref Get-model-data), [`getColsEntries`](@ref Get-model-data) and |
| 28 | [`getRowsEntries`](@ref Get-model-data). |
| 29 | |
| 30 | Specific matrix coefficients obtained using the method [`getCoeff`](@ref Get-model-data). |
| 31 | |
| 32 | ## Modifying model data |
| 33 | |
| 34 | The most immediate model modification is to change the sense of the objective. |
| 35 | By default, HiGHS minimizes the model's objective function. The objective sense |
| 36 | can be set to minimize (maximize) using [changeObjectiveSense](@ref Modify-model-data). |
| 37 | |
| 38 | Model data for can be changed for one column or row by specifying the index of |
| 39 | the column or row, together with the new scalar value for the cost or bounds, |
| 40 | the specific methods being [changeColCost](@ref Modify-model-data), |
| 41 | [changeColBounds](@ref Modify-model-data). The corresponding method for a row is |
| 42 | [changeRowBounds](@ref Modify-model-data). Changes for multiple columns or rows |
| 43 | are defined by supplying a list of indices, together with arrays of new values, |
| 44 | using the methods [changeColsCost](@ref Modify-model-data), |
| 45 | [changeColsBounds](@ref Modify-model-data). The corresponding method for a row |
| 46 | is [changeRowsBounds](@ref Modify-model-data). An individual matrix coefficient |
| 47 | is changed by passing its row index, column index and new value to |
| 48 | [changeCoeff](@ref Modify-model-data). |
| 49 | |
| 50 | ## [Hot start](@id hot-start) |
| 51 | |
| 52 | It may be possible for HiGHS to start solving a model using data |
| 53 | obtained by solving a related model, or supplied by a user. Whether |
| 54 | this is possible depends on the the class of model being solved, the |
| 55 | solver to be used, and the modifications (if any) that have been to |
| 56 | the incumbent model since it was last solved. |
| 57 | |
| 58 | ### LP |
| 59 | |
| 60 | To run HiGHS from a user-defined solution or basis, this is passed to HiGHS |
| 61 | using the methods [setSolution](@ref Set-solution) or [setBasis](@ref Set-basis). The basis passed to HiGHS need not be complete |
| 62 | |
| 63 | * There can be more basic variables then the number of rows in the |
| 64 | model. HiGHS will identify a set of basic variables of the correct |
| 65 | dimension by making some basic variables nonbasic |
| 66 | |
| 67 | * There can be fewer basic variables then the number of rows in the |
| 68 | model. HiGHS will identify a set of basic variables of the correct |
| 69 | dimension by adding basic variables corresponding to slacks. |
| 70 | |
| 71 | * For nonbasic variables, it is unnecessary to specify whether they |
| 72 | are at their lower or upper bound unless they are "boxed" variables. |
| 73 | |
| 74 | ### MIP |
| 75 | |
| 76 | If a (partial) feasible assignment of the integer variables is known, |
| 77 | this can be passed to HiGHS via [setSolution](@ref Set-solution). If |
| 78 | integer variables are set to integer values, HiGHS will solve the LP |
| 79 | with these integer variables fixed (or MIP if the assignment of the |
| 80 | integer variables is not complete). If a feasible solution is |
| 81 | obtained, it will be used to provide the MIP solver with an initial |
| 82 | primal bound when it run to solve for all integer variables. |
| 83 | |
| 84 | ## [Presolve](@id guide-presolve) |
| 85 | |
| 86 | HiGHS has a sophisticated presolve procedure for LPs and MIPs that |
| 87 | aims to reduce the dimension of the model that must be solved. In most |
| 88 | cases, the time saved by solving the reduced model is very much |
| 89 | greater than the time taken to perform presolve. Once he presolved |
| 90 | model is solved, a postsolve procedure (of minimal computational cost) |
| 91 | deduces the optimal solution to the original model. Hence presolve is |
| 92 | performed by default. The only exception occus when there is a valid |
| 93 | basis for an LP and the simplex solver is used. In this case the |
| 94 | original LP is solved, starting from this basis. In cases where the |
| 95 | use of presolve is found not to be advantageous, its use can be |
| 96 | switched off by setting the [presolve](@ref option-presolve) option to |
| 97 | "off". |
| 98 | |
| 99 | HiGHS has a method [presolve](@ref Presolve/postsolve) that performs presolve on |
| 100 | the incumbent model, allowing the presolved model to be extracted or |
| 101 | written to a file. This is intended for users who have their own |
| 102 | solution technique that they wish to test using models presolved by |
| 103 | HiGHS. Note that this does not affect how the incumbent model is |
| 104 | solved. There are two corresponding [postsolve](@ref Presolve/postsolve) |
| 105 | methods, according to whether there are just solution values, or also |
| 106 | a basis. |
| 107 | |
| 108 | ## [Multi-objective optimization](@id guide-multi-objective-optimization) |
| 109 | |
| 110 | Users can specify multiple linear objectives with respect to which |
| 111 | HiGHS will optimize by either blending them, or by performing |
| 112 | lexicographic optimization according to the truth of the |
| 113 | [blend\_multi\_objectives](@ref blend_multi_objectives) option. Each |
| 114 | linear objective is represented by the following data, held in the |
| 115 | [HighsLinearObjective](@ref HighsLinearObjective) structure |
| 116 | |
| 117 | - weight: Scalar of type double - The weight of this objective when blending |
| 118 | - offset: Scalar of type double - The offset of this objective |
| 119 | - coefficients: Vector of type double - The coefficients of this objective |
| 120 | - abs\_tolerance: Scalar of type double - The absolute tolerance on this objective when performing lexicographic optimization |
| 121 | - rel\_tolerance: Scalar of type double - The relative tolerance on this objective when performing lexicographic optimization |
| 122 | - priority: Scalar of type HighsInt - The priority of this objective when performing lexicographic optimization |
| 123 | |
| 124 | ### Methods |
| 125 | |
| 126 | Multi-objective optimization in HiGHS is defined by the following methods |
| 127 | |
| 128 | - [addLinearObjective](@ref Multi-objective-optimization] - Add a single `HighsLinearObjective` instance to any already stored in HiGHS |
| 129 | - [clearLinearObjectives](@ref Multi-objective-optimization] - Clears any linear objectives stored in HiGHS |
| 130 | |
| 131 | When there is at least one `HighsLinearObjective` instance in HiGHS, |
| 132 | the `col_cost_` data in the incumbent model is ignored. |
| 133 | |
| 134 | ### Blending multiple linear objectives |
| 135 | |
| 136 | When [blend\_multi\_objectives](@ref blend_multi_objectives) is `true`, |
| 137 | as it is by default, any `HighsLinearObjective` instances will be |
| 138 | combined according to the `weight` values, and the resulting objective |
| 139 | will be minimized. Hence, any objectives that should be maximized |
| 140 | within the combination must have a negative `weight` value. |
| 141 | |
| 142 | ### Lexicographic optimization of multiple linear objectives |
| 143 | |
| 144 | When [blend\_multi\_objectives](@ref blend_multi_objectives) is `false`, |
| 145 | HiGHS will optimize lexicographically with respect to any |
| 146 | `HighsLinearObjective` instances. This is carried out as follows, according to the |
| 147 | `priority` values in `HighsLinearObjective` instances. Note that _all |
| 148 | priority values must be distinct_. |
| 149 | |
| 150 | * Minimize/maximize with respect to the linear objective of highest priority value, according to whether its `weight` is positive/negative |
| 151 | |
| 152 | * Add a constraint to the model so that the value of the linear objective of highest priority satsifies a bound given by the values of `abs_tolerance` and/or `rel_tolerance`. |
| 153 | + If the objective was minimized to a value ``f^*\ge0``, then the constraint ensures that the this objective value is no greater than ``\min(f^*+abs\_tolerance,~f^*\times[1+rel\_tolerance]).`` |
| 154 | |
| 155 | + If the objective was minimized to a value ``f^*<0``, then the constraint ensures that the this objective value is no greater than ``\min(f^*+abs\_tolerance,~f^*\times[1-rel\_tolerance]).`` |
| 156 | |
| 157 | + If the objective was maximized to a value ``f^*\ge0``, then the constraint ensures that the this objective value is no less than ``\max(f^*-abs\_tolerance,~f^*\times[1-rel\_tolerance]).`` |
| 158 | |
| 159 | + If the objective was maximized to a value ``f^*<0``, then the constraint ensures that the this objective value is no less than ``\max(f^*-abs\_tolerance,~f^*\times[1+rel\_tolerance]).`` |
| 160 | |
| 161 | * Minimize/maximize with respect to the linear objective of next highest priority, and then add a corresponding objective constraint to the model, repeating until optimization with respect to the linear objective of lowest priority has taken place. |
| 162 | |
| 163 | Note |
| 164 | |
| 165 | * Negative values of `abs_tolerance` and `rel_tolerance` will be ignored. This is a convenient way of "switching off" a bounding technique that is not of interest. |
| 166 | * When the model is continuous, no dual information will be returned if there is more than one linear objective. |
| 167 | |
| 168 |