[gecode-users] Values from Float vars
Vincent Barichard
Vincent.Barichard at univ-angers.fr
Fri Aug 2 17:31:44 CEST 2013
Hi,
You can get the min, max or mean with the min(), max() or med() member
functions of a FloatVar.
You can set another float variable with the rel() function :
rel(home, x, FRT_EQ, FloatVal(y.min()));
I hope it will be usefull to you.
Best,
Vincent
2013/8/2 Federico Campeotto <campe8 at nmsu.edu>
> I'm currently working on a CP-model for a project that involves geometric
> operations on vectors, points in R^3, etc..
> I would like to know if there is a way to obtain the min/max value of a
> float variable that is constrained in a float expression or relation as in
> the following example.
>
> /// Note: FloatVarArray& T
> /// First we constrain the float vars of the array T to be equal to some
> rescaled integer values...
> FloatVar float_x ( home, -255.0, +255.0 );
> FloatVar float_y ( home, -255.0, +255.0 );
> channel ( home, int_x, float_x );
> channel ( home, int_y, float_y );
> ...
> FloatVar div_var ( home, 100, 100 );
> div ( home, float_x, div_var, T[ 0 ] );
> div ( home, float_y, div_var, T[ 1 ] );
> ...
>
> /// Then we perform some operations (e.g., subtracting two vectors of
> points in R^3)...
> FloatVarArray p1 ( home, 3, -255.0, +255.0 );
> FloatVarArray p2 ( home, 3, -255.0, +255.0 );
> FloatVarArgs p3 ( home, 3, -255.0, +255.0 );
>
> for ( int i = 0; i < 3; i++) {
> rel ( home, p1[ i ] == T[ i ] );
> rel ( home, p2[ i ] == T[ i ] );
> }
>
> rel ( home, v[0] == p2[0] - p1[0] );
> rel ( home, v[1] == p2[1] - p1[1] );
> rel ( home, v[2] == p2[2] - p1[2] );
> …
>
> /// Note: FloatVarArgs x, FloatVarArgs temp( prot, 3, MIN, MAX )
> /// FloatVar sum ( home, MIN, MAX ), FloatVar sqr_rt ( prot,
> MIN, MAX ),
> sqr ( home, x[ 0 ], temp[ 0 ] );
> sqr ( home, x[ 1 ], temp[ 1 ] );
> sqr ( home, x[ 2 ], temp[ 2 ] );
> rel ( home, sum == temp[ 0 ] + temp[ 1 ] + temp[ 2 ] );
> sqrt ( home, sum, sqr_rt );
>
> If we finally print the values for the variables in the vectors v and x we
> obtain restricted ranges.
> Eventually we would like to calculate some real values obtained from such
> vectors (e.g., the value of
> a certain physics formula given by the current labeling).
> Is there a way to obtain the current min,max or the mean value of such
> restricted domains?
> It is also possible to set such current min, max, mean value to another
> real variable?
>
> Thanks,
> Federico Campeotto
>
>
>
> _______________________________________________
> Gecode users mailing list
> users at gecode.org
> https://www.gecode.org/mailman/listinfo/gecode-users
>
>
--
Vincent Barichard Université d'Angers (LERIA)
Tel: 02 41 73 52 06 Département Informatique
Fax: 02 41 73 50 73 H203
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gecode.org/pipermail/users/attachments/20130802/7de6c47d/attachment.html>
More information about the users
mailing list