$gdxin Sets.gdx SET i number of continuous variables j number of binary variables k number of inequality constraints r number of parametric cuts nCR number of critical regions ; $load i j k r nCR $gdxin ALIAS (i1,i), (j1,j), (k1,k); $ONTEXT This part simply loads the sets from MATLAB. Note the following: a) For consistency, all constraint matrices have the same size. However, what we do is that we have the indices 'Size_m' and 'Size_Cut', which denote the size of the affine constraints and of the parametric cuts. These will be used in the loop to not increase the problem size b) If we only have one binary variable, we have a different situation, because the matrices are handled differently in MATLAB $OFFTEXT $gdxin Parameters.gdx PARAMETER Q(i,i1) quadratic terms of continuous variables Qbin(j,j1) quadratic terms of binary variables Qxy(i,j) quadratic terms of binary-continuous bilinear terms ccon(i) linear terms of continuous variables dcon(j) linear terms of binary variables AAll(k,i,nCR) inequality constraint matrix of continuous variables EAll(k,j,nCR) inequality constraint matrix of binary variables bAll(k,nCR) coefficents of inequality constraints; $load Q Qbin Qxy ccon dcon AAll EAll bAll $gdxin $ONTEXT We now consider the case whether we have a) parametric cuts or not and b) whether we have more than one binary variables $OFFTEXT $gdxin Parameters.gdx PARAMETER PxAll(r,i,i1,nCR) quadratic part of the continuous variables of parametric cut PxyAll(r,i,j,nCR) quadratic part of the continuous_binary variables of parametric cut PyAll(r,j,j1,nCR) quadratic part of the binary variables of parametric cut txAll(r,i,nCR) linear part of continuous variables of parametric cut tyAll(r,j,nCR) linear part of binary variables of parametric cut fAll(r,nCR) constant part of parametric cut SizeAll(nCR) number of parametric cuts ; $load PxAll PxyAll PyAll txAll tyAll fAll SizeAll $gdxin $ONTEXT Now we define the dummy variables for the equations $OFFTEXT PARAMETER A(k,i) E(k,j) b(k) Px(r,i,i1) Pxy(r,i,j) Py(r,j,j1) tx(r,i) ty(r,j) f(r) Solution(nCR,j) ; SCALAR Size ; VARIABLE OBJ ; VARIABLES x(i) ; BINARY VARIABLES y(j) ; EQUATION cost, inequality(k), paracut(r) ; cost.. OBJ =e= sum((i,i1), x(i) * Q(i,i1) * x(i1)) + sum((j,j1), y(j) * Qbin(j,j1) * y(j1)) + sum((i,j), x(i) * Qxy(i,j) * y(j)) + sum(i, ccon(i) * x(i)) + sum(j, dcon(j) * y(j)) ; inequality(k).. sum(i, A(k,i) * x(i)) + sum(j, E(k,j) * y(j)) =l= b(k) ; paracut(r)$(Size gt 0).. sum((i,i1), x(i) * Px(r,i,i1) * x(i1)) + sum((i,j), x(i) * Pxy(r,i,j) * y(j)) + sum((j,j1), y(j) * Py(r,j,j1) * y(j1)) + sum(i, tx(r,i) * x(i)) + sum(j, ty(r,j) * y(j)) + f(r) =l= 0 ; model MIQP /ALL/; $ONTEXT The loop comes in when looking at the solve statement. The key idea is the following: we define temporary data via the loaded data. Then, we loop through the solve statement $OFFTEXT loop(nCR, A(k,i) = AAll(k,i,nCR); E(k,j) = EAll(k,j,nCR); b(k) = bAll(k,nCR); Px(r,i,i1) = PxAll(r,i,i1,nCR); Pxy(r,i,j) = PxyAll(r,i,j,nCR); Py(r,j,j1) = PyAll(r,j,j1,nCR); tx(r,i) = txAll(r,i,nCR); ty(r,j) = tyAll(r,j,nCR); f(r) = fAll(r,nCR); Size = SizeAll(nCR); option limrow=0, limcol=0, solprint=silent, solvelink=5; Solve MIQP Using MINLP Minimizing OBJ; If ((MIQP.modelstat eq 1) or (MIQP.modelstat eq 2) or (MIQP.modelstat eq 8), Solution(nCR,j) = y.L(j); else Solution(nCR,j) = inf; ); ); execute_unload "gams_data.gdx" Solution ;