Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c2e7d65

Browse files
authored
Update README.md
1 parent e4b8d55 commit c2e7d65

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

‎README.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,45 @@ We can see that the algorithm quickly converges to the optimal point (see Fig. 5
135135
For more examples refer to the python scripts in "examples" folder. [https://github.com/tsyet12/Duelist-Algorithm-Python/tree/master/examples]
136136

137137

138-
# Small Tutorial on Complex Constraint using Karush-Kuhn-Tucker (KKT) conditions
138+
# Dealing with Complex Constraint using Karush-Kuhn-Tucker (KKT) conditions
139139

140140
There will be some problems that have complex constraints. For example, constraints which depends on two or more manipulated variables.
141141

142-
Say: we take the same problem from the **Short Tutorial**, and now we have an extra constraint, which is x1 must be larger than x2:
142+
*Example 1: Inequality*
143+
144+
Say:
145+
We take the same problem from the **Short Tutorial**, and now we have an extra constraint, which is x1 must be larger than x2:
146+
143147
> x1>x2
144148
145149
Using KKT conditions, we can put this constraint in the objective function:
146150

147-
f=(x1,x2) = (x1)^2+(x2)^2 + (
151+
f=(x1,x2) = (x1)^2+(x2)^2 + max(0,x2-x1)
152+
153+
Implementation:
154+
155+
```python
156+
def f(x1,x2):
157+
return x1*x1+x2*x2+max(0,x2-x1)
158+
```
159+
Continue from Step 2 of **Short Tutorial**.
160+
161+
162+
163+
*Example 2: Equality*
164+
Say:
165+
We take the same problem from the **Short Tutorial**, and now the extra constraint is x1 equal to x2:
166+
167+
f=(x1,x2) = (x1)^2+(x2)^2 + (x2-x1)^2
168+
169+
Implementation:
170+
171+
```python
172+
def f(x1,x2):
173+
return x1*x1+x2*x2+(x2-x1)*(x2-x1)
174+
```
175+
176+
Continue from Step 2 of **Short Tutorial**.
148177

149178

150179
# Version

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /