The idea is to find an energy function $E$ that is minimal when all clauses are satisfied, and then to simply enforce that $$\frac{dx}{dt} = -\frac{\partial E}{\partial x}$$

The idea is to find an energy function $E$ that is minimal when all clauses are satisfied, and then to simply enforce that $$\frac{dx}{dt} = -\frac{\partial E}{\partial x}$$

For a SAT problem involving variables $x_i\in [0, 1], 1\leq i\leq N$ and clauses $C_j, 1\leq j\leq M$ (with $C_{ji} = 1$ if $x_i$ appears positively in $C_j$, $C_{ji} = -1$ if $x_i$ appears negatively, and $0$ otherwise), we will define our energy function as a sum of squares of sub-energies for each clause.

For a SAT problem involving variables $x_i\in [0, 1], 1\leq i\leq N$ and clauses $C_j, 1\leq j\leq M$ (with $C_{ji} = 1$ if $x_i$ appears positively in $C_j$, $C_{ji} = -1$ if $x_i$ appears negatively, and $0$ otherwise), we will define our energy function as a sum of squares of sub-energies for each clause.

$$E = \sum_{1\leq j\leq M}K_m^2$$

$$E = \sum_{1\leq j\leq M}K_j^2$$

%% Cell type:markdown id: tags:

%% Cell type:markdown id: tags:

## Question 5) Write $K_m$

## Question 5) Write $K_j$

Define (formally) $K_m$ as a function of the $C_ji$ and of the $x_i$, such that $K_m = 0$ iff clause $m$ is satisfied, and $K_m = 2^N$ if all $N$ variables appear in clause $m$ and are currently at the wrong value.

Define (formally) $K_j$ as a function of the $C_{ji}$ and of the $x_i$, such that $K_j = 0$ iff clause $j$ is satisfied, and $K_j = 2^N$ if all $N$ variables appear in clause $j$ and are currently at the _wrong_ value.

One might want to define $s_i\in[-1, 1]$ as a function of $x_i\in[0, 1]$ for ease of writing.

One might want to define $s_i\in[-1, 1]$ as a function of $x_i\in[0, 1]$ and then $K_j$ as a function of the $s_i$ for ease of writing.

%% Cell type:code id: tags:

%% Cell type:code id: tags:

```

```

...

@@ -299,11 +299,11 @@

...

@@ -299,11 +299,11 @@

%% Cell type:markdown id: tags:

%% Cell type:markdown id: tags:

## Question 8) Improving the search

## Question 8) Improving the search

To avoid getting stuck in some local minima, we can add *Lagrange multipliers* $a_j, 1\leq j\leq M$.

To avoid getting stuck in some local minima, we can add *Lagrange multipliers* $a_j, 1\leq j\leq M$ so that the energy becomes $$E = \sum_{1\leq j\leq M}a_j K_j^2$$

These are new variables that will have an exponential increase proportional to $K_j$.

These are new variables that will have an exponential increase proportional to $K_j$.

Add the 3 new variables and their ODEs with `add_ode`.

Add the 3 new variables and their ODEs with `add_ode`.