Thank you Gifari for your answer. However, I have more than 500 binary variables. Having ai * aj for all i and j makes the problem more complex. I am still struglling to define the dependency between two components (ai's) and (ai * aj's).
In optimization models, variables are usually denoted by the latest letters of the Latin alphabet : x,y,z (also, t,u,v,w) and parameters when specified in the "symbolic" way, not as numbers by the initial letters: a, b, c, ,d.
Your problem is not linear since it contains products of variables like a1 * a3 (unless "linear multiplicative" stands for the case).
It is described there how to replace a product of 2 binary variables with an additional binary variable and 3 simple linear constraints. You still have binary variables, but no more products of them. Of course, in your case it means that with more than 500 variables, you are going to have more than 500*499/2=124750 more additional variables (one for each product ai*aj). The "cost" of getting rid of non-linearity in fomulas may be then too large.
One more question. How does the a1 + a2 + a3 = 2 constraint look like in case of more than 3 variables? Is it still equal 2 (a1 + a2 + a3+....+a499+a500 = 2) or is it "number of variables minus one" (a1 + a2 + a3+....+a499+a500 = 499)?
Thanks Przemysław Kowalik for correcting the variable representation. I really appreciate your help. I read the documentation and I figured out how can I represent the multiplication using the suggested method.
Bur for my case, Xi is a 1-D array while Yij is a 2-D array. Yij is selected only if Xi and Xj are chosen i.e. the choice of a1 and a2 and I don't know how can I choose Yij using a new variable say t1.
Also for my case, a1 + a2 + a3 = K where K is a constant.