Concatenate variables into a new one

  • 9 September 2022
  • 4 replies

Hi everyone, I am relatively new to AIMMS. 

I have a question with the following: 
I want to concatenate the values from variables: var1 and var2 into var_new. 
For example: 




How do I do that? 

Thank you in advance! 

4 replies

Userlevel 5
Badge +6

Hey, how are you? 

I don’t fully understand yout use case, but, I read that you want to unite two sets. To do that, you can do via procedure or by definition.


Hi, I am doing well. How are you? 
Thank you so much for your reply! I appreciate it.

Hmm, I’ve tried that, but since var1 is not a single value, but it’s an array, then the expression var1(n1) +var2(n2) doesn’t seem to work because of the indices. 

I just want to extend the first array, adding the second one to it. So not quite sure how to perform that with the indices. 


Userlevel 5
Badge +6

Hi @asimonovska , 

If it is an array, var1 and var2 should have some sort of an index. So are you trying to unite the variable values or the sets? Either way, see if it helps:

for int_numb | var1(int_numb) do
    SetElementAdd(s_new, ep_new, var1(int_numb));

for int_numb | var2(int_numb) do
    SetElementAdd(s_new, ep_new, var2(int_numb));

Thank you Gabriela for helping me out. 

Essentially what I want to do is the following: 

I have OutputL1_1(n1) or that is my var1(int_numb). This variable is an array of n1 elements. 

Then I have OutputL1_2(n2) or that is my var2(int_numb_2). This variable is an array of n2 elements.

What I want to do next is to unite them both so I get: Concat_Output(n3) where n3=n1+n2, and it contains the values of OutputL1_1(n1) and OutputL1_2(n2). 

Then I will use this Concat_Output(n3) further as an input in order to get my final output. 
And I will perform my optimization on top of it. 

Now, I don’t know what s_new and ep_new stand for in your equation. 

Thank you so much for helping me out!


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator