Hello,

I want to create a constraint: a variable *var1* is equal to the output of a torch artificial neural network whose input is another variable *var2*.

------- This following function is my ann prediction (the ANN has been imported) -----

```
function get_y_pred(ann, x, x_scl, y_scl)
# x_scl and y_scl are scaler to modify the input x and output y.
x_std = x_scl.transform(x)
x_std = V.Variable(torch.from_numpy(x_std).float())
y_std = ann(x_std).data.numpy()
y_pred = y_scl.inverse_transform(y_std)
return y_pred
end
```

The input x should be a matrix containing *var2* and some constants, e.g.,

```
x = [1.0, 0.6, var2, 0.8] # Vector
x = reshape(x, 1, length(x)) # Vector to Matrix
```

now I try to add a constraint for *var1*, i.e., during the optimization *var1* should be adaptively changed by the ANN.

```
@addNLconstraint(model, var1 == get_y_pred(ann, x, x_scl, y_scl))
```

but it does not work, because I can not create a constraint by using a self-defined function or expression (**get_y_pred**) with ANN.

Can anyone help me with finding a way to solve this problem? Thank you very much!