Skip to content

Commit

Permalink
chore: fix math formula.
Browse files Browse the repository at this point in the history
  • Loading branch information
fuookami committed Mar 31, 2024
1 parent 2b893ca commit b2398d9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ ospf introduces a concept called "intermediate expression" to facilitate DDD-bas
The initial purpose of designing intermediate expressions was to reduce redundancy in mathematical models. Therefore, the most basic arithmetic intermediate expressions are constructed using a polynomial, allowing users to replace all identical polynomials with this intermediate expression anywhere in the model.

$$
ExprSymbol = \sum_{i} x_{i} \\ \; \\
min \quad ExprSymbol \\ \; \\
ExprSymbol = \sum_{i} x_{i} \\\\\\ \\\; \\\\\\
min \quad ExprSymbol \\\\\\ \\\; \\\\\\
s.t. \quad ExprSymbol \leq 1
$$

Expand All @@ -42,19 +42,19 @@ This engineering practice is similar to <strong><em>Object-Oriented Design</em><
Building upon the concept of arithmetic intermediate expressions, ospf can also encapsulate non-arithmetic expressions such as logical operations into intermediate expressions.

$$
FuncSymbol = \bigvee_{i} x_{i} = Or(x_{1}, \, x_{2}, \, .. \, , \, x_{i}) \\ \; \\
FuncSymbol = \bigvee_{i} x_{i} = Or(x_{1}, \, x_{2}, \, .. \, , \, x_{i}) \\\\\\ \\\; \\\\\\
s.t. \quad FuncSymbol = 1
$$

When ospf translates the model into interfaces for specific solvers, it automatically adds the intermediate variables and constraints required for each intermediate expressions. This translation process is transparent to the users, so the users don't need to know how the intermediate expressions are implemented through which intermediate variables and constraints. For example, the expression $FuncSymbol = \bigvee_{i} x_{i}$ will be translated as follows:

$$
s.t. \quad y = 1, \; \\ \; \\
s.t. \quad y = 1 \\\\\\ \\\; \\\\\\
\begin{cases}
y \geq \frac{x_{i}}{\sup_{\leq}(x_{i})}, & \sup_{\leq}(x_{i}) > 1 \\ \;
y \geq \frac{x_{i}}{\sup_{\leq}(x_{i})}, & \sup_{\leq}(x_{i}) > 1 \\\\\\
y \geq x_{i}, & else
\end{cases} \\ \; \\
y \leq \sum_{i} x_{i}, \; \forall i \\ \; \\
\end{cases} \\\\\\ \\\; \\\\\\
y \leq \sum_{i} x_{i}, \; \forall i \\\\\\ \\\; \\\\\\
y \in \{ 0, 1 \}
$$

Expand Down
14 changes: 7 additions & 7 deletions README_ch.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ ospf 提供了一种命名为“中间值”的概念,以实现基于 DDD 的
中间值最开始的设计目的是为了减少数学模型中的重复,所以最基本的算术中间值就是通过一个多项式来构建,然后使用者就可以在模型的任何地方使用该中间值替代所有同样的多项式。

$$
ExprSymbol = \sum_{i} x_{i} \\\\ \\; \\\\
min \quad ExprSymbol \\\\ \\; \\\\
ExprSymbol = \sum_{i} x_{i} \\\\\\ \\\; \\\\\\
min \quad ExprSymbol \\\\\\ \\\; \\\\\\
s.t. \quad ExprSymbol \leq 1
$$

Expand All @@ -41,19 +41,19 @@ ospf 会在将模型翻译到具体求解器的接口时,自动将把每个算
基于算术中间值的思想,ospf 同样可以把类似逻辑运算表达式等非算术表达式封装到中间值中。

$$
FuncSymbol = \bigvee_{i} x_{i} = Or(x_{1}, \, x_{2}, \, .. \, , \, x_{i}) \\\\ \\; \\\\
FuncSymbol = \bigvee_{i} x_{i} = Or(x_{1}, \, x_{2}, \, .. \, , \, x_{i}) \\\\\\ \\\; \\\\\\
s.t. \quad FuncSymbol = 1
$$

ospf 会在将模型翻译到具体求解器的接口时,自动添加每个函数中间值所需的中间变量以及约束。这个翻译过程对于使用者而言是无感知的,因此使用者并不需要知道这个函数中间值是通过什么中间变量以及约束实现的。比如上面的这个 $FuncSymbol = \bigvee_{i} x_{i}$ 就会被翻译成:

$$
s.t. \quad y = 1 \\\\ \\; \\\\
s.t. \quad y = 1 \\\\\\ \\\; \\\\\\
\begin{cases}
y \geq \frac{x_{i}}{\sup_{\leq}(x_{i})}, & \sup_{\leq}(x_{i}) > 1 \\\\
y \geq \frac{x_{i}}{\sup_{\leq}(x_{i})}, & \sup_{\leq}(x_{i}) > 1 \\\\\\
y \geq x_{i}, & else
\end{cases} \\\\ \\; \\\\
y \leq \sum_{i} x_{i}, \; \forall i \\\\ \\; \\\\
\end{cases} \\\\\\ \\\; \\\\\\
y \leq \sum_{i} x_{i}, \; \forall i \\\\\\ \\\; \\\\\\
y \in \{ 0, 1 \}
$$

Expand Down

0 comments on commit b2398d9

Please sign in to comment.