parse-lp 2.6.1__cp39-abi3-win32.whl
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.
- LICENSE-APACHE +201 -0
- README.md +291 -0
- parse_lp/__init__.py +73 -0
- parse_lp/parse_lp.pyd +0 -0
- parse_lp/parse_lp.pyi +179 -0
- parse_lp/py.typed +0 -0
- parse_lp-2.6.1.dist-info/METADATA +12 -0
- parse_lp-2.6.1.dist-info/RECORD +10 -0
- parse_lp-2.6.1.dist-info/WHEEL +4 -0
- parse_lp-2.6.1.dist-info/licenses/LICENSE-APACHE +201 -0
LICENSE-APACHE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
README.md
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
# parse_lp
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/py/parse-lp)
|
|
4
|
+
|
|
5
|
+
A LP file format parser, writer, and modifier for Python, powered by Rust.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Complete LP Support**: Handles all standard LP file format features
|
|
10
|
+
- **Problem Modification**: Programmatically modify objectives, constraints, and variables
|
|
11
|
+
- **LP File Writing**: Generate LP files from modified problems with round-trip compatibility
|
|
12
|
+
- **Easy Data Access**: Direct access to problem components (variables, constraints, objectives)
|
|
13
|
+
- **CSV Export**: Export parsed data to CSV files for further analysis
|
|
14
|
+
- **Problem Comparison**: Compare two LP problems to identify differences
|
|
15
|
+
- **Type Safety**: Full type hints for better IDE support and development experience
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install parse_lp
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from parse_lp import LpParser
|
|
27
|
+
|
|
28
|
+
# Parse an LP file
|
|
29
|
+
parser = LpParser("path/to/problem.lp")
|
|
30
|
+
parser.parse()
|
|
31
|
+
|
|
32
|
+
# Access problem information
|
|
33
|
+
print(f"Problem: {parser.name}")
|
|
34
|
+
print(f"Sense: {parser.sense}")
|
|
35
|
+
print(f"Variables: {parser.variable_count()}")
|
|
36
|
+
print(f"Constraints: {parser.constraint_count()}")
|
|
37
|
+
|
|
38
|
+
# Modify the problem
|
|
39
|
+
parser.update_objective_coefficient("OBJ", "x1", 5.0)
|
|
40
|
+
parser.rename_variable("x2", "production")
|
|
41
|
+
parser.update_constraint_rhs("C1", 100.0)
|
|
42
|
+
|
|
43
|
+
# Write back to LP format
|
|
44
|
+
modified_lp = parser.to_lp_string()
|
|
45
|
+
parser.save_to_file("modified_problem.lp")
|
|
46
|
+
|
|
47
|
+
# Export to CSV files
|
|
48
|
+
parser.to_csv("output_directory/")
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Usage Examples
|
|
52
|
+
|
|
53
|
+
### Basic Parsing and Information
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from parse_lp import LpParser
|
|
57
|
+
|
|
58
|
+
parser = LpParser("optimization_problem.lp")
|
|
59
|
+
parser.parse()
|
|
60
|
+
|
|
61
|
+
# Get problem overview
|
|
62
|
+
print(f"Problem Name: {parser.name}")
|
|
63
|
+
print(f"Optimization Sense: {parser.sense}")
|
|
64
|
+
print(f"Variables: {parser.variable_count()}")
|
|
65
|
+
print(f"Constraints: {parser.constraint_count()}")
|
|
66
|
+
print(f"Objectives: {parser.objective_count()}")
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Accessing Problem Data
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
# Access objectives
|
|
73
|
+
for i, objective in enumerate(parser.objectives):
|
|
74
|
+
print(f"Objective {i+1}: {objective['name']}")
|
|
75
|
+
for coef in objective['coefficients']:
|
|
76
|
+
print(f" {coef['name']}: {coef['value']}")
|
|
77
|
+
|
|
78
|
+
# Access variables
|
|
79
|
+
for var_name, var_info in parser.variables.items():
|
|
80
|
+
print(f"Variable {var_name}:")
|
|
81
|
+
print(f" Type: {var_info['var_type']}")
|
|
82
|
+
if 'bounds' in var_info:
|
|
83
|
+
bounds = var_info['bounds']
|
|
84
|
+
if 'lower' in bounds:
|
|
85
|
+
print(f" Lower bound: {bounds['lower']}")
|
|
86
|
+
if 'upper' in bounds:
|
|
87
|
+
print(f" Upper bound: {bounds['upper']}")
|
|
88
|
+
|
|
89
|
+
# Access constraints
|
|
90
|
+
for constraint in parser.constraints:
|
|
91
|
+
print(f"Constraint {constraint['name']}:")
|
|
92
|
+
print(f" Type: {constraint['type']}")
|
|
93
|
+
if constraint['type'] == 'standard':
|
|
94
|
+
print(f" Sense: {constraint['sense']}")
|
|
95
|
+
print(f" RHS: {constraint['rhs']}")
|
|
96
|
+
print(f" Coefficients: {len(constraint['coefficients'])}")
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### CSV Export
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
import os
|
|
103
|
+
|
|
104
|
+
# Create output directory
|
|
105
|
+
os.makedirs("output", exist_ok=True)
|
|
106
|
+
|
|
107
|
+
# Export to CSV files
|
|
108
|
+
parser.to_csv("output/")
|
|
109
|
+
|
|
110
|
+
# Files created:
|
|
111
|
+
# - output/variables.csv
|
|
112
|
+
# - output/constraints.csv
|
|
113
|
+
# - output/objectives.csv
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Problem Modification
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from parse_lp import LpParser
|
|
120
|
+
|
|
121
|
+
# Parse an existing LP file
|
|
122
|
+
parser = LpParser("optimization_problem.lp")
|
|
123
|
+
parser.parse()
|
|
124
|
+
|
|
125
|
+
# Modify objectives
|
|
126
|
+
parser.update_objective_coefficient("profit", "x1", 5.0)
|
|
127
|
+
parser.rename_objective("profit", "total_profit")
|
|
128
|
+
|
|
129
|
+
# Modify constraints
|
|
130
|
+
parser.update_constraint_coefficient("capacity", "x1", 2.0)
|
|
131
|
+
parser.update_constraint_rhs("capacity", 200.0)
|
|
132
|
+
parser.rename_constraint("capacity", "production_limit")
|
|
133
|
+
|
|
134
|
+
# Modify variables
|
|
135
|
+
parser.rename_variable("x1", "production_a")
|
|
136
|
+
parser.update_variable_type("production_a", "integer")
|
|
137
|
+
|
|
138
|
+
# Set problem properties
|
|
139
|
+
parser.set_problem_name("Modified Optimization Problem")
|
|
140
|
+
parser.set_sense("minimize")
|
|
141
|
+
|
|
142
|
+
# Write back to LP format
|
|
143
|
+
modified_lp_content = parser.to_lp_string()
|
|
144
|
+
parser.save_to_file("modified_problem.lp")
|
|
145
|
+
|
|
146
|
+
# Verify round-trip compatibility
|
|
147
|
+
new_parser = LpParser("modified_problem.lp")
|
|
148
|
+
new_parser.parse()
|
|
149
|
+
print(f"Successfully modified and re-parsed: {new_parser.name}")
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Problem Comparison
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
# Parse two different versions of a problem
|
|
156
|
+
parser1 = LpParser("problem_v1.lp")
|
|
157
|
+
parser1.parse()
|
|
158
|
+
|
|
159
|
+
parser2 = LpParser("problem_v2.lp")
|
|
160
|
+
parser2.parse()
|
|
161
|
+
|
|
162
|
+
# Compare the problems
|
|
163
|
+
diff = parser1.compare(parser2)
|
|
164
|
+
|
|
165
|
+
print("Comparison Results:")
|
|
166
|
+
print(f"Name changed: {diff['name_changed']}")
|
|
167
|
+
print(f"Sense changed: {diff['sense_changed']}")
|
|
168
|
+
print(f"Variable count difference: {diff['variable_count_diff']}")
|
|
169
|
+
print(f"Added variables: {diff['added_variables']}")
|
|
170
|
+
print(f"Removed variables: {diff['removed_variables']}")
|
|
171
|
+
print(f"Modified variables: {diff['modified_variables']}")
|
|
172
|
+
print(f"Added constraints: {diff['added_constraints']}")
|
|
173
|
+
print(f"Removed constraints: {diff['removed_constraints']}")
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Objectives Structure
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
[
|
|
180
|
+
{
|
|
181
|
+
"name": "objective_name",
|
|
182
|
+
"coefficients": [
|
|
183
|
+
{"name": "variable_name", "value": 1.5},
|
|
184
|
+
{"name": "another_var", "value": -2.0}
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
]
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Variables Structure
|
|
191
|
+
|
|
192
|
+
```python
|
|
193
|
+
{
|
|
194
|
+
"variable_name": {
|
|
195
|
+
"name": "variable_name",
|
|
196
|
+
"var_type": "Continuous", # or "Binary", "Integer", etc.
|
|
197
|
+
"bounds": { # Optional
|
|
198
|
+
"lower": 0.0, # Optional
|
|
199
|
+
"upper": 100.0 # Optional
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Constraints Structure
|
|
206
|
+
|
|
207
|
+
```python
|
|
208
|
+
[
|
|
209
|
+
{
|
|
210
|
+
"name": "constraint_name",
|
|
211
|
+
"type": "standard", # or "sos"
|
|
212
|
+
"sense": "LessOrEqual", # "Equal", "GreaterOrEqual"
|
|
213
|
+
"rhs": 10.0,
|
|
214
|
+
"coefficients": [
|
|
215
|
+
{"name": "variable_name", "value": 2.0}
|
|
216
|
+
]
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
"name": "sos_constraint",
|
|
220
|
+
"type": "sos",
|
|
221
|
+
"sos_type": "SOS1", # or "SOS2"
|
|
222
|
+
"variables": ["var1", "var2", "var3"]
|
|
223
|
+
}
|
|
224
|
+
]
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Modification Methods
|
|
228
|
+
|
|
229
|
+
### Objective Methods
|
|
230
|
+
|
|
231
|
+
- `update_objective_coefficient(obj_name, var_name, coefficient)` - Update or add coefficient
|
|
232
|
+
- `rename_objective(old_name, new_name)` - Rename an objective
|
|
233
|
+
- `remove_objective(obj_name)` - Remove an objective
|
|
234
|
+
|
|
235
|
+
### Constraint Methods
|
|
236
|
+
|
|
237
|
+
- `update_constraint_coefficient(const_name, var_name, coefficient)` - Update or add coefficient
|
|
238
|
+
- `update_constraint_rhs(const_name, new_rhs)` - Update right-hand side value
|
|
239
|
+
- `rename_constraint(old_name, new_name)` - Rename a constraint
|
|
240
|
+
- `remove_constraint(const_name)` - Remove a constraint
|
|
241
|
+
|
|
242
|
+
### Variable Methods
|
|
243
|
+
|
|
244
|
+
- `rename_variable(old_name, new_name)` - Rename variable across problem
|
|
245
|
+
- `update_variable_type(var_name, var_type)` - Change variable type
|
|
246
|
+
- `remove_variable(var_name)` - Remove variable from problem
|
|
247
|
+
|
|
248
|
+
### Problem Methods
|
|
249
|
+
|
|
250
|
+
- `set_problem_name(name)` - Set problem name
|
|
251
|
+
- `set_sense(sense)` - Set optimization sense ("maximize" or "minimize")
|
|
252
|
+
|
|
253
|
+
### Writing Methods
|
|
254
|
+
|
|
255
|
+
- `to_lp_string()` - Generate LP format string
|
|
256
|
+
- `to_lp_string_with_options(**options)` - Generate with custom formatting
|
|
257
|
+
- `save_to_file(filepath)` - Save to LP file
|
|
258
|
+
|
|
259
|
+
### Variable Types
|
|
260
|
+
|
|
261
|
+
Supported variable types for `update_variable_type()`:
|
|
262
|
+
|
|
263
|
+
- `"binary"` - Binary variables (0 or 1)
|
|
264
|
+
- `"integer"` - General integer variables
|
|
265
|
+
- `"general"` - Continuous variables (default)
|
|
266
|
+
- `"free"` - Free variables (no bounds)
|
|
267
|
+
- `"semicontinuous"` - Semi-continuous variables
|
|
268
|
+
|
|
269
|
+
## Supported LP Format Features
|
|
270
|
+
|
|
271
|
+
- Multiple objective functions
|
|
272
|
+
- Standard constraints (≤, =, ≥)
|
|
273
|
+
- Variable bounds
|
|
274
|
+
- Variable types (continuous, binary, integer)
|
|
275
|
+
- SOS (Special Ordered Sets) constraints
|
|
276
|
+
- Problem names and comments
|
|
277
|
+
- Scientific notation in coefficients
|
|
278
|
+
|
|
279
|
+
## License
|
|
280
|
+
|
|
281
|
+
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
|
|
282
|
+
|
|
283
|
+
## Contributing
|
|
284
|
+
|
|
285
|
+
Issues and pull requests are welcome at: <https://github.com/dandxy89/lp_parser_rs>
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
make build
|
|
289
|
+
make install
|
|
290
|
+
make unit-test
|
|
291
|
+
```
|
parse_lp/__init__.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""parse_lp - A fast LP file format parser, writer, and modifier for Python, powered by Rust.
|
|
2
|
+
|
|
3
|
+
This package provides a high-performance parser for Linear Programming (LP) files,
|
|
4
|
+
leveraging Rust for speed and Python for ease of use. It supports parsing, modifying,
|
|
5
|
+
and writing LP files with full round-trip compatibility.
|
|
6
|
+
|
|
7
|
+
Key Features:
|
|
8
|
+
- Fast parsing of LP files of various formats
|
|
9
|
+
- Programmatic modification of LP problems (objectives, constraints, variables)
|
|
10
|
+
- Write LP problems back to standard LP format
|
|
11
|
+
- Export parsed data to CSV files
|
|
12
|
+
- Access to problem components (variables, constraints, objectives)
|
|
13
|
+
- Compare two LP problems to find differences
|
|
14
|
+
- Type hints for better IDE support
|
|
15
|
+
|
|
16
|
+
Example Usage:
|
|
17
|
+
>>> from parse_lp import LpParser
|
|
18
|
+
>>>
|
|
19
|
+
>>> # Parse an LP file
|
|
20
|
+
>>> parser = LpParser("optimization_problem.lp")
|
|
21
|
+
>>> parser.parse()
|
|
22
|
+
>>>
|
|
23
|
+
>>> # Access problem information
|
|
24
|
+
>>> print(f"Problem name: {parser.name}")
|
|
25
|
+
>>> print(f"Variables: {parser.variable_count()}")
|
|
26
|
+
>>> print(f"Constraints: {parser.constraint_count()}")
|
|
27
|
+
>>>
|
|
28
|
+
>>> # Modify the problem
|
|
29
|
+
>>> parser.update_objective_coefficient("profit", "x1", 5.0)
|
|
30
|
+
>>> parser.rename_variable("x2", "production")
|
|
31
|
+
>>> parser.update_constraint_rhs("capacity", 100.0)
|
|
32
|
+
>>> parser.update_variable_type("x1", "integer")
|
|
33
|
+
>>>
|
|
34
|
+
>>> # Write back to LP format
|
|
35
|
+
>>> modified_lp = parser.to_lp_string()
|
|
36
|
+
>>> parser.save_to_file("modified_problem.lp")
|
|
37
|
+
>>>
|
|
38
|
+
>>> # Export to CSV files
|
|
39
|
+
>>> parser.to_csv("output/")
|
|
40
|
+
>>>
|
|
41
|
+
>>> # Compare two problems
|
|
42
|
+
>>> parser2 = LpParser("modified_problem.lp")
|
|
43
|
+
>>> parser2.parse()
|
|
44
|
+
>>> diff = parser.compare(parser2)
|
|
45
|
+
>>> print(f"Added variables: {diff['added_variables']}")
|
|
46
|
+
|
|
47
|
+
Modification Methods:
|
|
48
|
+
Objective modifications:
|
|
49
|
+
- update_objective_coefficient(obj_name, var_name, coefficient)
|
|
50
|
+
- rename_objective(old_name, new_name)
|
|
51
|
+
- remove_objective(obj_name)
|
|
52
|
+
|
|
53
|
+
Constraint modifications:
|
|
54
|
+
- update_constraint_coefficient(const_name, var_name, coefficient)
|
|
55
|
+
- update_constraint_rhs(const_name, new_rhs)
|
|
56
|
+
- rename_constraint(old_name, new_name)
|
|
57
|
+
- remove_constraint(const_name)
|
|
58
|
+
|
|
59
|
+
Variable modifications:
|
|
60
|
+
- rename_variable(old_name, new_name)
|
|
61
|
+
- update_variable_type(var_name, var_type) # binary, integer, general, free, semicontinuous
|
|
62
|
+
- remove_variable(var_name)
|
|
63
|
+
|
|
64
|
+
Problem modifications:
|
|
65
|
+
- set_problem_name(name)
|
|
66
|
+
- set_sense(sense) # maximize, minimize
|
|
67
|
+
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
from .parse_lp import LpParser
|
|
71
|
+
|
|
72
|
+
__version__ = "2.5.0"
|
|
73
|
+
__all__ = ["LpParser"]
|
parse_lp/parse_lp.pyd
ADDED
|
Binary file
|
parse_lp/parse_lp.pyi
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"""Type stubs for parse_lp module."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, Dict, List, Optional
|
|
4
|
+
|
|
5
|
+
class LpParser:
|
|
6
|
+
"""A fast LP file format parser.
|
|
7
|
+
|
|
8
|
+
This class provides functionality to parse Linear Programming (LP) files
|
|
9
|
+
and access the parsed data or export it to CSV format.
|
|
10
|
+
|
|
11
|
+
Attributes:
|
|
12
|
+
lp_file: Path to the LP file being parsed.
|
|
13
|
+
name: Name of the LP problem (after parsing).
|
|
14
|
+
sense: Optimization sense ('maximize' or 'minimize').
|
|
15
|
+
objectives: List of objective functions with coefficients.
|
|
16
|
+
constraints: List of constraints with their properties.
|
|
17
|
+
variables: Dictionary of variables with their properties.
|
|
18
|
+
|
|
19
|
+
Example:
|
|
20
|
+
>>> from parse_lp import LpParser
|
|
21
|
+
>>> parser = LpParser("path/to/problem.lp")
|
|
22
|
+
>>> parser.parse() # Parse the file
|
|
23
|
+
>>> print(f"Problem: {parser.name}")
|
|
24
|
+
>>> print(f"Variables: {parser.variable_count()}")
|
|
25
|
+
>>> parser.to_csv("output/directory/")
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def __init__(self, lp_file: str) -> None:
|
|
29
|
+
"""Initialize the LP parser with a file path.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
lp_file: Path to the LP file to parse.
|
|
33
|
+
|
|
34
|
+
Raises:
|
|
35
|
+
FileExistsError: If the specified file does not exist.
|
|
36
|
+
"""
|
|
37
|
+
...
|
|
38
|
+
|
|
39
|
+
@property
|
|
40
|
+
def lp_file(self) -> str:
|
|
41
|
+
"""Get the path to the LP file.
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
The path to the LP file being parsed.
|
|
45
|
+
"""
|
|
46
|
+
...
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def name(self) -> Optional[str]:
|
|
50
|
+
"""Get the name of the LP problem.
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
The problem name if available and parsed, None otherwise.
|
|
54
|
+
"""
|
|
55
|
+
...
|
|
56
|
+
|
|
57
|
+
@property
|
|
58
|
+
def sense(self) -> Optional[str]:
|
|
59
|
+
"""Get the optimization sense of the problem.
|
|
60
|
+
|
|
61
|
+
Returns:
|
|
62
|
+
'maximize' or 'minimize' if parsed, None otherwise.
|
|
63
|
+
"""
|
|
64
|
+
...
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
def objectives(self) -> List[Dict[str, Any]]:
|
|
68
|
+
"""Get the list of objective functions.
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
List of dictionaries containing objective information:
|
|
72
|
+
- name: Name of the objective
|
|
73
|
+
- coefficients: List of coefficient dictionaries with 'name' and 'value'
|
|
74
|
+
"""
|
|
75
|
+
...
|
|
76
|
+
|
|
77
|
+
@property
|
|
78
|
+
def constraints(self) -> List[Dict[str, Any]]:
|
|
79
|
+
"""Get the list of constraints.
|
|
80
|
+
|
|
81
|
+
Returns:
|
|
82
|
+
List of dictionaries containing constraint information:
|
|
83
|
+
- name: Name of the constraint
|
|
84
|
+
- type: 'standard' or 'sos'
|
|
85
|
+
- For standard constraints: coefficients, sense, rhs
|
|
86
|
+
- For SOS constraints: sos_type, variables
|
|
87
|
+
"""
|
|
88
|
+
...
|
|
89
|
+
|
|
90
|
+
@property
|
|
91
|
+
def variables(self) -> Dict[str, Dict[str, Any]]:
|
|
92
|
+
"""Get the dictionary of variables.
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
Dictionary mapping variable names to their properties:
|
|
96
|
+
- name: Variable name
|
|
97
|
+
- var_type: Type of variable (e.g., 'Continuous', 'Binary', 'Integer')
|
|
98
|
+
- bounds: Optional dictionary with 'lower' and/or 'upper' bounds
|
|
99
|
+
"""
|
|
100
|
+
...
|
|
101
|
+
|
|
102
|
+
def parse(self) -> None:
|
|
103
|
+
"""Parse the LP file.
|
|
104
|
+
|
|
105
|
+
This method reads and parses the LP file, storing the problem
|
|
106
|
+
data internally for later access.
|
|
107
|
+
|
|
108
|
+
Raises:
|
|
109
|
+
RuntimeError: If the LP file cannot be read or parsed.
|
|
110
|
+
"""
|
|
111
|
+
...
|
|
112
|
+
|
|
113
|
+
def to_csv(self, base_directory: str) -> None:
|
|
114
|
+
"""Export the parsed LP problem to CSV files.
|
|
115
|
+
|
|
116
|
+
This method parses the LP file (if not already parsed) and exports
|
|
117
|
+
the problem data (variables, constraints, and objectives) to separate
|
|
118
|
+
CSV files in the specified directory.
|
|
119
|
+
|
|
120
|
+
Args:
|
|
121
|
+
base_directory: Path to the directory where CSV files will be saved.
|
|
122
|
+
The directory must exist.
|
|
123
|
+
|
|
124
|
+
Raises:
|
|
125
|
+
NotADirectoryError: If base_directory is not a valid directory.
|
|
126
|
+
RuntimeError: If the LP file cannot be read or parsed, or if
|
|
127
|
+
CSV files cannot be written.
|
|
128
|
+
"""
|
|
129
|
+
...
|
|
130
|
+
|
|
131
|
+
def variable_count(self) -> int:
|
|
132
|
+
"""Get the number of variables in the problem.
|
|
133
|
+
|
|
134
|
+
Returns:
|
|
135
|
+
Number of variables, or 0 if not parsed.
|
|
136
|
+
"""
|
|
137
|
+
...
|
|
138
|
+
|
|
139
|
+
def constraint_count(self) -> int:
|
|
140
|
+
"""Get the number of constraints in the problem.
|
|
141
|
+
|
|
142
|
+
Returns:
|
|
143
|
+
Number of constraints, or 0 if not parsed.
|
|
144
|
+
"""
|
|
145
|
+
...
|
|
146
|
+
|
|
147
|
+
def objective_count(self) -> int:
|
|
148
|
+
"""Get the number of objective functions in the problem.
|
|
149
|
+
|
|
150
|
+
Returns:
|
|
151
|
+
Number of objectives, or 0 if not parsed.
|
|
152
|
+
"""
|
|
153
|
+
...
|
|
154
|
+
|
|
155
|
+
def compare(self, other: "LpParser") -> Dict[str, Any]:
|
|
156
|
+
"""Compare this LP problem with another.
|
|
157
|
+
|
|
158
|
+
Both parsers must be parsed before comparison.
|
|
159
|
+
|
|
160
|
+
Args:
|
|
161
|
+
other: Another LpParser instance to compare with.
|
|
162
|
+
|
|
163
|
+
Returns:
|
|
164
|
+
Dictionary containing comparison results:
|
|
165
|
+
- name_changed: Whether problem names differ
|
|
166
|
+
- sense_changed: Whether optimization senses differ
|
|
167
|
+
- variable_count_diff: Difference in variable counts
|
|
168
|
+
- constraint_count_diff: Difference in constraint counts
|
|
169
|
+
- objective_count_diff: Difference in objective counts
|
|
170
|
+
- added_variables: Variables in 'other' but not in 'self'
|
|
171
|
+
- removed_variables: Variables in 'self' but not in 'other'
|
|
172
|
+
- modified_variables: Variables that exist in both but differ
|
|
173
|
+
- added_constraints: Constraints in 'other' but not in 'self'
|
|
174
|
+
- removed_constraints: Constraints in 'self' but not in 'other'
|
|
175
|
+
|
|
176
|
+
Raises:
|
|
177
|
+
RuntimeError: If either parser hasn't been parsed yet.
|
|
178
|
+
"""
|
|
179
|
+
...
|
parse_lp/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: parse_lp
|
|
3
|
+
Version: 2.6.1
|
|
4
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
5
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
6
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
7
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
9
|
+
License-File: LICENSE-APACHE
|
|
10
|
+
Summary: A LP file format parser for Python, powered by Rust
|
|
11
|
+
Keywords: linear-programming,optimization,parser,integer-programming,math
|
|
12
|
+
Requires-Python: >=3.9
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
LICENSE-APACHE,sha256=uGAfx5vfjYCI8JOL6oYf_GPtDuu-3yX0SrLPLoW9ftw,11046
|
|
2
|
+
README.md,sha256=FVTMlavLnJAy3c-dMxEUKUMQHrCWV6PolzqHTcCjNrQ,8083
|
|
3
|
+
parse_lp-2.6.1.dist-info/METADATA,sha256=AYUYWRJAiVhJt7s-sc1NnOmV2rrliHgCOVz9lfje3ZE,505
|
|
4
|
+
parse_lp-2.6.1.dist-info/WHEEL,sha256=l-zZhOZ2a5ZXnfk1pQvieCLMom_QD7Et38SJZ8iK5h8,91
|
|
5
|
+
parse_lp-2.6.1.dist-info/licenses/LICENSE-APACHE,sha256=uGAfx5vfjYCI8JOL6oYf_GPtDuu-3yX0SrLPLoW9ftw,11046
|
|
6
|
+
parse_lp/__init__.py,sha256=AKzBVLYyRXngRoNQopuS_5y3IXV7_s0rI_bhl-ETWwg,2631
|
|
7
|
+
parse_lp/parse_lp.pyd,sha256=ldALXuGMAX67CHEjuLkxNaWq9ew2sQUAfi_l2dy6Kxc,548352
|
|
8
|
+
parse_lp/parse_lp.pyi,sha256=gaP3OZiKavT9GReFAig8YWZwKvyzZJ6iXmKhtxrcY10,5876
|
|
9
|
+
parse_lp/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
parse_lp-2.6.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|