# The Equation gives me wrong result

**URL:** <https://discuss.ampl.com/t/the-equation-gives-me-wrong-result/976>\
**Category:** Support\
**Created:** [February 28, 2024, 6:46pm UTC](https://discuss.ampl.com/t/the-equation-gives-me-wrong-result/976 "2024-02-28T18:46:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gustavo\_Martinez](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/gustavo_martinez/32/642_2.png) [@Gustavo\_Martinez](https://discuss.ampl.com/u/Gustavo_Martinez)\
**Post date:** [February 28, 2024, 6:46pm UTC](https://discuss.ampl.com/t/the-equation-gives-me-wrong-result/976/1 "2024-02-28T18:46:15Z")

</div>

Hi! My model has this equation

```auto
s.t. are{k in pol}:sqrt((X[k,4]-X[k,3])^2 + (Y[k,4]-Y[k,3])^2) * sqrt((X[k,3]-X[k,2]^2) + (Y[k,3]-Y[k,2])^2)==area[k];

```

In this equation, makes sure the shape of a rectangle is equal to a fixed area, X[k,j] and Y[k,j] are variables and area[k] is a fixed parameter. but I solve it with baron, the shape indicated has not the same value of the fixed area. for example with this solution,

```auto
X[1,1] = -3.35 X[1,2] = -1.42 X[1,3] = -1.42 X[1,4] = -3.35
Y[1,1] = -4.20 Y[1,2] = -4.20 Y[1,3] = -1.42 Y[1,4] = -1.42

```

With these points, in theory i have a rectangle with a area 4.  
but when I resolve only this equation in another software the result is total different (5.36). And with the commands

```auto
display area.lb;
display area.body;
display area.ub;

```

show me the value 4 and not 5.36. any idea why this happen?

[test.dat](https://discuss.ampl.com/uploads/short-url/a0Z8wGqtIlnDAP0PD3dvOOZzzu4.dat) (507 Bytes)  
[test.mod](https://discuss.ampl.com/uploads/short-url/wDE7ye0BnsRXt4r0i8Y2Gk3JvAo.mod) (2.1 KB)  
[test.run](https://discuss.ampl.com/uploads/short-url/pENOjrpNAnVZjO6d8dgzTRrwQSJ.run) (606 Bytes)

Thank you

---

<div class="post-metadata">

**Author:** ![4er](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/4er/32/530_2.png) [@4er](https://discuss.ampl.com/u/4er)\
**Post date:** [February 29, 2024, 2:57pm UTC](https://discuss.ampl.com/t/the-equation-gives-me-wrong-result/976/2 "2024-02-29T14:57:21Z")

</div>

Constraint `are` is an equality with the constant term `area[k]`, which is 4 for all `k`. So in any feasible solution, `are.lb`, `are.body`, and `are.ub` will be 4.

However, it looks like there is a ) in constraint `are` that is in the wrong place. It’s more obvious when some line breaks are added:

```auto
s.t. are{k in pol}:
   sqrt((X[k,4]-X[k,3])^2 + (Y[k,4]-Y[k,3])^2) * 
   sqrt((X[k,3]-X[k,2]^2) + (Y[k,3]-Y[k,2])^2) == area[k];

```

Also when I run BARON on your problem, it reports

```auto
BARON 23.3.11 (2023.03.11): 28185 iterations, CPU time limit reached.
Objective 3.457036724

```

By default, BARON has a time limit of 500 seconds. After that much time, it stops and returns the best solution found so far, which may not be the optimal solution. You can tell BARON to run longer; for example, to set a limit of 1500 seconds, before `solve` you can set some options like this:

```auto
option baron_options 'maxtime=1500 outlev=1';

```

(The setting `outlev=1` tells BARON to display a log of its progress, which is useful for long runs.)
