Debian Codegraph @

submodules/subprojects/highs/docs/src/guide/basic.md

raw symbols SCIP
1 # [Basic features](@id guide-basic)
2
3 The minimal use of HiGHS has the following three stages.
4
5 * [Define a model](@ref Defining-a-model)
6 * [Solve the model](@ref Solving-the-model)
7 * [Extract results](@ref Extracting-results)
8
9 Although its default actions will be sufficient for most users, HiGHS
10 can be controlled by setting [Option values](@ref Option-values).
11
12 _Intro to other basic features_
13
14 ### HiGHS data structures
15
16 There are several specialist data structures that can be used to
17 interact with HiGHS when using [`C++`](@ref cpp-getting-started) and
18 `highspy`. These are defined in the sections on [enums](@ref structures-enums)
19 and [classes](@ref classes-overview), and are referred to below.
20
21 #### [Enums](@id guide-basic-enums)
22
23 Enums are scalar identifier types that can take only a limited range of values.
24
25 #### [Classes](@id guide-basic-classes)
26
27 The advantage of using the native `C++` classes in HiGHS is that many fewer parameters are needed
28 when passing data to and from HiGHS. The binding of the data members
29 of these classes to `highspy` structures allows them to be used when
30 calling HiGHS from Python, although they are not necessary for the
31 basic use of `highspy`. As with the `C` and `Fortran` interfaces,
32 there are equivalent methods that use simple scalars and vectors of
33 data.
34
35 ## Defining a model
36
37 HiGHS has comprehensive tools for defining models. This can be done by
38 either reading a model using a data file created elsewhere, or by
39 passing model data to HiGHS. Once a model has been defined in HiGHS,
40 it is referred to as the `incumbent model`.
41
42 ### Reading a model from a file
43
44 The simplest way to define a model in HiGHS is to read it from a file using
45 the method [`readModel`](@ref Read-a-model). HiGHS infers the file type by the extension. Supported extensions are:
46
47 * `.mps`: for an MPS file
48 * `.lp`: for a CPLEX LP file
49
50 HiGHS can read compressed files that end in the `.gz` extension, but
51 not (yet) files that end in the `.zip` extension.
52
53 ### Building a model
54
55 The model in HiGHS can be built using a sequence of calls to add
56 variables and constraints. This is most easily done one-by-one using
57 the methods [`addCol` and `addRow`](@ref
58 Build-a-model). Alternatively, calls to [`addVar`](@ref Build-a-model)
59 can be used to add variables, with calls to [`changeColCost`](@ref
60 Build-a-model) used to define each objective coefficient.
61
62 Addition of multiple variables and constraints can be achieved using
63 [`addCols` and `addRows`](@ref Build-a-model). Alternatively,
64 [`addVars`](@ref Build-a-model) can be used to add variables, with
65 [`changeColsCost`](@ref Build-a-model) used to define objective
66 coefficients. Note that defining multiple variables and constraints requires
67 vectors of data and the specification of constraint coefficients as
68 compressed
69 [row-wise](https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_row_(CSR,_CRS_or_Yale_format))
70 or
71 [column-wise](https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_column_(CSC_or_CCS))
72 matrices.
73
74 ### Passing a model
75
76 If the entire definition of a model is known, then it can be passed to
77 HiGHS via individual data arrays using the method [`passModel`](@ref
78 Pass-a-model). In languages where HiGHS data structures can be used,
79 an instance of the [`HighsLp`](@ref HighsLp) class can be populated
80 with data and then passed.
81
82 ## Solving the model
83
84 The incumbent model in HiGHS is solved by a call to the method
85 [`run`](@ref Solve-the-model). By default, HiGHS minimizes the model's
86 objective function, although this can be [changed](@ref
87 Modifying-model-data). Where possible, HiGHS will reduce the solution
88 time by using data obtained on previous runs, or supplied by the
89 user. More information on this process of hot starting solvers is
90 [available](@ref hot-start).
91
92 ## Extracting results
93
94 After solving a model, it is important to know whether it has been
95 solved to optimality, shown to be infeasible or unbounded, or why the
96 solver may have terminated early. This model status is given by the
97 value returned by the method [`getModelStatus`](@ref
98 Extract-results). This value is of type [`HighsModelStatus`](@ref HighsModelStatus).
99 Scalar information about a solved model is obtained using the method
100 [`getInfo`](@ref Extract-results). The solution and (any) basis are
101 returned by the methods [`getSolution`](@ref Extract-results) and
102 [`getBasis`](@ref Extract-results) respectively. HiGHS can also be used
103 to write the solution to a file using the method [`writeSolution`](@ref
104 Report-results).
105
106 ## Option values
107
108 The option values that control HiGHS are of type `string`, `bool`,
109 `int` and `double`. Options are referred to by a `string` identical to
110 the name of their identifier. A full specification of the options is
111 given in the [list of options](@ref option-definitions). An option
112 value is changed by passing its name and value to the method
113 [`setOptionValue`](@ref example-py-option-values). The current value
114 of an option is obtained by passing its name to the method
115 [`getOptionValue`](@ref example-py-option-values).
116