Skip to content

Commit d355cc0

Browse files
committed
chore: fix math formula.
1 parent b2398d9 commit d355cc0

File tree

2 files changed

+48
-12
lines changed

2 files changed

+48
-12
lines changed

README.md

+24-6
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,14 @@ ospf introduces a concept called "intermediate expression" to facilitate DDD-bas
2626
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.
2727

2828
$$
29-
ExprSymbol = \sum_{i} x_{i} \\\\\\ \\\; \\\\\\
30-
min \quad ExprSymbol \\\\\\ \\\; \\\\\\
29+
ExprSymbol = \sum_{i} x_{i}
30+
$$
31+
32+
$$
33+
min \quad ExprSymbol
34+
$$
35+
36+
$$
3137
s.t. \quad ExprSymbol \leq 1
3238
$$
3339

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

4450
$$
45-
FuncSymbol = \bigvee_{i} x_{i} = Or(x_{1}, \, x_{2}, \, .. \, , \, x_{i}) \\\\\\ \\\; \\\\\\
51+
FuncSymbol = \bigvee_{i} x_{i} = Or(x_{1}, \, x_{2}, \, .. \, , \, x_{i})
52+
$$
53+
54+
$$
4655
s.t. \quad FuncSymbol = 1
4756
$$
4857

4958
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:
5059

5160
$$
52-
s.t. \quad y = 1 \\\\\\ \\\; \\\\\\
61+
s.t. \quad y = 1
62+
$$
63+
64+
$$
5365
\begin{cases}
5466
y \geq \frac{x_{i}}{\sup_{\leq}(x_{i})}, & \sup_{\leq}(x_{i}) > 1 \\\\\\
5567
y \geq x_{i}, & else
56-
\end{cases} \\\\\\ \\\; \\\\\\
57-
y \leq \sum_{i} x_{i}, \; \forall i \\\\\\ \\\; \\\\\\
68+
\end{cases}
69+
$$
70+
71+
$$
72+
y \leq \sum_{i} x_{i}, \; \forall i
73+
$$
74+
75+
$$
5876
y \in \{ 0, 1 \}
5977
$$
6078

README_ch.md

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

2727
$$
28-
ExprSymbol = \sum_{i} x_{i} \\\\\\ \\\; \\\\\\
29-
min \quad ExprSymbol \\\\\\ \\\; \\\\\\
28+
ExprSymbol = \sum_{i} x_{i}
29+
$$
30+
31+
$$
32+
min \quad ExprSymbol
33+
$$
34+
35+
$$
3036
s.t. \quad ExprSymbol \leq 1
3137
$$
3238

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

4349
$$
44-
FuncSymbol = \bigvee_{i} x_{i} = Or(x_{1}, \, x_{2}, \, .. \, , \, x_{i}) \\\\\\ \\\; \\\\\\
50+
FuncSymbol = \bigvee_{i} x_{i} = Or(x_{1}, \, x_{2}, \, .. \, , \, x_{i})
51+
$$
52+
53+
$$
4554
s.t. \quad FuncSymbol = 1
4655
$$
4756

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

5059
$$
51-
s.t. \quad y = 1 \\\\\\ \\\; \\\\\\
60+
s.t. \quad y = 1
61+
$$
62+
63+
$$
5264
\begin{cases}
5365
y \geq \frac{x_{i}}{\sup_{\leq}(x_{i})}, & \sup_{\leq}(x_{i}) > 1 \\\\\\
5466
y \geq x_{i}, & else
55-
\end{cases} \\\\\\ \\\; \\\\\\
56-
y \leq \sum_{i} x_{i}, \; \forall i \\\\\\ \\\; \\\\\\
67+
\end{cases}
68+
$$
69+
70+
$$
71+
y \leq \sum_{i} x_{i}, \; \forall i
72+
$$
73+
74+
$$
5775
y \in \{ 0, 1 \}
5876
$$
5977

0 commit comments

Comments
 (0)