# Constraints in SymbolicRegression.jl

**URL:** <https://discourse.julialang.org/t/constraints-in-symbolicregression-jl/121063>\
**Category:** General Usage\
**Tags:** symbolic-regression\
**Created:** [October 8, 2024, 1:26pm UTC](https://discourse.julialang.org/t/constraints-in-symbolicregression-jl/121063 "2024-10-08T13:26:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![PrimulaBunce](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/primulabunce/32/46933_2.png) [@PrimulaBunce](https://discourse.julialang.org/u/PrimulaBunce)\
**Post date:** [October 8, 2024, 1:26pm UTC](https://discourse.julialang.org/t/constraints-in-symbolicregression-jl/121063/1 "2024-10-08T13:26:50Z")

</div>

Hi,  
  
I was experimenting with the `constraints` parameter in SymbolicRegression.jl.   
  
So, my original equation is

y = \mathrm{sin}(2x\_4) + x\_1^2 \,.

I believe the size/complexity of `sin` here is 3.   
  
Since \mathrm{sin}(2x)=2\mathrm{sin}(x)\mathrm{cos}(x), I can also write the equation as

y = 2\mathrm{sin}(x\_4)\mathrm{cos}(x\_4) + x\_1^2 \,.

In this form, the size/complexity of both the `sin` and `cos` operators is 1. I tried to constrain my model so that it finds this expression:

```julia
model = SRRegressor(
    binary_operators=[+,-,*],
    unary_operators=[cos, sin],
    constraints=[cos=>1, sin=>1],
    save_to_file=false,
    # 
    turbo=true,
    bumper=true,
)

```

I got the following results:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/4/4/448057f926378670202e09bcbd25e8614337dde8.png)  
  
  
I was wondering why this list includes the original expression with the term `sin(x_4+x_4)` when I constrained the size of `sin` to be `1`?   
  
Thanks!
