[gecode-users] Trigonometric functions in Gecode

Guido Tack tack at gecode.org
Thu Mar 17 12:43:30 CET 2011


Jonathan Skovhus Andersen wrote:

> Hello,
> 
> I'm a beginner in Gecode, so there is something that I don't quite understand. First of all I understand that Gecode only uses integers. But in my implementation I have to use arcus tangent which gives me some problems. I have to following line in my code:
> 
> for(int i = 0; i < p.size(); i++)
> 			rel(*this, angle[i] == 180/3.1415*atan((sqrt(sqr(coordinatesArray[i][0]-x)+sqr(coordinatesArray[i][1]-y))/constantsArray[2][0])));
> 
> Which gives me the following error:
> 
> Error	12	error C2665: 'atan' : none of the 3 overloads could convert all the argument types	...source.cpp	107	TSP
> 
> Is there any way to work around this? I don't really have any ideas...

It's simply a type problem: sqrt returns a Gecode::LinExpr, but there's no atan function that would accept a LinExpr as an argument. The only way to work around this would be to add propagators for trigonometric functions to Gecode, which only really makes sense if you have floating point variables.

Cheers,
	Guido

-- 
Guido Tack, http://people.cs.kuleuven.be/~guido.tack/




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gecode.org/pipermail/users/attachments/20110317/405a8766/attachment.htm>


More information about the users mailing list