Skip to content

Commit 4389b1a

Browse files
committed
Rewrite the Optimizer in C++ and NLopt
1 parent b4dbd53 commit 4389b1a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+8072
-1460
lines changed

Diff for: .clang-format

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
2+
AlignAfterOpenBracket: BlockIndent
3+
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
4+
AllowShortLoopsOnASingleLine: true
5+
BreakBeforeBraces: Attach
6+
ColumnLimit: 0
7+
IndentWidth: 4
8+
NamespaceIndentation: All
9+
PackConstructorInitializers: NextLine
10+
TabWidth: 4
11+
UseTab: Always

Diff for: .clang-tidy

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Checks: '-*,
2+
modernize-*,
3+
-modernize-use-trailing-return-type,
4+
-modernize-use-nodiscard'

Diff for: .gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44

55
# Set GitHub linguist exclusion
66
lib/**/*.js linguist-vendored
7+
lib/optimizer/**/*.mjs linguist-vendored
8+
lib/nlopt/* linguist-vendored
79
src/log/*.md linguist-detectable=true

Diff for: .pylintrc

-13
This file was deleted.

Diff for: .vscode/c_cpp_properties.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
// https://code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference
3+
"configurations": [
4+
{
5+
"name": "Emscripten",
6+
"includePath": [
7+
"${workspaceFolder}/src/client/plugins/optimizer/src",
8+
"${workspaceFolder}/lib/nlopt"
9+
],
10+
// Change the next line to your Emscripten location
11+
"compilerPath": "C:/Sdk/emsdk/upstream/emscripten/emcc.bat",
12+
"cppStandard": "c++20",
13+
"intelliSenseMode": "linux-clang-x86"
14+
}
15+
],
16+
"version": 4,
17+
"enableConfigurationSquiggles": true
18+
}

Diff for: .vscode/settings.json

+8-9
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"**/*sample*"
1212
],
1313
"cSpell.ignoreRegExpList": [
14-
"/[A-Z]+(?![a-z])/g"
14+
"/[A-Z]+(?![a-z])/g",
15+
"/(?:NL|nl)opt/g"
1516
],
1617
"cSpell.ignoreWords": [
1718
"fbclid",
@@ -28,12 +29,14 @@
2829
"beforeinstallprompt",
2930
"bpstudio",
3031
"browserslistrc",
32+
"ccall",
3133
"Chainer",
3234
"Chebyshev",
3335
"configurator",
3436
"dpad",
3537
"draggables",
3638
"earcut",
39+
"Emscripten",
3740
"esbuild",
3841
"fflate",
3942
"fontawesome",
@@ -91,6 +94,7 @@
9194
"wicg",
9295
"xdescribe"
9396
],
97+
"C_Cpp.autoAddFileAssociations": false,
9498
"css.validate": false,
9599
"editor.codeActionsOnSave": {
96100
"source.fixAll.eslint": "explicit"
@@ -109,14 +113,13 @@
109113
"README.md": "LICENSE.md, CONTRIBUTING.md",
110114
"eslint.config.mjs": ".editorconfig, eslint-local-rules.js",
111115
"package.json": "pnpm-lock.yaml, .npmrc, .browserslistrc",
112-
"rsbuild.config.ts": "rsbuild.*.ts"
116+
"rsbuild.config.ts": "rsbuild.*.ts",
117+
".clang-format": ".clang-*"
113118
},
114119
"files.exclude": {
115-
"**/__pycache__/": true,
116120
"**/debug.log": true,
117-
".mypy_cache": true,
118121
".nyc_output": true,
119-
".pytest_cache": true,
122+
"build/obj/": true,
120123
"coverage": true,
121124
"node_modules/": true,
122125
"patches/": true,
@@ -143,10 +146,6 @@
143146
],
144147
"javascript.suggestionActions.enabled": false, // See https://github.com/Microsoft/vscode/issues/47299
145148
"mochaExplorer.multiFileSuites": true,
146-
"mypy-type-checker.args": [
147-
"--check-untyped-defs"
148-
],
149-
"python.testing.pytestEnabled": true,
150149
"scss.validate": false,
151150
"stylelint.packageManager": "pnpm",
152151
"stylelint.validate": [

Diff for: CONTRIBUTING.md

+14-5
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,20 @@ and then run `pnpm preview` to launch the local server on production build.
3232
3333
## Developing optimizer
3434

35-
The BP Studio optimizer is written in Python as it utilizes [scipy](https://pypi.org/project/scipy/).
36-
In order to have typing supports in VS Code,
37-
you will need [Pylance](https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance) extension,
38-
Python 3.9+ and [pipenv](https://pypi.org/project/pipenv/) installed.
39-
You can then install the dependencies with `pipenv install`.
35+
The BP Studio optimizer is written in C++. To compile it, you'll need:
36+
37+
- [Emscripten](https://emscripten.org/), and make sure that `emcc` is available in PATH.\
38+
You may also need to change `configurations.compilerPath` in the
39+
[.vscode/c_cpp_properties.json](./.vscode/c_cpp_properties.json)
40+
file to reflect the location of your Emscripten installation.
41+
- [GNU make](https://community.chocolatey.org/packages/make), if you're on Windows.\
42+
(Our makefile should work on all desktop platforms regardlessly.)
43+
44+
Then you can compile the Optimizer by:
45+
46+
```
47+
make MODE=dist
48+
```
4049

4150
## Browser compatibility
4251

Diff for: Pipfile

-12
This file was deleted.

Diff for: Pipfile.lock

-226
This file was deleted.

Diff for: eslint.config.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function legacyPlugin(name, alias = name) {
2727
export default [
2828
{
2929
name: "Global ignores",
30-
ignores: ["{build,coverage}/**", "lib/**/*.js", "src/app/gen/**"],
30+
ignores: ["{build,coverage}/**", "lib/**/*.js", "lib/optimizer/**/*.mjs", "src/app/gen/**"],
3131
},
3232
{
3333
name: "Matching file extensions",

0 commit comments

Comments
 (0)