Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prolog - aggregate : extract other variable than the minimum

I would like to know if there is a way to extract the X Value when I'm doing this :

aggregate_all(min(V), simulate(P, Color, V, X), Value)

The simulate predicate is used with P and Color as inputs and V and X as outputs.

For now, this works well to get the min value of V, but what I actually want is to get the value of X when V is at its minimum.

Is there a way to do that ? Any idea about how should I proceed ?

like image 244
Aleks Avatar asked Jun 16 '26 07:06

Aleks


1 Answers

aggregate library supports a 'Witness' on min/max scalar aggregates: then this should work

aggregate_all(min(V,X), simulate(P, Color, V, X), min(Value,X))
like image 132
CapelliC Avatar answered Jun 19 '26 07:06

CapelliC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!