108 views

Skip to first unread message

Jul 8, 2013, 2:14:10 AM7/8/13

to eureqa...@googlegroups.com

Dear all,

It would be a great help to me, if someone can let me know how to use Eureqa for constrained fitting of models.

for example: I have a data for X and Y

I want to fit a model, to my experimental data, which is of structure like:

y=a1*(1-exp(-b1*x)+a2*(1-exp(-b2*x)+a3*(1-exp(-b3*x), with the constrain that a1+a2+a3 = 1

I am stuck that how do I define this constrain in Eureqa while setting up my target expression.

Thanks and Best Regards

Jul 8, 2013, 2:30:17 PM7/8/13

to Eureqa Group

I was going to suggest something like:

y = (1-(f0(a1)) + (f1(a2)) + (f3(a3)) )

and just realized that EQ is crashing with this expression using dummy data, can someone please verify that this expression crashes EQ or is it just my machine ? -d

y = (1-(f0(a1)) + (f1(a2)) + (f3(a3)) )

and just realized that EQ is crashing with this expression using dummy data, can someone please verify that this expression crashes EQ or is it just my machine ? -d

--

You received this message because you are subscribed to the Google Groups "Eureqa Group" group.

To unsubscribe from this group and stop receiving emails from it, send an email to eureqa-group...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--

When things get too complicated, it sometimes makes sense to stop and wonder: Have I asked the right question?

-Enrico Bombieri

Jul 8, 2013, 5:24:24 PM7/8/13

to Eureqa Group

Oh yes, it's running.. now I know where the problem is, turn off constants and run a search.

hmm..Jul 8, 2013, 11:25:28 PM7/8/13

to eureqa...@googlegroups.com

Actually in the expression r=a1*(1-exp(-b1*t)+a2*(1-exp(-b2*t)+a3*(1-exp(-b3*t), a1, a2, a3, b1,b2 and b3 are constants which EQ needs to predict through model fitting. The constraint is with summation of a1, a2 and a3, a1+a2+a3=1.

I have data for r and t which I have attached here.

Please have a look at the file so that you can have clear insights.

Jul 9, 2013, 12:37:51 AM7/9/13

to Eureqa Group

Oh ic now.. I tried this really quick and it was working with your data after 30s

I got this "r = 0.476256254342857 + -0.474852776829926/exp(t)"

Expression is really quick and dirty, but I hope you get the point.

r = f3(t)*f0() + f1() + f2() + 1 - f0() + f1() + f2()

It was on my laptop so it was going really slow (too many fs), a similar issue was discussed some time ago here and Michael suggested:I got this "r = 0.476256254342857 + -0.474852776829926/exp(t)"

Expression is really quick and dirty, but I hope you get the point.

r = f3(t)*f0() + f1() + f2() + 1 - f0() + f1() + f2()

--

"

"

y = abs(f0())*x1 + abs(f1())*x2 + abs(100 - abs(f0()) - abs(f1()))*x3

That should force 3 coefficients that add to 100:

abs(f0())

abs(f1())

abs(100 - abs(f0()) - abs(f1()))

"

I would recommend instead of looking for a specific solution, perhaps you might want to let Eureqa find it and you can just type an expression like you already had in the file you sent.

hth, -d

Jul 9, 2013, 3:10:52 AM7/9/13

to eureqa...@googlegroups.com

Thanks a lot .. I understood your point but how to constrain f1, f3 and f5 values to be between 0 to 2, 0 to 1 and 0 to 0.5 respectively.

I used the following expression

r = 1 - abs(f0())*exp((-f1())*t) - abs(f2())*exp((-f3())*t) - abs(1 - f0() - f2())*exp((-f5())*t) + require(between(f1(), 0, 2)) + require(between(f3(), 0, 1)) + require(between(f5(), 0, 0.5))

but EQ doesnt seem to be working here. I have the solution for the same data set(within mentioned ranges) but EQ doesnt seem to generate the same result.

Jul 9, 2013, 2:09:49 PM7/9/13

to eureqa...@googlegroups.com

Hi Rachit,

The expression looks good. Just a couple tips...

To constrain a1+a2+a3 = 1, using abs() as you have will work well. You might consider one change though if you also want all of the values to be between 0 and 1. With abs(), you might end up with quite large values. e.g. 100, -105, and 6. If you use logistic() instead, it will naturally constrain the values to be between 0 and 1. With that modification, your coefficients would be:

logistic(f0())

logistic(f1())

logistic(1 - logistic(f0()) - logistic(f1()))

So, target expression: r = 1 - logistic(f0())*exp((-f1())*t) - logistic(f2())*exp((-f3())*t) - logistic(1 - logistic(f0()) - logistic(f2()))*exp((-f5())*t)

You can similarly use multiples of the logistic function to constrain the ranges of your other coefficients f1, f3, and f5:

2*logistic(f1())

logistic(f3())

0.5*logistic(f5())

Then use overall equation: r = 1 - logistic(f0())*exp(-2*logistic(f1())*t) - logistic(f2())*exp((-logistic(f3()))*t) - logistic(1 - logistic(f0()) - logistic(f2()))*exp(-0.5*logistic(f5())*t).

The "require" building block takes a lot of computational effort so in general it should be avoided if you can accomplish the same thing in another way.

Here's an example output expression that I got using the above equation with your sample data set: r = 1 - 6.942e-8*exp(-t) - 0.341*exp(-1.651*t) - 0.659*exp(-0.03624*t). When simplifying, the program has re-ordered the terms, but you can see that they all fall into the desired ranges.

Let me know if that works for you.

Alison

Jul 9, 2013, 4:14:34 PM7/9/13

to eureqa...@googlegroups.com

After thinking about this a bit more, introducing constraints using logistic still isn't quite right. The problem is that the first two are independent of one another. If the terms are:

logistic(f0())

logistic(f2())

logistic(1 - logistic(f0()) - logistic(f2()))

There is a chance that both the first and the second would independently give values very close to 1, thus violating the constraint.

I think the following adjustment should work though:

logistic(f0()) <-- this constrains the first coefficient to between 0 and 1

(1 - logistic(f0())) * logistic(f2()) <-- this ensures that the sum of the first two coefficients doesn't exceed 1

1 - (logistic(f0())) - ((1 - logistic(f0())) * logistic(f2())) <-- this ensures that the 3 coefficients sum to 1

Jul 10, 2013, 2:52:18 AM7/10/13

to eureqa...@googlegroups.com

Alison, thanks for your inputs. I do agree that with first case there was a problem that one of a's out of three might become negative to constraint their summation to 1.**r=0.4095*(1-exp(-1.2020*t)) + 0.0106*(1-exp(-0.7050*t)) + 0.5800*(1-exp(- 0.0171*t))**

With the second approach also I couldn't get the desired results.

Please have a look at the solution which I should get with this data but I am unable to obtain the same with EQ.

Jul 10, 2013, 8:35:40 PM7/10/13

to eureqa...@googlegroups.com

Hi Rachit,

I'm taking a look now. Can you give me any information on where you got the equation that you are expecting? I'm wondering whether changing the error metric that Eureqa is optimizing for might make a difference since many algorithms will optimize for R^2 while Eureqa uses absolute error by default. Can you try changing the error metric on the 'Set Target' page from absolute error to squared error and then resuming the search?

When I did that in my search I came up with this expression which actually seems quite close to the one you are targeting:

Using R^2 as the measure, this one actually seems to fit the data set just a bit better than the one you were expecting..

Let me know if that change makes a difference.

Best,

Alison

Jul 10, 2013, 11:14:45 PM7/10/13

to Eureqa Group

On that note, it would be really nice to have a coefficient op with optional ranges. As a simple example, if we take Rachit's requirements one could simply write:

...(1 - (cf0(0,2) + cf1(0,1) + cf3(0,0.5)) )...

or something similar where one requests exactly what one is looking with cf#(min,max).

-d

--

You received this message because you are subscribed to the Google Groups "Eureqa Group" group.

To unsubscribe from this group and stop receiving emails from it, send an email to eureqa-group...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

Jul 11, 2013, 12:20:54 AM7/11/13

to eureqa...@googlegroups.com

Hi Alison,

Actually the expression which I had mentioned, as a solution, in my earlier post was obtained using "Eureka-the solver". The criteria used there, for parameter estimation, was the minimization of the absolute sum of squares of the deviations at a given time(t) between experimental and calculated r values( Which is r^2 as far as I know, Please correct me If I am wrong).

I did the iteration again using r2 value and I got many solutions one of them was and this one is close the one obtained from Eureka-the solver (for b1, b2 and b3 values).

Solution: r = 1 - (logistic(-0.3473)*exp((-(1.227))*t) + (1 -
logistic(-0.3473)*logistic(6.792))*exp((-(0.01886))*t) + (1 -
logistic(-0.3473) - (1 -
logistic(-0.3473))*logistic(6.792))*exp((-(0.7113))*t)) after few more iterations at a stability of 99% I got this solution. |
||||||||||||||||

Solution: r
= 1 - (logistic(-0.3446)*exp((-(1.224))*t) + (1 -
logistic(-0.3446)*logistic(6.887))*exp((-(0.01872))*t) + (1 -
logistic(-0.3446) - (1 -
logistic(-0.3446))*logistic(6.887))*exp((-(1.226))*t)) but my concern here is, still the, constraints for example in this case: a1=logistic(-0.3446)= 0.415 a2=(1 - logistic(-0.3446)*logistic(6.887))=1-0.(415*0.999)=0.585 a3=(1 - logistic(-0.3446) - (1 - logistic(-0.3446))*logistic(6.887))=1-0.415-.585= 0 |

and If I consider 4 significant digits after decimal value of a3 becomes -0.0004

Actually these a1, a2 and a3 are nothing but fractions(or % for that matter) that should sum up to 1 and none of them can be zero or negative.

so is there other way-out for these constraints to be valid.

I was wondering, why expression like require((a1+a2+a3)= or ==1) doesn't work in EQ? or can this base and prior solution block be used for the same??

Many thanks and Best regards,

Rachit

Jul 11, 2013, 9:59:54 AM7/11/13

to eureqa...@googlegroups.com

Hm, I think the constraints are satisfied, though the 3rd parameter is very close to 0. I get:

a1=logistic(-0.3446) = 0.414693

a2=(1 - logistic(-0.3446)*logistic(6.887))=1-0.(415*0.999)= 0.584711

a3=(1 - logistic(-0.3446) - (1 - logistic(-0.3446))*logistic(6.887)) = 0.000597

a2=(1 - logistic(-0.3446)*logistic(6.887))=1-0.(415*0.999)= 0.584711

a3=(1 - logistic(-0.3446) - (1 - logistic(-0.3446))*logistic(6.887)) = 0.000597

I know that the require() building block is quite computationally expensive so I suspect the algorithm just isn't finding a good fit in a reasonable amount of compute time.

In any case, it seems like the area of constraints is one that could be improved in the future.

Jul 11, 2013, 1:35:48 PM7/11/13

to eureqa...@googlegroups.com

That's a good idea. We'll look into doing something like that in the future to make constraining coefficients simpler.

Reply all

Reply to author

Forward

0 new messages

Search

Clear search

Close search

Google apps

Main menu