# REST API モジュール　rest


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

\#hide \## FASTAPI

REST APIはfastapiとpydanticを用いる．

- FastAPI https://fastapi.tiangolo.com/ は，
  APIを構築するためのWebフレームワークである．
- pydantic https://github.com/samuelcolvin/pydantic/
  は，FastAPI内で使われるJSON互換のデータ定義のためのモジュールである．

インストールは，fastapiとサーバーとして uvicorn http://www.uvicorn.org/
を必要とする．

main.pyでFastAPIを動かすためのコードを記述してから，サーバーを起動することによって，APIコールが可能になる．

    uvicorn main:app --reload   

## Pydanticによるデータフレーム検証

Excelファイルやcsvファイルを読み込んだ際に，データの妥当性の検証を行う必要がある．
そのために，fastAPI (https://fastapi.tiangolo.com/) に含まれるPydantic
(https://pydantic-docs.helpmanual.io/) を利用する．

Pydanticは，オブジェクトタイプが間違えていても，できるだけ自動変換する．

\#hide \## 認証

認証用のコードを動かしておく．

    uvicorn fastapi-user-main:app --reload

このAPIにrequestを出すことによって認証を行う． \###
レジストレーション　/auth/register

引数：メイルとパスワードを入れたJSON

返値：id, メイル， アクティブ: True， スーパーユーザー: False

\#hide \### ログイン　/auth/jwt/login”

引数:

- headers: {‘Content-Type’: ‘application/x-www-form-urlencoded’}
- data: ユーザー名（メイル）　＆ パスワード の文字列

返値： - access_token: トークン - token_type: トークンタイプ (bearer)

\#hide \### トークンによるアクセス

headersに”Authorization”をキー，値に”Bearer
トークン”の文字列を入れてアクセス

\#hide \#hide \### 認証なしでのアクセス

\#hide \### パスワードを忘れた場合

forgot-passwordは常に202（Accepted)を返す．

関数 on_after_register(user: UserDB, request: Request)
が呼ばれるので，そこでユーザーにメイルを送るように設定する．

https://frankie567.github.io/fastapi-users/configuration/routers/reset/

\#hide \### reset-passwordは，トークンと新しいパスワードを入れる．

\#hide \#### 正しくないパスワードでのログイン

## MELOS-GF

Weiszfeld法のREST(Representational State Transfer) APIを FastAPI
とpydanticを用いて作成する．

MelosGfのモデルクラスは，顧客クラスCustomer，移動時間クラス Time
から構成され，以下のように定義される．

### クラス定義

データ検証用に顧客リスト，時間リストのクラスも作っておく．

    <unknown>:437: SyntaxWarning: invalid escape sequence '\s'
    <unknown>:438: SyntaxWarning: invalid escape sequence '\s'

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L139"
target="_blank" style="float:right; font-size:smaller">source</a>

### MelosGf

``` python

def MelosGf(
    data:Any
)->None:

```

*Melos Green Field モデル*

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L135"
target="_blank" style="float:right; font-size:smaller">source</a>

### TimeList

``` python

def TimeList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L115"
target="_blank" style="float:right; font-size:smaller">source</a>

### Time

``` python

def Time(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L112"
target="_blank" style="float:right; font-size:smaller">source</a>

### CustomerList

``` python

def CustomerList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L96"
target="_blank" style="float:right; font-size:smaller">source</a>

### Customer

``` python

def Customer(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L90"
target="_blank" style="float:right; font-size:smaller">source</a>

### Solution

``` python

def Solution(
    data:Any
)->None:

```

*Pickleを付加したベースモデル*

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L85"
target="_blank" style="float:right; font-size:smaller">source</a>

### Instance

``` python

def Instance(
    data:Any
)->None:

```

*Pickleを付加したベースモデル*

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L69"
target="_blank" style="float:right; font-size:smaller">source</a>

### PickledBaseModel

``` python

def PickledBaseModel(
    data:Any
)->None:

```

*Pickleを付加したベースモデル*

### 顧客クラスの使用例

PydanticのBaseClassから派生させたクラス

引数は辞書で与え，入力データにエラーがある場合には，ValidationErrorが発生する．

クラスインスタンスには，以下のメソッドがある．

- json
- schema
- dict

``` python
example  = {
                "name": "響本店",
                "lat": "43.06417", #文字列はfloatに変換される
                "lon": 141.34694,
                "weight": 1 #整数もfloatに変換される
            }
cust = Customer(**example) #Pydantic BaseClassは辞書から生成できる．（**で展開）
print("文字列:", cust) #インスタンス文字列
print("JSON:", cust.json()) #JSON文字列 https://www.json.org/json-ja.html
print("スキーマ:", cust.schema()) #JSONスキーマ
print("辞書:", cust.dict()) #辞書に変換
print("JSONで読める形式:", jsonable_encoder(cust)) #JSONで読める形式（この場合は辞書）　https://fastapi.tiangolo.com/tutorial/encoder/
```

    文字列: name='響本店' lat=43.06417 lon=141.34694 weight=1.0
    JSON: {"name":"響本店","lat":43.06417,"lon":141.34694,"weight":1.0}
    スキーマ: {'properties': {'name': {'description': '名称', 'title': 'Name', 'type': 'string'}, 'lat': {'description': '緯度', 'title': 'Lat', 'type': 'number'}, 'lon': {'description': '経度', 'title': 'Lon', 'type': 'number'}, 'weight': {'anyOf': [{'type': 'number'}, {'type': 'null'}], 'description': '重み', 'title': 'Weight'}}, 'required': ['name', 'lat', 'lon', 'weight'], 'title': 'Customer', 'type': 'object'}
    辞書: {'name': '響本店', 'lat': 43.06417, 'lon': 141.34694, 'weight': 1.0}
    JSONで読める形式: {'name': '響本店', 'lat': 43.06417, 'lon': 141.34694, 'weight': 1.0}

``` python
#エラーが発生する例
example2  = {
                "name": "響本店",
                "lat": "43.06417"
            }
try:
    cust2 = Customer(**example2)
except ValidationError as e:
    print(e.json())
```

    [{"type":"missing","loc":["lon"],"msg":"Field required","input":{"name":"響本店","lat":"43.06417"},"url":"https://errors.pydantic.dev/2.6/v/missing"},{"type":"missing","loc":["weight"],"msg":"Field required","input":{"name":"響本店","lat":"43.06417"},"url":"https://errors.pydantic.dev/2.6/v/missing"}]

### JSONからクラスを生成

``` python
cust_json = cust.json()
cust_dict = json.loads(cust_json)
new_customer = parse_obj_as(Customer, cust_dict) #以下でも同じ
#Customer(**cust_dict)
new_customer
```

    /var/folders/69/5y96sdc94jxf6khgc8mlmxrr0000gn/T/ipykernel_85321/878949156.py:3: PydanticDeprecatedSince20: `parse_obj_as` is deprecated. Use `pydantic.TypeAdapter.validate_python` instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.6/migration/
      new_customer = parse_obj_as(Customer, cust_dict) #以下でも同じ

    Customer(name='響本店', lat=43.06417, lon=141.34694, weight=1.0)

### Excelファイルを読み込みデータフレームを生成する関数 read_xl

引数:

- file_name: xlsx属性子のExcelファイル名

返値： - dfs: Excelファイルの各シートから生成したデータフレームのリスト

ファイルがないときには，FileNotFoundErrorが発生する．

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L151"
target="_blank" style="float:right; font-size:smaller">source</a>

### read_xl

``` python

def read_xl(
    file_name
):

```

*Call self as a function.*

### read_xl関数の使用例

``` python
cust_df, time_df = read_xl("melos-gf.xlsx")
#read_xl("error.xlsx") #FileNotFoundErrorが発生
cust_df.head()
#time_df.head()
```

<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }
&#10;    .dataframe tbody tr th {
        vertical-align: top;
    }
&#10;    .dataframe thead th {
        text-align: right;
    }
</style>

<table class="dataframe" data-quarto-postprocess="true" data-border="1">
<thead>
<tr style="text-align: right;">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th">name</th>
<th data-quarto-table-cell-role="th">lat</th>
<th data-quarto-table-cell-role="th">lon</th>
<th data-quarto-table-cell-role="th">weight</th>
</tr>
</thead>
<tbody>
<tr>
<td data-quarto-table-cell-role="th">0</td>
<td>札幌市</td>
<td>43.06417</td>
<td>141.34694</td>
<td>9632.39</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">1</td>
<td>青森市</td>
<td>40.82444</td>
<td>140.74000</td>
<td>8607.57</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">2</td>
<td>盛岡市</td>
<td>39.70361</td>
<td>141.15250</td>
<td>9614.31</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">3</td>
<td>仙台市</td>
<td>38.26889</td>
<td>140.87194</td>
<td>11050.32</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">4</td>
<td>秋田市</td>
<td>39.71861</td>
<td>140.10250</td>
<td>2280.27</td>
</tr>
</tbody>
</table>

</div>

## データフレームとクラスからクラスインスタンスのリストを生成する関数 make_obj_list

引数： - dfs: データフレームのリスト - cls_list:
Pydanticのクラスのリスト；対応するデータフレームの列名がクラスの属性名に対応していると仮定する．

返値： - obj_list:
各データフレームを行ごとにクラスインスタンスに変換したリストを1つの要素としたリスト

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L165"
target="_blank" style="float:right; font-size:smaller">source</a>

### make_obj_list

``` python

def make_obj_list(
    dfs, cls_list
):

```

*Call self as a function.*

### make_obj_list関数の使用例

このデータ構造を使うと，ユニークなID（この例では顧客名）をキーとした辞書が準備できる．
これを用いて，様々な実際問題のモデル化ができる．

``` python
customer_list, time_list = make_obj_list([cust_df, time_df], [Customer, Time])
print(customer_list[0])
print(time_list[10])

cust_dic = {} #customer dic.
for c in customer_list:
    cust_dic[c.name] = c
print("Pop from customer dic.=", cust_dic.popitem() )

time_dic = {} #time dic. 
for t in time_list:
    time_dic[t.from_name, t.to_name] = t.time 
print("Pop from time dic.=", time_dic.popitem() )
```

    name='札幌市' lat=43.06417 lon=141.34694 weight=9632.389999999998
    from_node=0 from_name='札幌市' to_node=10 to_name='さいたま市' time=51609 distance=1053644
    Pop from customer dic.= ('那覇市', Customer(name='那覇市', lat=26.2125, lon=127.68111, weight=3011.280000000001))
    Pop from time dic.= (('那覇市', '那覇市'), 0)

### 顧客リストクラス

データフレームを辞書に変換してCustomerListクラスに渡す．

逆にモデルからデータを得ることもできる．

モデルの属性から顧客リストを得た後に，
FastAPIのjsonable_encoder関数で辞書のリストに変換し，そこからデータフレームを生成する．

``` python
from pprint import pprint
model = CustomerList(**{"field_list":cust_df.to_dict("records")})
pprint(jsonable_encoder(model.field_list)[:3]) #JSONで読める形式（この場合は辞書のリスト）
#pd.DataFrame(jsonable_encoder(model.field_list)).head() #データフレームに戻す
```

    [{'lat': 43.06417,
      'lon': 141.34694,
      'name': '札幌市',
      'weight': 9632.389999999998},
     {'lat': 40.82444, 'lon': 140.74, 'name': '青森市', 'weight': 8607.569999999998},
     {'lat': 39.70361, 'lon': 141.1525, 'name': '盛岡市', 'weight': 9614.31}]

### データフレームを検証する関数 valid_test

エラーがあるとJSON形式でエラーを捉えることがでいるので，それをエラーデータフレームに変換して返す．

引数：

- Cls: 検証用のクラス
- df: 検証したいデータフレーム

返値：

- データにエラーがある場合には，エラーの情報を含んだデータフレームを返し，エラーがない場合にはNoneを返す．

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L177"
target="_blank" style="float:right; font-size:smaller">source</a>

### valid_test

``` python

def valid_test(
    Cls:BaseModel, df:DataFrame
):

```

*Call self as a function.*

### valid_test関数の使用例

``` python
#エラー挿入
cust_df.iloc[0,1] = None
cust_df.iloc[0,2] = np.nan
cust_df.iloc[0,3] = "１．２３４５" #大文字だとエラー
time_df.iloc[0,5] = "１．２３４５"

ret = valid_test(CustomerList, cust_df)
print(ret)

ret = valid_test(TimeList, time_df)
print(ret)
```

       row     col                       message
    0    0     lat  none is not an allowed value
    1    0     lon  none is not an allowed value
    2    0  weight    value is not a valid float
       row       col                       message
    0    0  distance  value is not a valid integer

