Hello, I want to ask if it is possible to declare the following sets and use the following equalities. I tried something but I was unsuccessful. I need it for my thesis. Could you help me? :-)

First of all, I would suggest to use a more concise and formal notation for your problem. Then it becomes easier to model your problem. For example, you could also write your problem as follows (for the sake of exposition I only included the first constraint):

In Mosel, you can model this problem as follows:

model sets
uses "mmxprs"
uses "mmsystem"
! Scalars
parameters
pmax = 1
dmax = 1
mmax = 2
rmax = 3
cmaxrandom = 3
end-parameters
! Sets and arrays
declarations
P = 1..pmax
D = 1..dmax
R = 1..rmax
M = 1..mmax
Mhat: set of integer
cmax: array(M) of integer
C: array(M) of set of integer
end-declarations
! Initialize Mhat (RANDOM EXAMPLE)
Mhat := M - {integer(random * mmax + 1)}
writeln('P = ', P)
writeln('D = ', D)
writeln('R = ', R)
writeln('M = ', M)
writeln('Mhat = ', Mhat)
! Initialize cmax and C (RANDOM EXAMPLE)
forall(m in M) do
cmax(m) := integer(random * cmaxrandom + 1)
C(m) := 1..cmax(m)
writeln('C(',m,') = ', C(m))
end-do
! Sets and arrays
declarations
Call = union(m in M) C(m)
Q: array(M, Call) of set of integer
y: array(D, M, Call, R, P) of mpvar
ctr1: array(D, M, Call, P) of linctr
end-declarations
! Initialize Q (RANDOM EXAMPLE)
forall(m in M, c in C(m)) do
Q(m,c) := 1..integer(random * rmax + 1)
writeln('Q(',m,',',c,') = ', Q(m,c))
end-do
! Create constraint 1
forall(d in D, m in Mhat, c in C(m), p in P) do
writeln('Creating constraint ctr1(',d,',',m,',',c,',',p,')')
ctr1(d,m,c,p) :=
sum(r in Q(m,c)) y(d,m,c,r,p) = 1
end-do
! Load problem to the optimizer
setparam("XPRS_LOADNAMES", true)
loadprob(0)
! Show the problem as an LP in the command line
writeprob("", "l")
end-model

First of all, I would suggest to use a more concise and formal notation for your problem. Then it becomes easier to model your problem. For example, you could also write your problem as follows (for the sake of exposition I only included the first constraint):

In Mosel, you can model this problem as follows: