Pinned topicproblem with piecewise using condition on the tuple

I noticed a wired behavior that I can't explain with piecewise when I apply a condition on the tuple.

In the code below I gave 2 ways of computing vS:

I have a tuple CostProfile with all my data. I filter the set passed to piecewise directly in piecewise. The result is the same for all the scenarios.... and it is equal to the result of scenario 1

I store in an array the prefilter tuple to feed them to pieceswise with costProfileTest. This solution works just fine.

// code 1: this does not work as it goive the same value for all scenario
float vSbad[c in Contracts][t in period][s in scenario] = omega * piecewise(bp in CostProfiles
: bp.contractId==c.contractId && bp.periodIndex == t && bp.scenario==s)
{bp.price -> bp.power; lastPrice[c][t][s]} vB[c][t];

// code 2: this works and give different value for all scenario
{costProfile} costProfileTest[c in Contracts][t in period][s in scenario]= {bp| bp in CostProfiles: bp.contractId==c.contractId && bp.periodIndex == t && bp.scenario==s};