### すべてのデータフレームを検証する関数 test_all

引数：

- df_list: データフレームのリスト
- cls_list: 検証用のクラスのリスト
- name_list: データの名称のリスト

返値：

- errorsheet: エラーがあるデータの名称のリスト
- error_df: エラーの情報を含んだデータフレームのリスト

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L191"
target="_blank" style="float:right; font-size:smaller">source</a>

### test_all

``` python

def test_all(
    df_list, cls_list, name_list
):

```

*Call self as a function.*

### test_all関数の使用例

``` python
df_list = [cust_df, time_df]
cls_list =[CustomerList, TimeList]
name_list =["Customer", "Time"]

error_sheet, error_df = test_all(df_list, cls_list, name_list)

print(error_sheet[0])
print(error_df[0])

print(error_sheet[1])
print(error_df[1])
```

    ### Error in Customer Data
       row     col                       message
    0    0     lat  none is not an allowed value
    1    0     lon  none is not an allowed value
    2    0  weight    value is not a valid float
    ### Error in Time Data
       row       col                       message
    0    0  distance  value is not a valid integer

### REST API用のモデルをもとにWeiszfeld法を適用し，結果の辞書を返す関数 solve_weiszfeld

これはサーバー側で呼ばれ，結果はJSONに変換されて返される．

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L202"
target="_blank" style="float:right; font-size:smaller">source</a>

### solve_weiszfeld

``` python

def solve_weiszfeld(
    model, X0:NoneType=None, Y0:NoneType=None
):

```

*モデルをもとにWeiszfeld法を適用し，結果の辞書を返す関数*

### solve_weiszfeld関数の使用例

データを入れた辞書 test
をMelosGfクラスのコンストラクタにわたすと，モデルのインスタンスが生成される．
モデルをsolve_weizfeldに渡すと求解され，解の情報を保存した辞書が返される．

``` python
sheet = pd.read_excel("melos-gf.xlsx", engine="openpyxl", sheet_name=None) 
cust_df = sheet["melos-gf"]
time_df = sheet["time"]

test ={"num_facilities":5, "seed":3, "customers":cust_df.to_dict("records"), "times":time_df.to_dict("records")}
try:
    model = MelosGf(**test)  # データ検証をこれで行う！　Exceptionがあれば，それを表示する．
except ValidationError as e:
    print(e)
ret = solve_weiszfeld(model) #初期値X0,Y0を入れても良い
print(ret)
```

    {'X': [34.65360063314167, 32.90941699070985, 37.75022939546075, 35.413513788771525, 34.68623309930219], 'Y': [133.92046323477393, 130.63627299431, 140.46771832282408, 136.90252457051528, 135.5198043043494], 'partition': {30: 0, 31: 0, 32: 0, 33: 0, 35: 0, 36: 0, 37: 0, 38: 0, 34: 1, 39: 1, 40: 1, 41: 1, 42: 1, 43: 1, 44: 1, 45: 1, 46: 1, 0: 2, 1: 2, 2: 2, 3: 2, 4: 2, 5: 2, 6: 2, 7: 2, 8: 2, 9: 2, 10: 2, 11: 2, 12: 2, 14: 2, 13: 3, 15: 3, 16: 3, 17: 3, 18: 3, 19: 3, 20: 3, 21: 3, 22: 3, 23: 3, 24: 4, 25: 4, 26: 4, 27: 4, 28: 4, 29: 4}, 'cost': 49104387.09080069, 'cpu': 0.03702592849731445}

### fastAPIでの求解

appはコード内で定義されたFastAPIのインスタンスである．

``` python
@app.post("/melosgf/")
def solve_melos_gf(model: MelosGf):
    return solve_weiszfeld(model)
```

/script/main.py を実行しておく．

### 呼び出し例

データを入れた辞書を，json.dumps関数でJSONファイルに変換してサーバー（以下では，ローカルサーバー
http://127.0.0.1:8000
を仮定）に渡すと，サーバー側でモデルインスタンスに変換される．
それをもとに，最適化計算を行い，結果を返す．結果はレスポンスオブジェクトなので，text属性やjson()関数で中身を得る．

``` python
URL = "http://127.0.0.1:8000/melosgf"
ret = requests.post(URL, data=json.dumps(test))
ret.text
```

### サーバー側で問題例と解を保管

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L226"
target="_blank" style="float:right; font-size:smaller">source</a>

### SolutionPool

``` python

def SolutionPool(
    data:Any
)->None:

```

*Pickleを付加したベースモデル*

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L218"
target="_blank" style="float:right; font-size:smaller">source</a>

### InstancePool

``` python

def InstancePool(
    data:Any
)->None:

```

*Pickleを付加したベースモデル*

``` python
instance_pool = InstancePool()
instance_pool.add(model)
instance_pool.to_pickle("an_instance_pool")
```

``` python
a_solution = Solution(name="melos_gf_sol", data = ret, objval=ret["cost"])
#a_solution.to_pickle()
#a_solution.from_pickle()
a_solution
```

    Solution(name='melos_gf_sol', data={'X': [34.65360063314167, 32.90941699070985, 37.75022939546075, 35.413513788771525, 34.68623309930219], 'Y': [133.92046323477393, 130.63627299431, 140.46771832282408, 136.90252457051528, 135.5198043043494], 'partition': {30: 0, 31: 0, 32: 0, 33: 0, 35: 0, 36: 0, 37: 0, 38: 0, 34: 1, 39: 1, 40: 1, 41: 1, 42: 1, 43: 1, 44: 1, 45: 1, 46: 1, 0: 2, 1: 2, 2: 2, 3: 2, 4: 2, 5: 2, 6: 2, 7: 2, 8: 2, 9: 2, 10: 2, 11: 2, 12: 2, 14: 2, 13: 3, 15: 3, 16: 3, 17: 3, 18: 3, 19: 3, 20: 3, 21: 3, 22: 3, 23: 3, 24: 4, 25: 4, 26: 4, 27: 4, 28: 4, 29: 4}, 'cost': 49104387.09080069}, cpu=None, objval=49104387)

``` python
solution_pool = SolutionPool()
solution_pool.add(a_solution)
solution_pool
```

    SolutionPool(name=None, solution_list=[Solution(name='melos_gf_sol', data='{"X": [34.65360063314167, 32.90941699070985, 37.75022939546075, 35.413513788771525, 34.68623309930219], "Y": [133.92046323477393, 130.63627299431, 140.46771832282408, 136.90252457051528, 135.5198043043494], "partition": {"30": 0, "31": 0, "32": 0, "33": 0, "35": 0, "36": 0, "37": 0, "38": 0, "34": 1, "39": 1, "40": 1, "41": 1, "42": 1, "43": 1, "44": 1, "45": 1, "46": 1, "0": 2, "1": 2, "2": 2, "3": 2, "4": 2, "5": 2, "6": 2, "7": 2, "8": 2, "9": 2, "10": 2, "11": 2, "12": 2, "14": 2, "13": 3, "15": 3, "16": 3, "17": 3, "18": 3, "19": 3, "20": 3, "21": 3, "22": 3, "23": 3, "24": 4, "25": 4, "26": 4, "27": 4, "28": 4, "29": 4}, "cost": 49104387.09080069}', cpu=None, objval=49104387)], solution_dic={'melos_gf_sol': Solution(name='melos_gf_sol', data='{"X": [34.65360063314167, 32.90941699070985, 37.75022939546075, 35.413513788771525, 34.68623309930219], "Y": [133.92046323477393, 130.63627299431, 140.46771832282408, 136.90252457051528, 135.5198043043494], "partition": {"30": 0, "31": 0, "32": 0, "33": 0, "35": 0, "36": 0, "37": 0, "38": 0, "34": 1, "39": 1, "40": 1, "41": 1, "42": 1, "43": 1, "44": 1, "45": 1, "46": 1, "0": 2, "1": 2, "2": 2, "3": 2, "4": 2, "5": 2, "6": 2, "7": 2, "8": 2, "9": 2, "10": 2, "11": 2, "12": 2, "14": 2, "13": 3, "15": 3, "16": 3, "17": 3, "18": 3, "19": 3, "20": 3, "21": 3, "22": 3, "23": 3, "24": 4, "25": 4, "26": 4, "27": 4, "28": 4, "29": 4}, "cost": 49104387.09080069}', cpu=None, objval=49104387)})

## MELOS

### モデル Melos

予測 forecast とSCBASも兼用

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L379"
target="_blank" style="float:right; font-size:smaller">source</a>

### Melos

``` python

def Melos(
    data:Any
)->None:

```

*MELOS モデル*

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L360"
target="_blank" style="float:right; font-size:smaller">source</a>

### Trans

``` python

def Trans(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L356"
target="_blank" style="float:right; font-size:smaller">source</a>

### PlantProductList

``` python

def PlantProductList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L341"
target="_blank" style="float:right; font-size:smaller">source</a>

### PlantProduct

``` python

def PlantProduct(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L338"
target="_blank" style="float:right; font-size:smaller">source</a>

### PlantList

``` python

def PlantList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L323"
target="_blank" style="float:right; font-size:smaller">source</a>

### Plant

``` python

def Plant(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L319"
target="_blank" style="float:right; font-size:smaller">source</a>

### DcList

``` python

def DcList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L302"
target="_blank" style="float:right; font-size:smaller">source</a>

### Dc

``` python

def Dc(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L299"
target="_blank" style="float:right; font-size:smaller">source</a>

### PromotionList

``` python

def PromotionList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L294"
target="_blank" style="float:right; font-size:smaller">source</a>

### Promotion

``` python

def Promotion(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L291"
target="_blank" style="float:right; font-size:smaller">source</a>

### DemandList

``` python

def DemandList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L274"
target="_blank" style="float:right; font-size:smaller">source</a>

### Demand

``` python

def Demand(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L261"
target="_blank" style="float:right; font-size:smaller">source</a>

### TotalDemand

``` python

