Prod¶
Prod(indices, term) ¶
Prod function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices | Union[INDEXWITHCOND, List[INDEXWITHCOND]] | product index dict or list of index. | required |
term | Expression | operand | required |
Returns:
| Name | Type | Description |
|---|---|---|
ProdOperator | ProdOperator | ProdOperator object. |
Example
Create $\prod_{i=0}^n d_i x_i$
import jijmodeling as jm
d = jm.Placeholder('d', dim=1)
n = d.shape[0]
x = jm.Binary('x', shape=n)
i = jm.Element('i', n)
jm.Prod(i, d[i]*x[i])
Create $\prod_{i}\sum_j d_{ij}x_i x_j$
import jijmodeling as jm
d = jm.Placeholder('d', dim = 2)
n = d.shape[0]
x = jm.Binary('x', shape=n)
i = jm.Element('i', n)
j = jm.Element('j', n)
jm.Prod([i, j], d[i, j]*x[i]*x[j])
Conditional production
import jijmodeling as jm
d = jm.Placeholder('d', dim = 2)
n = d.shape[0]
i, j = jm.Element("i", n), jm._variable.Element("j", n)
x = jm.Binary('x', shape=n)
jm.Prod([i, (j, i < j)], d[i, j]*x[i]*x[j])
prod(index, operand) ¶
Prod function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices | product index dict or list of index. | required | |
operand | Expression | operand | required |
Returns:
| Name | Type | Description |
|---|---|---|
ProdOperator | ProdOperator | ProdOperator object. |
Example
Create $\prod_{i=0}^n d_i x_i$
import jijmodeling as jm
d = jm.Placeholder('d', ndim=1)
n = d.shape[0]
x = jm.BinaryVar('x', shape=n)
i = jm.Element('i', n)
jm.prod(i, d[i]*x[i])
Create $\prod_{i}\sum_j d_{ij}x_i x_j$
import jijmodeling as jm
d = jm.Placeholder('d', ndim=2)
n = d.shape[0]
x = jm.BinaryVar('x', shape=n)
i = jm.Element('i', n)
j = jm.Element('j', n)
jm.prod([i, j], d[i, j]*x[i]*x[j])
Conditional production
import jijmodeling as jm
d = jm.Placeholder('d', ndim=2)
n = d.shape[0]
i, j = jm.Element("i", n), jm._variable.Element("j", n)
x = jm.BinaryVar('x', shape=n)
jm.prod([i, (j, i < j)], d[i, j]*x[i]*x[j])
Last update: 2023年7月5日