## 3 CPLEX CP Solver Solution
### MILP Model
#### 3.2.1. Using CPLEX Solver
Using CPLEX Solver  
dvar boolean x[i in tasks][k in satellites][m in orbits]; dvar boolean g[j in stations][k in satellites][n in orbits]; dvar int x_time[i in tasks][k in satellites]; dvar int g_time[i in stations][k in satellites][m in orbits]; dvar boolean y[i in tasks][j in stations][k in satellites][n in orbits]; dvar boolean za[i in tasks][j in stations][k in satellites][n in orbits]; dvar boolean zb[i in tasks][j in stations][k in satellites][n in orbits]; dvar boolean z1[i1 in tasks][i2 in tasks][k in satellites]; dvar boolean z1c[k in satellites][j1 in stations][n1 in orbits][j2 in stations][n2 in orbits]; dvar boolean z2[j in stations][k1 in satellites][m in orbits][k2 in satellites][n in orbits]; dvar int+ x_start[i in tasks][k in satellites]; dvar int+ x_end[i in tasks][k in satellites]; dvar int+ g_start[i in stations][k in satellites][m in orbits]; dvar int+ g_end[i in stations][k in satellites][m in orbits]; dvar float+ ux[tasks,satellites]; dvar float+ ug[ stations,satellites,orbits]; dvar float pg[k in satellites][j1 in stations][n1 in orbits][j2 in stations][n2 in orbits]; dvar float px[i1 in tasks][i2 in tasks][k in satellites]; dvar float pxga[i1 in tasks][j2 in stations][k in satellites][n2 in orbits]; dvar float pxgb[i1 in tasks][j2 in stations][k in satellites][n2 in orbits]; maximize sum(j in tasks, m in orbits,k in satellites)(profit[j] *x[j][k][m]); subject to { forall(i in tasks) sum(m in orbits,k in satellites) x[i][k][m]<=1; forall(i in tasks, k in satellites){ sum(n in orbits, j in stations) y[i][j][k][n]==sum(m in orbits) x[i][k][m];} forall(n in orbits, j in stations, k in satellites){ sum(i in tasks) y[i][j][k][n]<= g[j][k][n]*tasknum;} forall(i in tasks,k in satellites){ x_time[i][k]==sum(m in orbits)x[i][k][m]*duration[i];} forall(j in stations, n inorbits,k in satellites){ g_time[j][k][n]==sum(i in tasks)y[i][j][k][n]*utiline[i];} forall(i in tasks, k in satellites){ x_start[i][k]>=sum(m in orbits)x[i][k][m]*wst[i][k][m]; x_end[i][k]<=sum(m in orbits)x[i][k][m]*wst[i][k][m]; x_end[i][k]==x_start[i][k]+x_time[i][k];} forall(j in stations, n in orbits,k in satellites){ g_end[j][k][n]==g_start[j][k][n]+g_time[j][k][n]; g_start[j][k][n]>=g[j][k][n]*wsg[j][k][n]; g_end[j][k][n]<=g[j][k][n]*weg[j][k][n];} forall(i1 in tasks,i2 in tasks, k in satellites: i1!= i2){ z1[i1][i2][k]<=sum(m in orbits)x[i1][k][m]; z1[i1][i2][k]<=sum(m in orbits)x[i2][k][m]; sum(m in orbits)x[i1][k][m]+sum(m in orbits)x[i2][k][m] -z1[i1][i2][k]-z1[i2][i1][k]<=1;} forall(i in stations,m in orbits,k in satellites) forall(j in stations, n in orbits: <i,m>!= <j,n>){ z1c[k][i][m][j][n]<=g[i][k][m]; z1c[k][i][m][j][n]<=g[j][k][n];g[i][k][m]+g[j][k][n]-z1c[k][i][m][j][n]-z1c[k][j][n][i][m]<=1;} forall(i1 in tasks, k in satellites) forall(j in stations, n in orbits){ za[i1][j][k][n]<=sum(m in orbits)x[i1][k][m]; za[i1][j][k][n]<=g[j][k][n]; zb[i1][j][k][n]<=sum(m in orbits)x[i1][k][m]; zb[i1][j][k][n]<=g[j][k][n];} forall(i1 in tasks, k in satellites) forall(j in stations, n in orbits){ za[i1][j][k][n]>=y[i1][j][k][n];} forall(i in tasks, k in satellites) forall(j in tasks){ (x_end[i][k]-x_start[j][k]<=s && sum(m in orbits)x[i][k][m]==1)=>(z1[i][j][k]==1); (x_end[i][k]-x_start[j][k]>=0 && sum(m in orbits)x[i][k][m]==1)=>(z1[i][j][k]==0);} forall(i in tasks, k in satellites) forall(j in stations, n in orbits){ (x_end[i][k]-g_start[j][k][n]<=s && sum(m in orbits)x[i][k][m]==1)=>(za[i][j][k][n]==1); (x_end[i][k]-g_start[j][k][n]>=0 && sum(m in orbits)x[i][k][m]==1)=>(za[i][j][k][n]==0); (g_end[j][k][n]-x_start[i][k]<=s && g[j][k][n]==1)=>(zb[i][j][k][n]==1); (g_end[j][k][n]-x_start[i][k]>=0 && g[j][k][n]==1)=>(zb[i][j][k][n]==0);} forall(i in stations,m in orbits, k in satellites) forall(j in stations, n in orbits){ (g_end[i][k][m]-g_start[j][k][n]<=s && g[i][k][m]==1)=>(z1c[k][i][m][j][n]==1); (g_end[i][k][m]-g_start[j][k][n]>=0 && g[i][k][m]==1)=>(z1c[k][i][m][j][n]==0);} forall(i in stations, m in orbits,k in satellites) forall(j in stations, n in orbits){ (z1c[k][i][m][j][n]==1)=>(pg[k][i][m][j][n]==g_time[i][k][m]*umemory[k][1]); (z1c[k][i][m][j][n]==0)=>(pg[k][i][m][j][n]==0);} forall(i in tasks, k in satellites) forall(j in tasks){ (z1[i][j][k]==1)=>(px[x1][j][k]==x_time[i][k]*umemory[k][0]); (z1[i][j][k]==0)=>(px[x1][j][k]==0);} forall(i in tasks, k in satellites) forall(j in stations, n in orbits){ (za[i][j][k][n]==1)=>(pxga[i][j][k][n]==x_time[i][k]*umemory[k][0]); (za[i][j][k][n]==0)=>(pxga[i][j][k][n]==0); (zb[i][j][k][n]==1)=>(pxgb[i][j][k][n]==g_time[j][k][n]*umemory[k][1]); (zb[i][j][k][n]==0)=>(pxgb[i][j][k][n]==0);} forall(i in tasks,k in satellites){ (x1[k]==(sum(j in tasks) px[j][i][k])- (sum(j in stations, m in orbits) pxgb[i][j][k][m])+x_time[i][k]*umemory[k][0]; (ux[i][k]<=memory[k]; ux[i][k]>=0;} forall(i in stations, m in orbits,k in satellites){ ug[i][k][m]==(sum(j in tasks) pxga[j][i][k][m])- (sum(j in stations, m1 in orbits)pg[k][j][m1][i][m])-g_time[i][k][m]*umemory[k][1]; ug[i][k][m]<=memory[k]; ug[i][k][m]>=0;}  
forall(i in stations,m in orbits,k1 in satellites) forall(k2 in satellites, n in orbits:k1!=k2){ z2[i][k1][m][k2][n]<=g[i][k1][m]; z2[i][k1][m][k2][n]<=g[i][k2][n]; g[i][k1][m]+g[i][k2][n]-z2[i][k1][m][k2][n]-z2[i][k2][n][k1][m]<=1;} forall(i in stations,m in orbits,k1 in satellites) forall(k2 in satellites, n in orbits){ (g_end[i][k1][m]-g_start[i][k2][n]>=0 && g[i][k1][m]=1)=>(z2[i][k1][m][k2][n]==0); (g_end[i][k1][m]-g_start[i][k2][n]<=g && g[i][k1][m]==1)=>(z2[i][k1][m][k2][n]==1);} forall(i in stations,m in orbits,k1 in satellites) forall(k2 in satellites, n in orbits){ (z2[i][k1][m][k2][n]==1)=>(g_start[i][k2][n]-g_end[i][k1][m]>=slewt[i]);} forall(i in stations,m in orbits,k in satellites) forall(j in stations, n in orbits){ (z1c[k][i][m][j][n]==1)=>(g_start[j][k][n]-g_end[i][k][m]>=slewtime1[k]);} forall(i in tasks, k in satellites) forall(j in tasks){ (z1[i][j][k]==1)=>(x_start[j][k]-x_end[i][k]>=slewtime[i][j][k]);} forall(k in satellites){ sum(i in tasks)((x_time[i][k])*uenergy[k][0])+ sum(i in stations, m in orbits)((g_time[i][k][m])*uenergy[k][1])<=energy[k];} }