def TotalDemand(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L257"
target="_blank" style="float:right; font-size:smaller">source</a>

### ProductList

``` python

def ProductList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L235"
target="_blank" style="float:right; font-size:smaller">source</a>

### Product

``` python

def Product(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

### データフレーム検証

``` python
cust_df, prod_df, demand_df, dc_df, plnt_df, plnt_prod_df, time_df = read_xl("melos.xlsx")
```

``` python
sheet_list = ["Cust", "Prod", "demand", "DC", "Plnt", "Plnt-Prod", "time"]
df_list = [cust_df, prod_df, demand_df, dc_df, plnt_df, plnt_prod_df, time_df]
cls_list =[CustomerList, ProductList, DemandList, DcList, PlantList, PlantProductList, TimeList]
for s,df,c in zip(sheet_list, df_list, cls_list):
    ret = valid_test(c, df)
    if ret is not None:
        print(f"Error in Sheet {s}")
        print(ret)
```

``` python
# sheet = pd.read_excel("melos.xlsx", sheet_name=None) #read all sheets 
# prod_df = sheet["Prod"] #extract dataframe 
model = ProductList(**{"field_list":prod_df.to_dict("records")})
#print(type(jsonable_encoder(model.field_list))) #JSONで読める形式（この場合はリスト）
#pd.DataFrame(jsonable_encoder(model.field_list)).head()

model = CustomerList(**{"field_list":cust_df.to_dict("records")})
#pd.DataFrame(jsonable_encoder(model.field_list)).head()

model = DemandList(**{"field_list":demand_df.to_dict("records")})
```

### MELOSをモデルから解く関数 solve_melos

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L396"
target="_blank" style="float:right; font-size:smaller">source</a>

### solve_melos

``` python

def solve_melos(
    model:Melos
):

```

*MELOSをモデルから解く関数*

### REST API呼び出し例

``` python
cust_df = pd.read_csv(folder + "Cust.csv")
plnt_df = pd.read_csv(folder + "Plnt.csv")
total_demand_df = pd.read_csv(folder + "total_demand.csv")
trans_df = pd.read_csv(folder + "trans_cost.csv")
dc_df = pd.read_csv(folder + "DC.csv")
prod_df = pd.read_csv(folder + "Prod.csv")
plnt_prod_df = pd.read_csv(folder + "Plnt-Prod.csv")

test ={"dc_lb":None, "dc_ub":None,"single_sourcing":True,"max_cpu":10,"customers":cust_df.to_dict("records"), 
       "dcs":dc_df.to_dict("records"),"plants":plnt_df.to_dict("records"),  
       "products":prod_df.to_dict("records"),"plnt_prod": plnt_prod_df.to_dict("records"), "total_demand":total_demand.to_dict("records"),
       "trans":trans_df.to_dict("records")}
model = Melos(**test) 
ret = solve_melos(model)
```

``` python
URL = "http://127.0.0.1:8000/melos"
ret = requests.post(URL, data=json.dumps(test))
ret.text[:100]
```

## OptSeq

### モデル OptSeq

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L416"
target="_blank" style="float:right; font-size:smaller">source</a>

### OptSeq

``` python

def OptSeq(
    data:Any
)->None:

```

*OptSeq モデル*

### データフレーム検証用のクラス

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L515"
target="_blank" style="float:right; font-size:smaller">source</a>

### StateList

``` python

def StateList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/optseq.py#L640"
target="_blank" style="float:right; font-size:smaller">source</a>

### State

``` python

def State(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L508"
target="_blank" style="float:right; font-size:smaller">source</a>

### LeftHandSideList

``` python

def LeftHandSideList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L502"
target="_blank" style="float:right; font-size:smaller">source</a>

### LeftHandSide

``` python

def LeftHandSide(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L499"
target="_blank" style="float:right; font-size:smaller">source</a>

### NonrenewableList

``` python

def NonrenewableList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L493"
target="_blank" style="float:right; font-size:smaller">source</a>

### Nonrenewable

``` python

def Nonrenewable(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L490"
target="_blank" style="float:right; font-size:smaller">source</a>

### TemporaryList

``` python

def TemporaryList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L484"
target="_blank" style="float:right; font-size:smaller">source</a>

### Temporary

``` python

def Temporary(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L481"
target="_blank" style="float:right; font-size:smaller">source</a>

### ModeResourceList

``` python

def ModeResourceList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L475"
target="_blank" style="float:right; font-size:smaller">source</a>

### ModeResource

``` python

def ModeResource(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L472"
target="_blank" style="float:right; font-size:smaller">source</a>

### ActivityModeList

``` python

def ActivityModeList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L468"
target="_blank" style="float:right; font-size:smaller">source</a>

### ActivityMode

``` python

def ActivityMode(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L465"
target="_blank" style="float:right; font-size:smaller">source</a>

### ResourceList

``` python

def ResourceList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/optseq.py#L374"
target="_blank" style="float:right; font-size:smaller">source</a>

### Resource

``` python

def Resource(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L458"
target="_blank" style="float:right; font-size:smaller">source</a>

### ModeList

``` python

def ModeList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/optseq.py#L95"
target="_blank" style="float:right; font-size:smaller">source</a>

### Mode

``` python

def Mode(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L448"
target="_blank" style="float:right; font-size:smaller">source</a>

### ActivityList

``` python

def ActivityList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/optseq.py#L287"
target="_blank" style="float:right; font-size:smaller">source</a>

### Activity

``` python

def Activity(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

``` python
sheet = pd.read_excel("optseq.xlsx", engine="openpyxl", sheet_name=None)
sheet_list = ["act", "mode", "res", "act_mode", "mode_res", "temp", "non_res", "non_lhs", "state"]
cls_list =[ActivityList, ModeList, ResourceList, ActivityModeList, ModeResourceList, TemporaryList, NonrenewableList, LeftHandSideList, StateList]
sheet["mode"].iloc[0,4] = "{4:5}"
for s,c in zip(sheet_list, cls_list):
    ret = valid_test(c, sheet[s])
    if ret is not None:
        print(f"Error in Sheet {s}")
        print(ret)
```

``` python
model = optseq.ex1()
act_df, res_df, mode_df, act_mode_df, mode_res_df, temp_df, non_res_df, non_lhs_df, state_df = optseq.convert(model)
act_df.head()
```

<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }
&#10;    .dataframe tbody tr th {
        vertical-align: top;
    }
&#10;    .dataframe thead th {
        text-align: right;
    }
</style>

<table class="dataframe" data-quarto-postprocess="true" data-border="1">
<thead>
<tr style="text-align: right;">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th">name</th>
<th data-quarto-table-cell-role="th">duedate</th>
<th data-quarto-table-cell-role="th">backward</th>
<th data-quarto-table-cell-role="th">weight</th>
<th data-quarto-table-cell-role="th">autoselect</th>
</tr>
</thead>
<tbody>
<tr>
<td data-quarto-table-cell-role="th">0</td>
<td>Act[1]</td>
<td>inf</td>
<td>False</td>
<td>1</td>
<td>False</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">1</td>
<td>Act[2]</td>
<td>inf</td>
<td>False</td>
<td>1</td>
<td>False</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">2</td>
<td>Act[3]</td>
<td>inf</td>
<td>False</td>
<td>1</td>
<td>False</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">3</td>
<td>Act[4]</td>
<td>inf</td>
<td>False</td>
<td>1</td>
<td>False</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">4</td>
<td>Act[5]</td>
<td>inf</td>
<td>False</td>
<td>1</td>
<td>False</td>
</tr>
</tbody>
</table>

</div>

``` python
ret = valid_test(ActivityList, act_df)
print(ret)
```

    None

### モデルから求解する関数 solve_optseq

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L519"
target="_blank" style="float:right; font-size:smaller">source</a>

### solve_optseq

``` python

def solve_optseq(
    model
):

```

*以下をローカルのソルバーと置き換える．すべて実行環境はlinuxとする．*

### REST API呼び出し例

``` python
ex1_model = optseq.ex1()
test = {"text_model": ex1_model.update(), "max_cpu": 1}
model = OptSeq(**test)
solve_optseq(model)
```

``` python
URL = "http://127.0.0.1:8000/optseq"
ret = requests.post(URL, data=json.dumps(test))
ret.json()
```

## SCOP

### モデル　SCOP

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L573"
target="_blank" style="float:right; font-size:smaller">source</a>

### Scop

``` python

def Scop(
    data:Any
)->None:

```

*SCOP モデル*

\### モデルから求解する関数 solve_scop

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L596"
target="_blank" style="float:right; font-size:smaller">source</a>

### solve_scop

``` python

def solve_scop(
    model
):

```

*以下をローカルのソルバーと置き換える．すべて実行環境はlinuxとする．*

### REST API呼び出し例

``` python
workers=['A','B','C']
Jobs   =[0,1,2]
Cost={ ('A',0):15, ('A',1):20, ('A',2):30,
       ('B',0): 7, ('B',1):15, ('B',2):12,
       ('C',0):25, ('C',1):10, ('C',2):13 }

m=scop.Model()
x={}
for i in workers:
    x[i]=m.addVariable(name=i,domain=Jobs)

xlist=[]
for i in x:
    xlist.append(x[i])

con1=scop.Alldiff('AD',xlist,weight='inf')

con2=scop.Linear('linear_constraint',weight=1,rhs=0,direction='<=')
for i in workers:
    for j in Jobs:
        con2.addTerms(Cost[i,j],x[i],j)

m.addConstraint(con1)
m.addConstraint(con2)

test = {"text_model": m.update(), "max_cpu": 1}
model = Scop(**test)
solve_scop(model)
```

``` python
URL = "http://127.0.0.1:8000/scop"
ret = requests.post(URL, data=json.dumps(test))
ret.json()
```

## METRO

### モデル Metro

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L818"
target="_blank" style="float:right; font-size:smaller">source</a>

### Metro

``` python

def Metro(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L815"
target="_blank" style="float:right; font-size:smaller">source</a>

### ShipmentList

``` python

def ShipmentList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L767"
target="_blank" style="float:right; font-size:smaller">source</a>

### Shipment

``` python

def Shipment(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L745"
target="_blank" style="float:right; font-size:smaller">source</a>

### ShipmentStep

``` python

def ShipmentStep(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L742"
target="_blank" style="float:right; font-size:smaller">source</a>

### JobList

``` python

def JobList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L710"
target="_blank" style="float:right; font-size:smaller">source</a>

### Job

``` python

def Job(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L707"
target="_blank" style="float:right; font-size:smaller">source</a>

### VehicleList

``` python

def VehicleList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L669"
target="_blank" style="float:right; font-size:smaller">source</a>

### Vehicle

``` python

def Vehicle(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L665"
target="_blank" style="float:right; font-size:smaller">source</a>

### BreakList

``` python

def BreakList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L650"
target="_blank" style="float:right; font-size:smaller">source</a>

### Break

``` python

def Break(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L647"
target="_blank" style="float:right; font-size:smaller">source</a>

### NodeList

``` python

def NodeList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L641"
target="_blank" style="float:right; font-size:smaller">source</a>

### Node

``` python

def Node(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

### データフレーム検証用のクラス

正規表現を用いる．

#### データフレーム検証

``` python
sheet = pd.read_excel("metro.xlsx", engine="openpyxl", sheet_name=None) #read all sheets 

sheet_list = ["break", "vehicle", "job", "shipment", "node", "time"]
cls_list =[BreakList, VehicleList, JobList, ShipmentList, NodeList, TimeList]
for s,c in zip(sheet_list, cls_list):
    ret = valid_test(c, sheet[s])
    if ret is not None:
        print(f"Error in Sheet {s}")
        print(ret)
```

### モデルから求解する関数 solve_metro

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L826"
target="_blank" style="float:right; font-size:smaller">source</a>

### solve_metro

``` python

def solve_metro(
    model, matrix:bool=False, threads:int=4, explore:int=1
):

```

*Call self as a function.*

### REST API呼び出し例

``` python
no ="06"
node_df = pd.read_csv(folder +"metroIV/node"+no+".csv")
job_df = pd.read_csv(folder +"metroIV/job"+no+".csv") 
shipment_df = pd.read_csv(folder +"metroIV/shipment"+no+".csv") 
vehicle_df = pd.read_csv(folder +"metroIV/vehicle"+no+".csv") 
time_df = pd.read_csv(folder+"metroIV/time"+no+".csv", index_col=0)
break_df = pd.read_csv(folder +"metroIV/break.csv", index_col=0)
model = metro.build_model_for_vrp(job_df, shipment_df, vehicle_df, break_df, time_df) #JSONのもとになる辞書を返す

#model = Metro(**model) 
#ret = solve_metro(model)
#jsonable_encoder(model.shipments[0])
#Vehicle(**model["vehicles"][0])
#model["shipments"][0]
```

``` python
URL = "http://127.0.0.1:8000/metro"
ret = requests.post(URL, data=json.dumps(model)) 
ret.text[:100]
```

## MESSA

### モデル Messa

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L933"
target="_blank" style="float:right; font-size:smaller">source</a>

### Messa

``` python

def Messa(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L930"
target="_blank" style="float:right; font-size:smaller">source</a>

### BomList

``` python

def BomList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L916"
target="_blank" style="float:right; font-size:smaller">source</a>

### Bom

``` python

def Bom(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L912"
target="_blank" style="float:right; font-size:smaller">source</a>

### StageList

``` python

def StageList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L877"
target="_blank" style="float:right; font-size:smaller">source</a>

### Stage

``` python

def Stage(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

### データフレーム検証

``` python
sheet = pd.read_excel("messa.xlsx", engine="openpyxl", sheet_name=None) #read all sheets 
sheet_list = ["stage", "bom"]
cls_list =[StageList, BomList]
for s,c in zip(sheet_list, cls_list):
    ret = valid_test(c, sheet[s])
    if ret is not None:
        print(f"Error in Sheet {s}")
        print(ret)
```

### モデルから求解する関数 solve_messa

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L938"
target="_blank" style="float:right; font-size:smaller">source</a>

### solve_messa

``` python

def solve_messa(
    model:Messa
):

```

*SSAをモデルから解く関数*

### REST API呼び出し例

``` python
folder_bom = "../data/bom/"
stage_df = pd.read_csv(folder_bom + "ssa03.csv")
bom_df = pd.read_csv(folder_bom + "ssa_bom03.csv")
#best_cost, stage_df, bom_df, fig = optinv.solve_SSA(stage_df, bom_df)
test = {"stages": stage_df.to_dict("records"), "boms": bom_df.to_dict("records")}
model = Messa(**test)
URL = "http://127.0.0.1:8000/messa"
ret = requests.post(URL, data=json.dumps(test)) 
#jsonable_encoder(model.boms[0])
```

## OptInv

モデルはMessaと同じ

### モデルから求解する関数 solve_optinv

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L948"
target="_blank" style="float:right; font-size:smaller">source</a>

### solve_optinv

``` python

def solve_optinv(
    model:Messa
):

```

*periodic_inv_optをモデルから解く関数*

### REST API呼び出し例

``` python
URL = "http://127.0.0.1:8000/optinv"
ret = requests.post(URL, data=json.dumps(test))
```

## SENDO

### モデル Sendo

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L958"
target="_blank" style="float:right; font-size:smaller">source</a>

### Sendo

``` python

def Sendo(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

### データフレーム検証

``` python
sheet = pd.read_excel("sendo.xlsx", engine="openpyxl", sheet_name=None) #read all sheets 
dc_df = sheet["DC"]
od_df = sheet["od"]
ret = valid_test(DcList, dc_df)
print(ret)
```

    None

``` python
#name1 = tuple(dc_df.name)
#name2 = tuple(od_df.name)
#assert name1 == name2
#長さのみ検証
n,_ = dc_df.shape
rows, cols = od_df.shape
if rows==n and cols-1 == n:
    print("OK")
```

    OK

### モデルから求解する関数 solve_sendo

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L972"
target="_blank" style="float:right; font-size:smaller">source</a>

### solve_sendo

``` python

def solve_sendo(
    model:Sendo
):

```

*Solve SENDO using Sendo model*

### REST API呼び出し例

``` python
dc_df = pd.read_csv(folder + "DC.csv", index_col=0) #ub =base capacity, vc = transfer cost
od_df = pd.read_csv(folder + "od.csv", index_col=0)

n= 10
dc_df = dc_df.iloc[:n,:]
od_df = od_df.iloc[:n,:n]

#リストのリストに変換
L =[]
for row in od_df.values:
    L.append( list(row) )
test ={
    "cost_per_dis":20, "cost_per_time":8000, "capacity":1000., "max_cpu":10, "scaling":False, "k":10, "alpha":0.5, "max_iter":10, "osrm": False,
    "dcs": dc_df.to_dict("records"), "demand":L}
#model = Sendo(**test)
URL = "http://127.0.0.1:8000/sendo"
ret = requests.post(URL, data=json.dumps(test))
```

## OptShift

### モデル OptShift

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L1103"
target="_blank" style="float:right; font-size:smaller">source</a>

### OptShift

``` python

def OptShift(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L1082"
target="_blank" style="float:right; font-size:smaller">source</a>

### Parameter

``` python

def Parameter(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L1078"
target="_blank" style="float:right; font-size:smaller">source</a>

### RequirementList

``` python

def RequirementList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L1064"
target="_blank" style="float:right; font-size:smaller">source</a>

### Requirement

``` python

def Requirement(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L1061"
target="_blank" style="float:right; font-size:smaller">source</a>

### StaffList

``` python

def StaffList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L1043"
target="_blank" style="float:right; font-size:smaller">source</a>

### Staff

``` python

def Staff(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L1040"
target="_blank" style="float:right; font-size:smaller">source</a>

### ShiftJobList

``` python

def ShiftJobList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L1030"
target="_blank" style="float:right; font-size:smaller">source</a>

### ShiftJob

``` python

def ShiftJob(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L1027"
target="_blank" style="float:right; font-size:smaller">source</a>

### DayList

``` python

def DayList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L1013"
target="_blank" style="float:right; font-size:smaller">source</a>

### Day

``` python

def Day(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L1009"
target="_blank" style="float:right; font-size:smaller">source</a>

### ShiftBreakList

``` python

def ShiftBreakList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L999"
target="_blank" style="float:right; font-size:smaller">source</a>

### ShiftBreak

``` python

def ShiftBreak(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L996"
target="_blank" style="float:right; font-size:smaller">source</a>

### PeriodList

``` python

def PeriodList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L986"
target="_blank" style="float:right; font-size:smaller">source</a>

### Period

``` python

def Period(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

### データフレーム検証

``` python
sheet = pd.read_excel("optshift.xlsx", engine="openpyxl", sheet_name = None)
sheet_list = ["period", "break", "day", "job", "staff", "requirement"]
cls_list =[PeriodList, ShiftBreakList, DayList, ShiftJobList, StaffList, RequirementList]
for s,c in zip(sheet_list, cls_list):
    ret = valid_test(c, sheet[s])
    if ret is not None:
        print(f"Error in Sheet {s}")
        print(ret)
```

``` python
folder = "../data/shift/"
period_df = pd.read_csv(folder+"period.csv", index_col=0)
break_df = pd.read_csv(folder+"break.csv", index_col=0)
day_df = pd.read_csv(folder+"day.csv", index_col=0)
job_df = pd.read_csv(folder+"job.csv", index_col=0)
staff_df = pd.read_csv(folder+"staff.csv", index_col=0)
requirement_df = pd.read_csv(folder+"requirement.csv", index_col=0)

test ={"periods": period_df.to_dict("records"),
       "breaks": break_df.to_dict("records"),
       "days": day_df.to_dict("records"),
       "jobs": job_df.to_dict("records"),
       "staffs": staff_df.to_dict("records"),
       "requirements": requirement_df.to_dict("records"),
       "parameters": {"random_seed": 2, "time_limit": 1}
      }
model = OptShift(**test)
jsonable_encoder(model.requirements[1])
```

    {'day_type': 'weekday', 'job': 1, 'period': 1, 'requirement': 2}

### モデルから求解する関数

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L1113"
target="_blank" style="float:right; font-size:smaller">source</a>

### solve_optshift

``` python

def solve_optshift(
    model
):

```

*Solve OPTSHIFT using OptShift model*

### REST API呼び出し例

``` python
URL = "http://127.0.0.1:8000/optshift/"
ret = requests.post(URL, data=json.dumps(test)) 
ret.text[:30]
```

## OptLot

### モデル OptLot

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L1162"
target="_blank" style="float:right; font-size:smaller">source</a>

### LotResourceList

``` python

def LotResourceList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L1157"
target="_blank" style="float:right; font-size:smaller">source</a>

### LotResource

``` python

def LotResource(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L1154"
target="_blank" style="float:right; font-size:smaller">source</a>

### PlantDemandList

``` python

def PlantDemandList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L1149"
target="_blank" style="float:right; font-size:smaller">source</a>

### PlantDemand

``` python

def PlantDemand(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L1145"
target="_blank" style="float:right; font-size:smaller">source</a>

### ProductionList

``` python

def ProductionList(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

------------------------------------------------------------------------

<a
href="https://github.com/scmopt/manual/tree/master/blob/master/scmopt/rest.py#L1138"
target="_blank" style="float:right; font-size:smaller">source</a>

### Production

``` python

def Production(
    data:Any
)->None:

```

*!!! abstract “Usage Documentation”* [Models](../concepts/models.md)

A base class for creating Pydantic models.

Attributes: **class_vars**: The names of the class variables defined on
the model. **private_attributes**: Metadata about the private attributes
of the model. **signature**: The synthesized `__init__`
\[`Signature`\]\[inspect.Signature\] of the model.

    __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
    __pydantic_core_schema__: The core schema of the model.
    __pydantic_custom_init__: Whether the model has a custom `__init__` function.
    __pydantic_decorators__: Metadata containing the decorators defined on the model.
        This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
    __pydantic_generic_metadata__: A dictionary containing metadata about generic Pydantic models.
        The `origin` and `args` items map to the [`__origin__`][genericalias.__origin__]
        and [`__args__`][genericalias.__args__] attributes of [generic aliases][types-genericalias],
        and the `parameter` item maps to the `__parameter__` attribute of generic classes.
    __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
    __pydantic_post_init__: The name of the post-init method for the model, if defined.
    __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
    __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
    __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

    __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects.
    __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects.

    __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
        is set to `'allow'`.
    __pydantic_fields_set__: The names of fields explicitly set during instantiation.
    __pydantic_private__: Values of private attributes set on the model instance.

``` python
sheet = pd.read_excel("optlot.xlsx", engine="openpyxl", sheet_name =None)
sheet_list = ["lotprod", "production", "bom", "plnt-demand", "resource"]
cls_list =[ProductList, ProductionList, BomList, PlantDemandList, LotResourceList]
for s,c in zip(sheet_list, cls_list):
    ret = valid_test(c, sheet[s])
    if ret is not None:
        print(f"Error in Sheet {s}")
        print(ret)
```

## OptLot0

Excelのインターフェイスに対するクラス

``` python
#動的にクラスの属性を追加する方法
#https://stackoverflow.com/questions/66168517/generate-dynamic-model-using-pydantic 参照
from pydantic import create_model
d = {}
for i in range(3):
    d[f"Skill{i}"] = (bool, ...) # (型,...) ...は既定値なしを意味する
Customer = create_model("Customer", **d)

print(Customer.schema())
```

    {'title': 'Customer', 'type': 'object', 'properties': {'Skill0': {'title': 'Skill0', 'type': 'boolean'}, 'Skill1': {'title': 'Skill1', 'type': 'boolean'}, 'Skill2': {'title': 'Skill2', 'type': 'boolean'}}, 'required': ['Skill0', 'Skill1', 'Skill2']}

``` python
#漢字の変数名が使える =>Excelの列名と一致させる（ただし () などは使えないので取る）
#fastapiでの利用は？ 漢字より英語？
class Item(BaseModel):
    名称: str
    在庫費用: float
    在庫量下限: float
    在庫量上限: float
    初期在庫量: float
    最終在庫量: float 

class ItemList(BaseModel):
    field_list: List[Item]= Field(description="品目リスト", default=[])
        
print(Item.schema())
```

    {'title': 'Item', 'type': 'object', 'properties': {'名称': {'title': '名称', 'type': 'string'}, '在庫費用': {'title': '在庫費用', 'type': 'number'}, '在庫量下限': {'title': '在庫量下限', 'type': 'number'}, '在庫量上限': {'title': '在庫量上限', 'type': 'number'}, '初期在庫量': {'title': '初期在庫量', 'type': 'number'}, '最終在庫量': {'title': '最終在庫量', 'type': 'number'}}, 'required': ['名称', '在庫費用', '在庫量下限', '在庫量上限', '初期在庫量', '最終在庫量']}

``` python
wb = load_workbook("optlot-master2-ex1.xlsx")
item_df, process_df, resource_df, bom_df, usage_df = lot.read_dfs_from_excel_lot(wb)
```

``` python
#Pydanticクラスとデータフレームの各行で validation test
cls_list =[ItemList]
sheet_list = [item_df]
for s,c in zip(sheet_list, cls_list):
    ret = valid_test(c, s)
    if ret is not None:
        print(f"Error in Sheet {s}")
        print(ret)
```

    Error in Sheet            名称  在庫費用  在庫量下限  在庫量上限  初期在庫量  最終在庫量
    0        None    54      0   1000      0      0
    1        Can6    74      0   1000      0      0
    2     Bottle1     8      0   1000      0      0
    3        Can1     9      0   1000      0      0
    4       Apple     1      0   1000      0      0
    5  Watermelon     2      0   1000      0      0
       row col                       message
    0    0  名称  none is not an allowed value

``` python
item_df.iloc[0,0] = None
item_df
```

<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }
&#10;    .dataframe tbody tr th {
        vertical-align: top;
    }
&#10;    .dataframe thead th {
        text-align: right;
    }
</style>

<table class="dataframe" data-quarto-postprocess="true" data-border="1">
<thead>
<tr style="text-align: right;">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th">名称</th>
<th data-quarto-table-cell-role="th">在庫費用</th>
<th data-quarto-table-cell-role="th">在庫量下限</th>
<th data-quarto-table-cell-role="th">在庫量上限</th>
<th data-quarto-table-cell-role="th">初期在庫量</th>
<th data-quarto-table-cell-role="th">最終在庫量</th>
</tr>
</thead>
<tbody>
<tr>
<td data-quarto-table-cell-role="th">0</td>
<td>None</td>
<td>54</td>
<td>0</td>
<td>1000</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">1</td>
<td>Can6</td>
<td>74</td>
<td>0</td>
<td>1000</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">2</td>
<td>Bottle1</td>
<td>8</td>
<td>0</td>
<td>1000</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">3</td>
<td>Can1</td>
<td>9</td>
<td>0</td>
<td>1000</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">4</td>
<td>Apple</td>
<td>1</td>
<td>0</td>
<td>1000</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td data-quarto-table-cell-role="th">5</td>
<td>Watermelon</td>
<td>2</td>
<td>0</td>
<td>1000</td>
<td>0</td>
<td>0</td>
</tr>
</tbody>
</table>

</div>
