Variable¶
Variable ¶
Bases: _expression.Expression
Abstract class for variables.
__init__(label, shape=tuple([]), uuid=None) ¶
__getitem__(key) ¶
[] operator for adding subscripts if the user specifies str for the.
argument which is available for previous versions of JijModeling (<=0.8.14), This function throws an error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key | subscripts | required |
Raises:
| Type | Description |
|---|---|
ModelingError | If there is a discrepancy between the dimension of the variable and the number of subscripts added. |
TypeError | key type check. |
Returns:
| Type | Description |
|---|---|
tp.Union[Subscripts, _sum.SumOperator] | Subscripted variable. |
Subscripts ¶
Bases: _expression.Expression
__init__(variable, subscripts, uuid=None) ¶
is_operatable() ¶
Check scalar or not.
If the subscripts are specified as many times as the dimension of the variable, the Subscripts object is 'operatable' because it is a scalar.
Returns:
| Name | Type | Description |
|---|---|---|
bool | bool | is operatable or not. |
__getitem__(key) ¶
Overload [] operator for adding subscripts if the user specifies str.
for the argument which is available for previous versions of JijModeling (<=0.8.14), This function throws an error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key | subscripts | required |
Raises:
| Type | Description |
|---|---|
TypeError | key type check. |
Returns:
| Type | Description |
|---|---|
tp.Union['Subscripts', _sum.SumOperator] | Subscripted variable. |
Element ¶
Bases: Variable
__init__(label, parent, uuid=None) ¶
Element object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label | str | variable label | required |
parent | tp.Union[tp.Tuple[tp.Union[int, Expression], tp.Union[int, Expression]], Expression, int, Range] | parent of element | required |
Examples:
```python
import jijmodeling as jm n = jm.Placeholder("n") i = jm.Element("i", belong_to=n) i.belong_to (0, n) jm.Element("i", belong_to=(1, n)).belong_to (1, n) V = jm.Placeholder("V") i = jm.Element("i", belong_to=V) # represents i in V i.belong_to V ````
Range ¶
__init__(start, last, uuid=None) ¶
Range object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start | tp.Union[Expression, int] | range start | required |
last | tp.Union[Expression, int] | range last | required |
Examples:
>>> import jijmodeling as jm
>>> n = jm.Placeholder('n')
>>> r = jm.expression.variables.variable.Range(0,n)
>>> r.start
0
>>> r.last
n
type_check_bool(value, cls) ¶
Do a type_check_and returns whether the validation succeeds or not.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value | value to be validated | required | |
cls | type | required |
Returns:
| Name | Type | Description |
|---|---|---|
bool | bool | return if |