No problem at all.
Could it be that there is something wrong with your data and that causes the extraction error? I have modified the example provided here to match your case and everything seems to work fine:
range Months = 1..2;
range Products = 1..2;
range Terminals = 1..2;
range Partners = 1..2;
int n=2;
float breakpoint[Months][Products][Terminals][Partners][1..n]=[[[[[100,200],[100,200]],[[100,200],[100,200]]],
[[[100,200],[100,200]],[[100,200],[100,200]]]],
[[[[100,200],[100,200]],[[100,200],[100,200]]],
[[[100,200],[100,200]],[[100,200],[100,200]]]]];
float slope[Months][Products][Terminals][Partners][1..n+1]=[[[[[1,2,-3],[1,2,-3]],[[1,2,-3],[1,2,-3]]],
[[[1,2,-3],[1,2,-3]],[[1,2,-3],[1,2,-3]]]],
[[[[1,2,-3],[1,2,-3]],[[1,2,-3],[1,2,-3]]],
[[[1,2,-3],[1,2,-3]],[[1,2,-3],[1,2,-3]]]]];
dvar float x[Months][Products][Terminals][Partners];
dvar float y[Months][Products][Terminals][Partners];
maximize sum(m in Months,p in Products,t in Terminals,cp in Partners) y[m][p][t][cp];
subject to
{
forall(m in Months,p in Products,t in Terminals,cp in Partners) {
y[m][p][t][cp] == piecewise(i in 1..n)
{slope[m][p][t][cp][i] -> breakpoint[m][p][t][cp][i]; slope[m][p][t][cp][n+1]}(0,0) x[m][p][t][cp];
}
}
Maybe you can start from this code snippet, transform it to yours step by step and see where things go wrong? Or check whether you can spot a significant difference to your code?
#DecisionOptimization#MathematicalProgramming-General