forked from opvious/highs.ts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
170 lines (143 loc) · 5.32 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/** Returns the underlying optimization solver's version. */
export function solverVersion(): string;
// https://github.com/ERGO-Code/HiGHS/blob/master/src/Highs.h
export declare class Solver {
setOption<N extends keyof TypedOptions>(name: N, val: TypedOptions[N]): void; // Enables better auto-complete
setOption(name: string, val: OptionValue): void;
getOption<N extends keyof TypedOptions>(name: N): TypedOptions[N];
getOption(name: string): OptionValue;
passModel(model: Model): void;
readModel(fp: string, cb: (err: Error) => void): string;
writeModel(fp: string, cb: (err: Error) => void): string;
changeObjectiveSense(isMaximization: boolean): void;
changeObjectiveOffset(offset: number): void;
changeColsCost(arr: Float64Array): void;
addRows(
height: number,
lowerBounds: Float64Array,
upperBounds: Float64Array,
weights: Matrix
): void;
run(cb: (err: Error) => void): void;
getModelStatus(): ModelStatus;
getInfo(): Info;
getSolution(): Solution;
setSolution(
sol: Partial<Pick<Solution, 'columnValues' | 'rowDualValues'>>
): void;
writeSolution(
fp: string,
style: SolutionStyle,
cb: (err: Error) => void
): void;
assessPrimalSolution(): SolutionAssessment;
clear(): void;
clearModel(): void;
clearSolver(): void;
}
export type OptionValue = boolean | number | string;
// https://github.com/ERGO-Code/HiGHS/blob/master/src/lp_data/HighsOptions.h
export interface TypedOptions {
readonly presolve: 'on' | 'off' | 'choose'; // kPresolveString
readonly solver: 'simplex' | 'choose' | 'ipm'; // kSolverString
readonly parallel: 'on' | 'off' | 'choose'; // kParallelString
readonly run_crossover: 'on' | 'off' | 'choose'; // kRunCrossoverString
readonly time_limit: number; // kTimeLimitString
readonly ranging: 'on' | 'off'; // kRangingString
readonly infinite_cost: number;
readonly infinite_bound: number;
readonly small_matrix_value: number;
readonly large_matrix_value: number;
readonly primal_feasibility_tolerance: number;
readonly dual_feasibility_tolerance: number;
readonly ipm_feasibility_tolerance: number;
readonly objective_bound: number;
readonly objective_target: number;
readonly random_seed: number; // kRandomSeed
readonly threads: number;
readonly output_flag: boolean;
readonly log_file: string; // kLogFileString
readonly log_to_console: boolean;
readonly mip_abs_gap: number;
readonly mip_rel_gap: number;
}
export interface Model {
/** Number of variables. */
readonly columnCount: number;
/**
* Integrality of variables, values must be one of `ColumnType`'s. Can
* (should) be omitted if all variables are continuous.
*/
readonly columnTypes?: Int32Array;
/**
* Variable bounds. Both arrays must have the same length, equal to the
* number of variables.
*/
readonly columnLowerBounds: Float64Array;
readonly columnUpperBounds: Float64Array;
/** Number of constraints. */
readonly rowCount: number;
/**
* Constraint bounds. Both arrays must have the same length, equal to the
* number of constraints.
*/
readonly rowLowerBounds: Float64Array;
readonly rowUpperBounds: Float64Array;
/** Row-oriented weight matrix. */
readonly weights: Matrix;
/** Objective sense. */
readonly isMaximization: boolean;
/** Objective offset. */
readonly objectiveOffset?: number;
/** Objective weights. */
readonly objectiveLinearWeights: Float64Array;
/**
* Only top-right half (assuming row-wise) entries need be present. The matrix
* will be assumed symmetric and entries in the lower-left half will be
* ignored. Note also that the effective objective weight for diagonal entries
* is 1/2 of their value in this matrix.
*/
readonly objectiveHessian?: Matrix;
}
export interface Matrix {
readonly offsets: Int32Array;
readonly indices: Int32Array;
readonly values: Float64Array;
}
// https://github.com/ERGO-Code/HiGHS/blob/master/src/lp_data/HStruct.h#L30
export interface Solution {
readonly isValueValid: boolean;
readonly isDualValid: boolean;
readonly columnValues: Float64Array;
readonly columnDualValues: Float64Array;
readonly rowValues: Float64Array;
readonly rowDualValues: Float64Array;
}
export interface SolutionAssessment {
readonly isValid: boolean;
readonly isIntegral: boolean;
readonly isFeasible: boolean;
}
// https://github.com/ERGO-Code/HiGHS/blob/master/src/lp_data/HighsInfo.h#L152
export interface Info {
readonly basis_validity: number;
readonly simplex_iteration_count: number;
readonly ipm_iteration_count: number;
readonly qp_iteration_count: number;
readonly objective_function_value: number;
readonly mip_gap: number;
readonly mip_dual_bound: number;
readonly mip_node_count: number;
readonly [name: string]: number;
}
// Enums placeholders (not included here since this is a declaration file only)
// https://github.com/ERGO-Code/HiGHS/blob/master/src/lp_data/HConst.h#L87
// 0 = continuous, 1 = integer, ...
export type ColumnType = number;
// https://github.com/ERGO-Code/HiGHS/blob/master/src/lp_data/HConst.h#L162
export type ModelStatus = number;
// https://github.com/ERGO-Code/HiGHS/blob/master/src/lp_data/HConst.h#L112
// 0 = no solution, 1 = infeasible, 2 = feasible
export type SolutionStatus = number;
// https://github.com/ERGO-Code/HiGHS/blob/master/src/lp_data/HConst.h#L127
export type SolutionStyle = number;