Skip to content

Commit e3ffc3f

Browse files
committed
NLWPY 0.0.1 #30
1 parent a260eaa commit e3ffc3f

File tree

13 files changed

+1125
-5
lines changed

13 files changed

+1125
-5
lines changed

nl-writer2/examples/cpp/easyAPI_1_MIQP/nlsol_ex_easy_api.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class ModelBuilder {
5555
i+1, sol.x_[i], x_ref_[i]);
5656
return false;
5757
}
58-
printf("MIQP 1: solution check ok.\n");
58+
printf("MIQP 1: solution check ok, obj=%.17g.\n",
59+
sol.obj_val_);
5960
return true;
6061
}
6162

@@ -113,7 +114,7 @@ s.t. C2: x2_5 -x3_6 -x4_3 + x6_2 >= 10;
113114
double obj_val_ref_ {-39.76};
114115
};
115116

116-
/// Solver with given parameters
117+
/// Solve with given parameters
117118
bool SolveAndCheck(std::string solver, std::string sopts,
118119
bool binary, std::string stub) {
119120
ModelBuilder mdlbld;

nl-writer2/include/mp/nl-solver.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,14 @@ class NLHeader;
7979
/// \endrst
8080
class NLSolver {
8181
public:
82+
/// Construct.
83+
NLSolver();
84+
8285
/// Construct.
8386
///
8487
/// @param put: pointer to NLUtils or a derived object
8588
/// (optional).
86-
NLSolver(mp::NLUtils* put=nullptr);
89+
NLSolver(mp::NLUtils* put);
8790

8891
/// Destruct.
8992
~NLSolver();
@@ -140,8 +143,8 @@ class NLSolver {
140143
/// See LoadModel(), Solve(), ReadSolution()
141144
/// for details.
142145
NLSolution Solve(const NLModel& mdl,
143-
const std::string& solver,
144-
const std::string& solver_opts) {
146+
const std::string& solver,
147+
const std::string& solver_opts) {
145148
NLSolution sol;
146149
if (LoadModel(mdl)
147150
&& Solve(solver, solver_opts)) {

nl-writer2/nlwpy/README.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
nlwpy
2+
==============
3+
4+
An example project built with [pybind11](https://github.com/pybind/pybind11).
5+
This requires Python 3.7+; for older versions of Python, check the commit
6+
history.
7+
8+
Installation
9+
------------
10+
11+
- clone this repository
12+
- `pip install ./nlwpy [--prefix=.]`
13+
14+
CI Examples
15+
-----------
16+
17+
There are examples for CI in `.github/workflows`. A simple way to produces
18+
binary "wheels" for all platforms is illustrated in the "wheels.yml" file,
19+
using [`cibuildwheel`][]. You can also see a basic recipe for building and
20+
testing in `pip.yml`, and `conda.yml` has an example of a conda recipe build.
21+
22+
23+
Building the documentation
24+
--------------------------
25+
26+
Documentation for the example project is generated using Sphinx. Sphinx has the
27+
ability to automatically inspect the signatures and documentation strings in
28+
the extension module to generate beautiful documentation in a variety formats.
29+
The following command generates HTML-based reference documentation; for other
30+
formats please refer to the Sphinx manual:
31+
32+
- `cd python_example/docs`
33+
- `make html`
34+
35+
License
36+
-------
37+
38+
pybind11 is provided under a BSD-style license that can be found in the LICENSE
39+
file. By using, distributing, or contributing to this project, you agree to the
40+
terms and conditions of this license.
41+
42+
Test call
43+
---------
44+
45+
Inline:
46+
47+
```python
48+
import nlwpy as m
49+
m.add(1, 2)
50+
```
51+
52+
Use tests:
53+
54+
```bash
55+
[PYTHONPATH=./<installation path++>] python test.py
56+
```
57+
58+
[`cibuildwheel`]: https://cibuildwheel.readthedocs.io
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package:
2+
name: python_example
3+
version: 0.0.1
4+
5+
source:
6+
path: ..
7+
8+
build:
9+
number: 0
10+
script: {{ PYTHON }} -m pip install . -vvv
11+
12+
requirements:
13+
build:
14+
- {{ compiler('cxx') }}
15+
16+
host:
17+
- python
18+
- pip
19+
- pybind11 >=2.10.0
20+
21+
run:
22+
- python
23+
24+
25+
test:
26+
imports:
27+
- python_example
28+
source_files:
29+
- tests
30+
commands:
31+
- python tests/test.py
32+
33+
about:
34+
summary: An example project built with pybind11.
35+
license_file: LICENSE

0 commit comments

Comments
 (0)