cpsat-js 1.3.0 → 1.3.1
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.
- package/README.md +17 -0
- package/dist/proto.d.ts +16 -0
- package/dist/proto.d.ts.map +1 -0
- package/dist/proto.js +14 -0
- package/dist/proto.js.map +1 -0
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -275,6 +275,23 @@ What `onSolution` receives: everything `CpSolverResult` has, including `value()`
|
|
|
275
275
|
The shape is deliberately the same as a final result, so an incumbent and an answer can
|
|
276
276
|
be read by the same code.
|
|
277
277
|
|
|
278
|
+
### `cpsat-js/proto`
|
|
279
|
+
|
|
280
|
+
The protobuf boundary, for solving a model somewhere other than this WASM — native
|
|
281
|
+
OR-Tools reads the same `CpModelProto` bytes:
|
|
282
|
+
|
|
283
|
+
```ts
|
|
284
|
+
import { toBinary, fromBinary, CpModelProtoSchema, CpSolverResponseSchema } from 'cpsat-js/proto';
|
|
285
|
+
|
|
286
|
+
const bytes = toBinary(CpModelProtoSchema, model.toProto());
|
|
287
|
+
// ...solve `bytes` elsewhere, get response bytes back...
|
|
288
|
+
const response = fromBinary(CpSolverResponseSchema, responseBytes);
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
Exports `CpModelProtoSchema`, `CpSolverResponseSchema` and `SatParametersSchema`, with
|
|
292
|
+
`create`/`toBinary`/`fromBinary` re-exported from `@bufbuild/protobuf` so encoding uses the
|
|
293
|
+
same runtime the schemas were generated against.
|
|
294
|
+
|
|
278
295
|
## Architecture
|
|
279
296
|
|
|
280
297
|
- **TypeScript wrapper** builds a `CpModelProto` via a fluent API
|
package/dist/proto.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The protobuf boundary, for solving a model somewhere other than this WASM —
|
|
3
|
+
* native OR-Tools, say, which reads the same CpModelProto bytes.
|
|
4
|
+
*
|
|
5
|
+
* import { toBinary, CpModelProtoSchema } from 'cpsat-js/proto';
|
|
6
|
+
* const bytes = toBinary(CpModelProtoSchema, model.toProto());
|
|
7
|
+
*
|
|
8
|
+
* The protobuf runtime is re-exported with the schemas so a caller encodes with
|
|
9
|
+
* the same @bufbuild/protobuf instance the schemas were generated against.
|
|
10
|
+
*/
|
|
11
|
+
export { create, toBinary, fromBinary } from '@bufbuild/protobuf';
|
|
12
|
+
export { CpModelProtoSchema, CpSolverResponseSchema } from './generated/cp_model_pb.js';
|
|
13
|
+
export type { CpModelProto, CpSolverResponse } from './generated/cp_model_pb.js';
|
|
14
|
+
export { SatParametersSchema } from './generated/sat_parameters_pb.js';
|
|
15
|
+
export type { SatParameters } from './generated/sat_parameters_pb.js';
|
|
16
|
+
//# sourceMappingURL=proto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proto.d.ts","sourceRoot":"","sources":["../src/proto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACxF,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,YAAY,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC"}
|
package/dist/proto.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The protobuf boundary, for solving a model somewhere other than this WASM —
|
|
3
|
+
* native OR-Tools, say, which reads the same CpModelProto bytes.
|
|
4
|
+
*
|
|
5
|
+
* import { toBinary, CpModelProtoSchema } from 'cpsat-js/proto';
|
|
6
|
+
* const bytes = toBinary(CpModelProtoSchema, model.toProto());
|
|
7
|
+
*
|
|
8
|
+
* The protobuf runtime is re-exported with the schemas so a caller encodes with
|
|
9
|
+
* the same @bufbuild/protobuf instance the schemas were generated against.
|
|
10
|
+
*/
|
|
11
|
+
export { create, toBinary, fromBinary } from '@bufbuild/protobuf';
|
|
12
|
+
export { CpModelProtoSchema, CpSolverResponseSchema } from './generated/cp_model_pb.js';
|
|
13
|
+
export { SatParametersSchema } from './generated/sat_parameters_pb.js';
|
|
14
|
+
//# sourceMappingURL=proto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proto.js","sourceRoot":"","sources":["../src/proto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAExF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cpsat-js",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "WebAssembly port of Google OR-Tools CP-SAT constraint programming solver",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.portable.js",
|
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
"./portable": {
|
|
20
20
|
"types": "./dist/index.d.ts",
|
|
21
21
|
"default": "./dist/index.portable.js"
|
|
22
|
+
},
|
|
23
|
+
"./proto": {
|
|
24
|
+
"types": "./dist/proto.d.ts",
|
|
25
|
+
"default": "./dist/proto.js"
|
|
22
26
|
}
|
|
23
27
|
},
|
|
24
28
|
"files": [
|