clp 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d6e2766ba9c5090563dd6534448cafcddb24affc2914cfe428671c1974ab7a07
4
+ data.tar.gz: 98d8951377b92b09c6df285e55117b7ac4d81c1836b54dcf9912b1ed059849de
5
+ SHA512:
6
+ metadata.gz: dbe28bb36c4c55ed5d39d2f6be0c3a2302ff069662c03e3aff4b197a7a63db82cf1c7cac1b8e7ebb6ef9f6d5a840e9b7f964ff3fa8421b1d8b468d1d33eada48
7
+ data.tar.gz: 5379acb441756aaec7d2c12e3685203c992cb4f14430a75c382fb8bca0e4fd5556012af71ff80f9f2c4cbfa0c77bae29e98cbfc3718e7c8599a0262823a04d6a
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## 0.1.0 (2022-04-05)
2
+
3
+ - First release
data/LICENSE.txt ADDED
@@ -0,0 +1,244 @@
1
+ Eclipse Public License - v 2.0
2
+
3
+ THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
4
+ LICENSE (“AGREEMENT”). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
5
+ CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
6
+
7
+ 1. DEFINITIONS
8
+ “Contribution” means:
9
+
10
+ a) in the case of the initial Contributor, the initial content Distributed
11
+ under this Agreement, and
12
+ b) in the case of each subsequent Contributor:
13
+ i) changes to the Program, and
14
+ ii) additions to the Program;
15
+ where such changes and/or additions to the Program originate from and
16
+ are Distributed by that particular Contributor. A Contribution
17
+ “originates” from a Contributor if it was added to the Program by such
18
+ Contributor itself or anyone acting on such Contributor's behalf.
19
+ Contributions do not include changes or additions to the Program that
20
+ are not Modified Works. “Contributor” means any person or entity that
21
+ Distributes the Program.
22
+
23
+ “Licensed Patents” mean patent claims licensable by a Contributor which are
24
+ necessarily infringed by the use or sale of its Contribution alone or when
25
+ combined with the Program.
26
+
27
+ “Program” means the Contributions Distributed in accordance with this
28
+ Agreement.
29
+
30
+ “Recipient” means anyone who receives the Program under this Agreement or
31
+ any Secondary License (as applicable), including Contributors.
32
+
33
+ “Derivative Works” shall mean any work, whether in Source Code or other
34
+ form, that is based on (or derived from) the Program and for which the
35
+ editorial revisions, annotations, elaborations, or other modifications
36
+ represent, as a whole, an original work of authorship.
37
+
38
+ “Modified Works” shall mean any work in Source Code or other form that
39
+ results from an addition to, deletion from, or modification of the contents
40
+ of the Program, including, for purposes of clarity any new file in Source
41
+ Code form that contains any contents of the Program. Modified Works shall
42
+ not include works that contain only declarations, interfaces, types,
43
+ classes, structures, or files of the Program solely in each case in order
44
+ to link to, bind by name, or subclass the Program or Modified Works
45
+ thereof.
46
+
47
+ “Distribute” means the acts of a) distributing or b) making available in
48
+ any manner that enables the transfer of a copy.
49
+
50
+ “Source Code” means the form of a Program preferred for making
51
+ modifications, including but not limited to software source code,
52
+ documentation source, and configuration files.
53
+
54
+ “Secondary License” means either the GNU General Public License, Version
55
+ 2.0, or any later versions of that license, including any exceptions or
56
+ additional permissions as identified by the initial Contributor.
57
+
58
+ 2. GRANT OF RIGHTS
59
+
60
+ a) Subject to the terms of this Agreement, each Contributor hereby grants
61
+ Recipient a non-exclusive, worldwide, royalty-free copyright license to
62
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
63
+ Distribute and sublicense the Contribution of such Contributor, if any, and
64
+ such Derivative Works.
65
+
66
+ b) Subject to the terms of this Agreement, each Contributor hereby grants
67
+ Recipient a non-exclusive, worldwide, royalty-free patent license under
68
+ Licensed Patents to make, use, sell, offer to sell, import and otherwise
69
+ transfer the Contribution of such Contributor, if any, in Source Code or
70
+ other form. This patent license shall apply to the combination of the
71
+ Contribution and the Program if, at the time the Contribution is added by
72
+ the Contributor, such addition of the Contribution causes such combination
73
+ to be covered by the Licensed Patents. The patent license shall not apply
74
+ to any other combinations which include the Contribution. No hardware per
75
+ se is licensed hereunder.
76
+
77
+ c) Recipient understands that although each Contributor grants the licenses
78
+ to its Contributions set forth herein, no assurances are provided by any
79
+ Contributor that the Program does not infringe the patent or other
80
+ intellectual property rights of any other entity. Each Contributor
81
+ disclaims any liability to Recipient for claims brought by any other entity
82
+ based on infringement of intellectual property rights or otherwise. As a
83
+ condition to exercising the rights and licenses granted hereunder, each
84
+ Recipient hereby assumes sole responsibility to secure any other
85
+ intellectual property rights needed, if any. For example, if a third party
86
+ patent license is required to allow Recipient to Distribute the Program, it
87
+ is Recipient's responsibility to acquire that license before distributing
88
+ the Program.
89
+
90
+ d) Each Contributor represents that to its knowledge it has sufficient
91
+ copyright rights in its Contribution, if any, to grant the copyright
92
+ license set forth in this Agreement.
93
+
94
+ e) Notwithstanding the terms of any Secondary License, no Contributor makes
95
+ additional grants to any Recipient (other than those set forth in this
96
+ Agreement) as a result of such Recipient's receipt of the Program under the
97
+ terms of a Secondary License (if permitted under the terms of Section 3).
98
+
99
+ 3. REQUIREMENTS
100
+
101
+ 3.1 If a Contributor Distributes the Program in any form, then:
102
+
103
+ a) the Program must also be made available as Source Code, in accordance
104
+ with section 3.2, and the Contributor must accompany the Program with a
105
+ statement that the Source Code for the Program is available under this
106
+ Agreement, and informs Recipients how to obtain it in a reasonable manner
107
+ on or through a medium customarily used for software exchange; and
108
+
109
+ b) the Contributor may Distribute the Program under a license different
110
+ than this Agreement, provided that such license:
111
+
112
+ i) effectively disclaims on behalf of all other Contributors all
113
+ warranties and conditions, express and implied, including warranties or
114
+ conditions of title and non-infringement, and implied warranties or
115
+ conditions of merchantability and fitness for a particular purpose;
116
+
117
+ ii) effectively excludes on behalf of all other Contributors all
118
+ liability for damages, including direct, indirect, special, incidental
119
+ and consequential damages, such as lost profits;
120
+
121
+ iii) does not attempt to limit or alter the recipients' rights in the
122
+ Source Code under section 3.2; and
123
+
124
+ iv) requires any subsequent distribution of the Program by any party to
125
+ be under a license that satisfies the requirements of this section 3.
126
+
127
+ 3.2 When the Program is Distributed as Source Code:
128
+
129
+ a) it must be made available under this Agreement, or if the Program (i)
130
+ is combined with other material in a separate file or files made available
131
+ under a Secondary License, and (ii) the initial Contributor attached to
132
+ the Source Code the notice described in Exhibit A of this Agreement, then
133
+ the Program may be made available under the terms of such Secondary
134
+ Licenses, and
135
+
136
+ b) a copy of this Agreement must be included with each copy of the
137
+ Program.
138
+
139
+ 3.3 Contributors may not remove or alter any copyright, patent, trademark,
140
+ attribution notices, disclaimers of warranty, or limitations of liability
141
+ (‘notices’) contained within the Program from any copy of the Program which
142
+ they Distribute, provided that Contributors may add their own appropriate
143
+ notices.
144
+
145
+ 4. COMMERCIAL DISTRIBUTION
146
+
147
+ Commercial distributors of software may accept certain responsibilities with
148
+ respect to end users, business partners and the like. While this license is
149
+ intended to facilitate the commercial use of the Program, the Contributor who
150
+ includes the Program in a commercial product offering should do so in a manner
151
+ which does not create potential liability for other Contributors. Therefore,
152
+ if a Contributor includes the Program in a commercial product offering, such
153
+ Contributor (“Commercial Contributor”) hereby agrees to defend and indemnify
154
+ every other Contributor (“Indemnified Contributor”) against any losses,
155
+ damages and costs (collectively “Losses”) arising from claims, lawsuits and
156
+ other legal actions brought by a third party against the Indemnified
157
+ Contributor to the extent caused by the acts or omissions of such Commercial
158
+ Contributor in connection with its distribution of the Program in a commercial
159
+ product offering. The obligations in this section do not apply to any claims
160
+ or Losses relating to any actual or alleged intellectual property
161
+ infringement. In order to qualify, an Indemnified Contributor must: a)
162
+ promptly notify the Commercial Contributor in writing of such claim, and b)
163
+ allow the Commercial Contributor to control, and cooperate with the Commercial
164
+ Contributor in, the defense and any related settlement negotiations. The
165
+ Indemnified Contributor may participate in any such claim at its own expense.
166
+
167
+ For example, a Contributor might include the Program in a commercial product
168
+ offering, Product X. That Contributor is then a Commercial Contributor. If
169
+ that Commercial Contributor then makes performance claims, or offers
170
+ warranties related to Product X, those performance claims and warranties are
171
+ such Commercial Contributor's responsibility alone. Under this section, the
172
+ Commercial Contributor would have to defend claims against the other
173
+ Contributors related to those performance claims and warranties, and if a
174
+ court requires any other Contributor to pay any damages as a result, the
175
+ Commercial Contributor must pay those damages.
176
+
177
+ 5. NO WARRANTY
178
+
179
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED
180
+ BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN “AS IS” BASIS, WITHOUT
181
+ WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
182
+ WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
183
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
184
+ responsible for determining the appropriateness of using and distributing the
185
+ Program and assumes all risks associated with its exercise of rights under
186
+ this Agreement, including but not limited to the risks and costs of program
187
+ errors, compliance with applicable laws, damage to or loss of data, programs
188
+ or equipment, and unavailability or interruption of operations.
189
+
190
+ 6. DISCLAIMER OF LIABILITY
191
+
192
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED
193
+ BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY
194
+ LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
195
+ CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER
196
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
197
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
198
+ OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
199
+ HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
200
+
201
+ 7. GENERAL
202
+
203
+ If any provision of this Agreement is invalid or unenforceable under
204
+ applicable law, it shall not affect the validity or enforceability of the
205
+ remainder of the terms of this Agreement, and without further action by the
206
+ parties hereto, such provision shall be reformed to the minimum extent
207
+ necessary to make such provision valid and enforceable.
208
+
209
+ If Recipient institutes patent litigation against any entity (including a
210
+ cross-claim or counterclaim in a lawsuit) alleging that the Program itself
211
+ (excluding combinations of the Program with other software or hardware)
212
+ infringes such Recipient's patent(s), then such Recipient's rights granted
213
+ under Section 2(b) shall terminate as of the date such litigation is filed.
214
+
215
+ All Recipient's rights under this Agreement shall terminate if it fails to
216
+ comply with any of the material terms or conditions of this Agreement and does
217
+ not cure such failure in a reasonable period of time after becoming aware of
218
+ such noncompliance. If all Recipient's rights under this Agreement terminate,
219
+ Recipient agrees to cease use and distribution of the Program as soon as
220
+ reasonably practicable. However, Recipient's obligations under this Agreement
221
+ and any licenses granted by Recipient relating to the Program shall continue
222
+ and survive.
223
+
224
+ Everyone is permitted to copy and distribute copies of this Agreement, but in
225
+ order to avoid inconsistency the Agreement is copyrighted and may only be
226
+ modified in the following manner. The Agreement Steward reserves the right to
227
+ publish new versions (including revisions) of this Agreement from time to
228
+ time. No one other than the Agreement Steward has the right to modify this
229
+ Agreement. The Eclipse Foundation is the initial Agreement Steward. The
230
+ Eclipse Foundation may assign the responsibility to serve as the Agreement
231
+ Steward to a suitable separate entity. Each new version of the Agreement will
232
+ be given a distinguishing version number. The Program (including
233
+ Contributions) may always be Distributed subject to the version of the
234
+ Agreement under which it was received. In addition, after a new version of the
235
+ Agreement is published, Contributor may elect to Distribute the Program
236
+ (including its Contributions) under the new version.
237
+
238
+ Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives
239
+ no rights or licenses to the intellectual property of any Contributor under
240
+ this Agreement, whether expressly, by implication, estoppel or otherwise. All
241
+ rights in the Program not expressly granted under this Agreement are reserved.
242
+ Nothing in this Agreement is intended to be enforceable by any entity that is
243
+ not a Contributor or Recipient. No third-party beneficiary rights are created
244
+ under this Agreement.
data/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # Clp Ruby
2
+
3
+ [Clp](https://github.com/coin-or/Clp) - linear programming solver - for Ruby
4
+
5
+ [![Build Status](https://github.com/ankane/clp-ruby/workflows/build/badge.svg?branch=master)](https://github.com/ankane/clp-ruby/actions)
6
+
7
+ ## Installation
8
+
9
+ First, install Clp. For Homebrew, use:
10
+
11
+ ```sh
12
+ brew install clp
13
+ ```
14
+
15
+ And for Ubuntu, use:
16
+
17
+ ```sh
18
+ sudo apt-get install coinor-libclp1
19
+ ```
20
+
21
+ Add this line to your application’s Gemfile:
22
+
23
+ ```ruby
24
+ gem "clp"
25
+ ```
26
+
27
+ ## Getting Started
28
+
29
+ *The API is fairly low-level at the moment*
30
+
31
+ Load a problem
32
+
33
+ ```ruby
34
+ model =
35
+ Clp.load_problem(
36
+ sense: :minimize,
37
+ start: [0, 3, 6],
38
+ index: [0, 1, 2, 0, 1, 2],
39
+ value: [2, 3, 2, 2, 4, 1],
40
+ col_lower: [0, 0],
41
+ col_upper: [1e30, 1e30],
42
+ obj: [8, 10],
43
+ row_lower: [7, 12, 6],
44
+ row_upper: [1e30, 1e30, 1e30]
45
+ )
46
+ ```
47
+
48
+ Solve
49
+
50
+ ```ruby
51
+ model.solve
52
+ ```
53
+
54
+ Write the problem to an MPS file
55
+
56
+ ```ruby
57
+ model.write_mps("hello.mps")
58
+ ```
59
+
60
+ Read a problem from an MPS file
61
+
62
+ ```ruby
63
+ model = Clp.read_mps("hello.mps")
64
+ ```
65
+
66
+ ## History
67
+
68
+ View the [changelog](https://github.com/ankane/clp-ruby/blob/master/CHANGELOG.md)
69
+
70
+ ## Contributing
71
+
72
+ Everyone is encouraged to help improve this project. Here are a few ways you can help:
73
+
74
+ - [Report bugs](https://github.com/ankane/clp-ruby/issues)
75
+ - Fix bugs and [submit pull requests](https://github.com/ankane/clp-ruby/pulls)
76
+ - Write, clarify, or fix documentation
77
+ - Suggest or add new features
78
+
79
+ To get started with development:
80
+
81
+ ```sh
82
+ git clone https://github.com/ankane/clp-ruby.git
83
+ cd clp-ruby
84
+ bundle install
85
+ bundle exec rake test
86
+ ```
data/lib/clp/ffi.rb ADDED
@@ -0,0 +1,62 @@
1
+ module Clp
2
+ module FFI
3
+ extend Fiddle::Importer
4
+
5
+ libs = Array(Clp.ffi_lib).dup
6
+ begin
7
+ dlload Fiddle.dlopen(libs.shift)
8
+ rescue Fiddle::DLError => e
9
+ retry if libs.any?
10
+ raise e
11
+ end
12
+
13
+ # https://github.com/coin-or/Clp/blob/master/src/Clp_C_Interface.h
14
+
15
+ OBJ_SENSE = {
16
+ minimize: 1,
17
+ maximize: -1
18
+ }
19
+
20
+ STATUS = [:optimal, :primal_infeasible, :dual_infeasible, :stopped, :error]
21
+
22
+ typealias "CoinBigIndex", "int"
23
+
24
+ # version info
25
+ extern "char * Clp_Version(void)"
26
+
27
+ # constructors and destructors
28
+ extern "Clp_Simplex * Clp_newModel(void)"
29
+ extern "void Clp_deleteModel(Clp_Simplex *model)"
30
+ extern "Clp_Solve * ClpSolve_new()"
31
+ extern "void ClpSolve_delete(Clp_Solve *solve)"
32
+
33
+ # load models
34
+ extern "void Clp_loadProblem(Clp_Simplex *model, int numcols, int numrows, CoinBigIndex *start, int *index, double *value, double *collb, double *colub, double *obj, double *rowlb, double *rowub)"
35
+ extern "int Clp_readMps(Clp_Simplex *model, char *filename, int keepNames, int ignoreErrors)"
36
+ extern "int Clp_writeMps(Clp_Simplex *model, char *filename, int formatType, int numberAcross, double objSense)"
37
+
38
+ # getters and setters
39
+ extern "int Clp_numberRows(Clp_Simplex *model)"
40
+ extern "int Clp_numberColumns(Clp_Simplex *model)"
41
+ extern "double Clp_objectiveOffset(Clp_Simplex *model)"
42
+ extern "void Clp_setObjectiveOffset(Clp_Simplex *model, double value)"
43
+ extern "int Clp_status(Clp_Simplex *model)"
44
+ extern "double Clp_getObjSense(Clp_Simplex *model)"
45
+ extern "void Clp_setObjSense(Clp_Simplex *model, double objsen)"
46
+ extern "double * Clp_primalRowSolution(Clp_Simplex *model)"
47
+ extern "double * Clp_primalColumnSolution(Clp_Simplex *model)"
48
+ extern "double * Clp_dualRowSolution(Clp_Simplex *model)"
49
+ extern "double * Clp_dualColumnSolution(Clp_Simplex *model)"
50
+ extern "double * Clp_objective(Clp_Simplex *model)"
51
+ extern "CoinBigIndex Clp_getNumElements(Clp_Simplex *model)"
52
+ extern "CoinBigIndex * Clp_getVectorStarts(Clp_Simplex *model)"
53
+ extern "int * Clp_getIndices(Clp_Simplex *model)"
54
+ extern "int * Clp_getVectorLengths(Clp_Simplex *model)"
55
+ extern "double * Clp_getElements(Clp_Simplex *model)"
56
+ extern "double Clp_objectiveValue(Clp_Simplex *model)"
57
+ extern "void Clp_setLogLevel(Clp_Simplex *model, int value)"
58
+
59
+ # solve
60
+ extern "int Clp_initialSolve(Clp_Simplex *model)"
61
+ end
62
+ end
data/lib/clp/model.rb ADDED
@@ -0,0 +1,88 @@
1
+ module Clp
2
+ class Model
3
+ def initialize
4
+ @model = FFI.Clp_newModel
5
+ ObjectSpace.define_finalizer(self, self.class.finalize(@model))
6
+
7
+ FFI.Clp_setLogLevel(model, 0)
8
+ end
9
+
10
+ def load_problem(sense:, start:, index:, value:, col_lower:, col_upper:, obj:, row_lower:, row_upper:, offset: 0)
11
+ start_size = start.size
12
+ index_size = index.size
13
+ num_cols = col_lower.size
14
+ num_rows = row_lower.size
15
+
16
+ FFI.Clp_loadProblem(
17
+ model, num_cols, num_rows,
18
+ big_index_array(start, start_size), int_array(index, index_size), double_array(value, index_size),
19
+ double_array(col_lower, num_cols), double_array(col_upper, num_cols), double_array(obj, num_cols),
20
+ double_array(row_lower, num_rows), double_array(row_upper, num_rows)
21
+ )
22
+ FFI.Clp_setObjSense(model, FFI::OBJ_SENSE.fetch(sense))
23
+ FFI.Clp_setObjectiveOffset(model, offset)
24
+ end
25
+
26
+ def read_mps(filename)
27
+ check_status FFI.Clp_readMps(model, filename, 0, 0)
28
+ end
29
+
30
+ def write_mps(filename)
31
+ check_status FFI.Clp_writeMps(model, filename, 0, 1, 0)
32
+ end
33
+
34
+ def solve
35
+ check_status FFI.Clp_initialSolve(model)
36
+
37
+ num_rows = FFI.Clp_numberRows(model)
38
+ num_cols = FFI.Clp_numberColumns(model)
39
+
40
+ {
41
+ status: FFI::STATUS[FFI.Clp_status(model)],
42
+ objective: FFI.Clp_objectiveValue(model),
43
+ primal_row: read_double_array(FFI.Clp_primalRowSolution(model), num_rows),
44
+ primal_col: read_double_array(FFI.Clp_primalColumnSolution(model), num_cols),
45
+ dual_row: read_double_array(FFI.Clp_dualRowSolution(model), num_rows),
46
+ dual_col: read_double_array(FFI.Clp_dualColumnSolution(model), num_cols)
47
+ }
48
+ end
49
+
50
+ def self.finalize(model)
51
+ # must use proc instead of stabby lambda
52
+ proc { FFI.Clp_deleteModel(model) }
53
+ end
54
+
55
+ private
56
+
57
+ def model
58
+ @model
59
+ end
60
+
61
+ def check_status(status)
62
+ if status != 0
63
+ raise Error, "Bad status"
64
+ end
65
+ end
66
+
67
+ def double_array(value, size)
68
+ base_array(value, size, "d")
69
+ end
70
+
71
+ def int_array(value, size)
72
+ base_array(value, size, "i!")
73
+ end
74
+ alias_method :big_index_array, :int_array
75
+
76
+ def base_array(value, size, format)
77
+ if value.size != size
78
+ # TODO add variable name to message
79
+ raise ArgumentError, "wrong size (given #{value.size}, expected #{size})"
80
+ end
81
+ Fiddle::Pointer[value.pack("#{format}#{size}")]
82
+ end
83
+
84
+ def read_double_array(ptr, size)
85
+ ptr[0, size * Fiddle::SIZEOF_DOUBLE].unpack("d#{size}")
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,3 @@
1
+ module Clp
2
+ VERSION = "0.1.0"
3
+ end
data/lib/clp.rb ADDED
@@ -0,0 +1,42 @@
1
+ # stdlib
2
+ require "fiddle/import"
3
+
4
+ # modules
5
+ require "clp/model"
6
+ require "clp/version"
7
+
8
+ module Clp
9
+ class Error < StandardError; end
10
+
11
+ class << self
12
+ attr_accessor :ffi_lib
13
+ end
14
+ lib_name =
15
+ if Gem.win_platform?
16
+ "clp.dll"
17
+ elsif RbConfig::CONFIG["host_os"] =~ /darwin/i
18
+ "libclp.dylib"
19
+ else
20
+ "libclp.so"
21
+ end
22
+ self.ffi_lib = [lib_name]
23
+
24
+ # friendlier error message
25
+ autoload :FFI, "clp/ffi"
26
+
27
+ def self.lib_version
28
+ FFI.Clp_Version.to_s
29
+ end
30
+
31
+ def self.read_mps(filename)
32
+ model = Model.new
33
+ model.read_mps(filename)
34
+ model
35
+ end
36
+
37
+ def self.load_problem(**options)
38
+ model = Model.new
39
+ model.load_problem(**options)
40
+ model
41
+ end
42
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: clp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Kane
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-04-06 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: andrew@ankane.org
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - CHANGELOG.md
20
+ - LICENSE.txt
21
+ - README.md
22
+ - lib/clp.rb
23
+ - lib/clp/ffi.rb
24
+ - lib/clp/model.rb
25
+ - lib/clp/version.rb
26
+ homepage: https://github.com/ankane/clp-ruby
27
+ licenses:
28
+ - EPL-2.0
29
+ metadata: {}
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '2.7'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubygems_version: 3.3.7
46
+ signing_key:
47
+ specification_version: 4
48
+ summary: Linear programming solver for Ruby
49
+ test_files: []