highs 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +15 -1
- data/lib/highs/ffi.rb +25 -9
- data/lib/highs/methods.rb +1 -0
- data/lib/highs/model.rb +16 -11
- data/lib/highs/version.rb +1 -1
- data/vendor/libhighs.arm64.dylib +0 -0
- data/vendor/libhighs.arm64.so +0 -0
- data/vendor/libhighs.dylib +0 -0
- data/vendor/libhighs.so +0 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e1820b5de1dbc70a3892696ec19873ee45ef2a1169eb581c7b62e64fa2930d4
|
4
|
+
data.tar.gz: f589846e73041dbd52ad4ac0fae110971f492525b9ad95023b4d20fe203c75b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a92aa350070a0870aac19d8e64597ed74b9293bc27ee2d8c1da82e1276e9918bb840b0617341925d7db468d6eb15f3e3bcb60a2efcd2eea6d7500a339cd219a9
|
7
|
+
data.tar.gz: 0a5780c8dd03a8692dba3c8edec0068c277b95b0521baaab324c950a3d00d8a242f5f9c3b97c673e11ad2e5c4552a376d3b07e80462db6d47bc4f83e39ac9594
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -49,7 +49,7 @@ model =
|
|
49
49
|
a_start: [0, 3],
|
50
50
|
a_index: [0, 1, 2, 0, 1, 2],
|
51
51
|
a_value: [2, 3, 2, 2, 4, 1],
|
52
|
-
integrality: [
|
52
|
+
integrality: [:integer, :continuous]
|
53
53
|
)
|
54
54
|
```
|
55
55
|
|
@@ -93,6 +93,20 @@ Read a program from an MPS file
|
|
93
93
|
model = Highs.read("model.mps")
|
94
94
|
```
|
95
95
|
|
96
|
+
## Reference
|
97
|
+
|
98
|
+
Enable verbose logging
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
model.solve(verbose: true)
|
102
|
+
```
|
103
|
+
|
104
|
+
Set the time limit in seconds
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
model.solve(time_limit: 30)
|
108
|
+
```
|
109
|
+
|
96
110
|
## History
|
97
111
|
|
98
112
|
View the [changelog](https://github.com/ankane/highs-ruby/blob/master/CHANGELOG.md)
|
data/lib/highs/ffi.rb
CHANGED
@@ -12,15 +12,12 @@ module Highs
|
|
12
12
|
|
13
13
|
# https://github.com/ERGO-Code/HiGHS/blob/master/src/interfaces/highs_c_api.h
|
14
14
|
|
15
|
-
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
|
20
|
-
|
21
|
-
MATRIX_FORMAT = {
|
22
|
-
colwise: 1,
|
23
|
-
rowwise: 2
|
15
|
+
VAR_TYPE = {
|
16
|
+
continuous: 0,
|
17
|
+
integer: 1,
|
18
|
+
semi_continuous: 2,
|
19
|
+
semi_integer: 3,
|
20
|
+
implicit_integer: 4
|
24
21
|
}
|
25
22
|
|
26
23
|
OBJ_SENSE = {
|
@@ -28,6 +25,17 @@ module Highs
|
|
28
25
|
maximize: -1
|
29
26
|
}
|
30
27
|
|
28
|
+
MATRIX_FORMAT = {
|
29
|
+
colwise: 1,
|
30
|
+
rowwise: 2
|
31
|
+
}
|
32
|
+
|
33
|
+
MODEL_STATUS = [
|
34
|
+
:not_set, :load_error, :model_error, :presolve_error, :solve_error, :postsolve_error,
|
35
|
+
:model_empty, :optimal, :infeasible, :unbounded_or_infeasible, :unbounded,
|
36
|
+
:objective_bound, :objective_target, :time_limit, :iteration_limit, :unknown
|
37
|
+
]
|
38
|
+
|
31
39
|
BASIS_STATUS = [:lower, :basic, :upper, :zero, :nonbasic]
|
32
40
|
|
33
41
|
typealias "HighsInt", "int"
|
@@ -50,6 +58,14 @@ module Highs
|
|
50
58
|
extern "HighsInt Highs_passModel(void* highs, HighsInt num_col, HighsInt num_row, HighsInt num_nz, HighsInt q_num_nz, HighsInt a_format, HighsInt q_format, HighsInt sense, double offset, double* col_cost, double* col_lower, double* col_upper, double* row_lower, double* row_upper, HighsInt* a_start, HighsInt* a_index, double* a_value, HighsInt* q_start, HighsInt* q_index, double* q_value, HighsInt* integrality)"
|
51
59
|
extern "HighsInt Highs_passHessian(void* highs, HighsInt dim, HighsInt num_nz, HighsInt format, HighsInt* start, HighsInt* index, double* value)"
|
52
60
|
extern "HighsInt Highs_setBoolOptionValue(void* highs, char* option, HighsInt value)"
|
61
|
+
extern "HighsInt Highs_setIntOptionValue(void* highs, char* option, HighsInt value)"
|
62
|
+
extern "HighsInt Highs_setDoubleOptionValue(void* highs, char* option, double value)"
|
63
|
+
extern "HighsInt Highs_setStringOptionValue(void* highs, char* option, char* value)"
|
64
|
+
extern "HighsInt Highs_getBoolOptionValue(void* highs, char* option, HighsInt* value)"
|
65
|
+
extern "HighsInt Highs_getIntOptionValue(void* highs, char* option, HighsInt* value)"
|
66
|
+
extern "HighsInt Highs_getDoubleOptionValue(void* highs, char* option, double* value)"
|
67
|
+
extern "HighsInt Highs_getStringOptionValue(void* highs, char* option, char* value)"
|
68
|
+
extern "HighsInt Highs_getOptionType(void* highs, char* option, HighsInt* type)"
|
53
69
|
extern "HighsInt Highs_getSolution(void* highs, double* col_value, double* col_dual, double* row_value, double* row_dual)"
|
54
70
|
extern "HighsInt Highs_getBasis(void* highs, HighsInt* col_status, HighsInt* row_status)"
|
55
71
|
extern "HighsInt Highs_getModelStatus(void* highs)"
|
data/lib/highs/methods.rb
CHANGED
data/lib/highs/model.rb
CHANGED
@@ -4,11 +4,13 @@ module Highs
|
|
4
4
|
@ptr = FFI.Highs_create
|
5
5
|
ObjectSpace.define_finalizer(self, self.class.finalize(@ptr))
|
6
6
|
|
7
|
-
# TODO add option
|
8
7
|
check_status FFI.Highs_setBoolOptionValue(@ptr, "output_flag", 0)
|
9
8
|
end
|
10
9
|
|
11
|
-
def solve
|
10
|
+
def solve(verbose: false, time_limit: nil)
|
11
|
+
num_col = FFI.Highs_getNumCol(@ptr)
|
12
|
+
num_row = FFI.Highs_getNumRow(@ptr)
|
13
|
+
|
12
14
|
col_value = DoubleArray.new(num_col)
|
13
15
|
col_dual = DoubleArray.new(num_col)
|
14
16
|
row_value = DoubleArray.new(num_row)
|
@@ -16,7 +18,9 @@ module Highs
|
|
16
18
|
col_basis = IntArray.new(num_col)
|
17
19
|
row_basis = IntArray.new(num_row)
|
18
20
|
|
19
|
-
|
21
|
+
with_options(verbose: verbose, time_limit: time_limit) do
|
22
|
+
check_status FFI.Highs_run(@ptr)
|
23
|
+
end
|
20
24
|
check_status FFI.Highs_getSolution(@ptr, col_value, col_dual, row_value, row_dual)
|
21
25
|
check_status FFI.Highs_getBasis(@ptr, col_basis, row_basis)
|
22
26
|
model_status = FFI.Highs_getModelStatus(@ptr)
|
@@ -48,16 +52,17 @@ module Highs
|
|
48
52
|
|
49
53
|
private
|
50
54
|
|
51
|
-
def num_col
|
52
|
-
FFI.Highs_getNumCol(@ptr)
|
53
|
-
end
|
54
|
-
|
55
|
-
def num_row
|
56
|
-
FFI.Highs_getNumRow(@ptr)
|
57
|
-
end
|
58
|
-
|
59
55
|
def check_status(status)
|
60
56
|
Highs.send(:check_status, status)
|
61
57
|
end
|
58
|
+
|
59
|
+
def with_options(verbose:, time_limit:)
|
60
|
+
check_status(FFI.Highs_setBoolOptionValue(@ptr, "output_flag", 1)) if verbose
|
61
|
+
check_status(FFI.Highs_setDoubleOptionValue(@ptr, "time_limit", time_limit)) if time_limit
|
62
|
+
yield
|
63
|
+
ensure
|
64
|
+
check_status(FFI.Highs_setBoolOptionValue(@ptr, "output_flag", 0)) if verbose
|
65
|
+
check_status(FFI.Highs_setDoubleOptionValue(@ptr, "time_limit", Float::INFINITY)) if time_limit
|
66
|
+
end
|
62
67
|
end
|
63
68
|
end
|
data/lib/highs/version.rb
CHANGED
data/vendor/libhighs.arm64.dylib
CHANGED
Binary file
|
data/vendor/libhighs.arm64.so
CHANGED
Binary file
|
data/vendor/libhighs.dylib
CHANGED
Binary file
|
data/vendor/libhighs.so
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: highs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: andrew@ankane.org
|