Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/en/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ parts:
- caption: Advanced
chapters:
- file: advanced/generation
- file: advanced/serialize
- caption: Reference
chapters:
- url: https://jij-inc-jijmodeling.readthedocs-hosted.com/en/
Expand Down
87 changes: 87 additions & 0 deletions docs/en/advanced/serialize.ipynb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/ja/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ parts:
- caption: Advanced
chapters:
- file: advanced/generation
- file: advanced/serialize
- caption: Reference
chapters:
- url: https://jij-inc-jijmodeling.readthedocs-hosted.com/en/
Expand Down
87 changes: 87 additions & 0 deletions docs/ja/advanced/serialize.ipynb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions markdowns/en/advanced/serialize.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
jupytext:
text_representation:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.19.1
kernelspec:
display_name: Python 3 (ipykernel)
language: python
name: python3
---

# Serialization

JijModeling models can be easily serialized to [Protobuf](https://protobuf.dev) using the {py:func}`jijmodeling.to_protobuf` function or the {py:meth}`Problem.to_protobuf <jijmodeling.Problem.to_protobuf>` method.

```{code-cell} ipython3
import jijmodeling as jm

problem = jm.Problem("my problem")
N = problem.Placeholder("N", dtype=jm.DataType.NATURAL)
x = problem.BinaryVar("x", shape=(N,))
problem += x.sum()

serialized = problem.to_protobuf()
```

To deserialize, use {py:func}`jijmodeling.from_protobuf` or {py:meth}`Problem.from_protobuf <jijmodeling.Problem.from_protobuf>`.

```{code-cell} ipython3
deserialized = jm.from_protobuf(serialized)
```
33 changes: 33 additions & 0 deletions markdowns/ja/advanced/serialize.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
jupytext:
text_representation:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.19.1
kernelspec:
display_name: Python 3 (ipykernel)
language: python
name: python3
---

# 数理モデルのシリアライズ

JijModeling で作られた数理モデルは、[Protobuf](https://protobuf.dev) で簡単にシリアライズできます。具体的には、{py:func}`jijmodeling.to_protobuf`関数か`Problem.to_protobuf <jijmodeling.Problem.to_protobuf>`メソッドを使えばシリアライズできます。

```{code-cell} ipython3
import jijmodeling as jm

problem = jm.Problem("my problem")
N = problem.Placeholder("N", dtype=jm.DataType.NATURAL)
x = problem.BinaryVar("x", shape=(N,))
problem += x.sum()

serialized = problem.to_protobuf()
```

デシリアライズは、{py:func}`jijmodeling.from_protobuf` か{py:meth}`Problem.from_protobuf <jijmodeling.Problem.from_protobuf>`で行えます。

```{code-cell} ipython3
deserialized = jm.from_protobuf(serialized)
```
Loading