How to model linearly this complex piecewise objective function?

I want to model linearly the following situation : my objective function $f(q)$ should be like this :

$f(q)=A\cdot q+B\cdot x$ if $x=1, \gamma=0, \delta=0$

$f(q)=A' \cdot q+B'\cdot x$ if $x=1, \gamma=1, \delta=0$

$f(q)=A'' \cdot q+B''\cdot x$ if $x=1, \gamma=0, \delta=1$

$x,\delta, \gamma$ are binary variables and when $x=0$, $\delta=0,\gamma=0$ but the reverse is not true.

$A,A',A", B,B',B"$ are constants.

Thanks for help

• What is $f$ when $x=0$? – Matthew Conroy Dec 14 '17 at 22:30
• @Matthew Conroy when $x=0$, $q=0$ automatically (it is fixed by other contraints) and so $f$ should be nul – MysteryGuy Dec 15 '17 at 6:06
• Okay. And what happens if x=1, $\gamma=1$ and $\delta=1$? – Matthew Conroy Dec 15 '17 at 7:24
• @MatthewConroy It can't happen. There are some constraints that do not allow this configuration – MysteryGuy Dec 15 '17 at 8:34
• @MatthewConroy, so do you have any other idea ? I guess your answer was a good start, the only challenge is how to make it with Cplex, which I guess is not impossible – MysteryGuy Dec 18 '17 at 11:17