# DOCPLEX: tips to manipulate data input (binary parameter)

I am coding a MIP problem in docplex and I would like to ask for some tips.

I would like to input a binary parameter that states a compatibility relation:

I have a set of characteristics $$H$$ to be satisfied in a product. The product is made by a set of components $$C$$ and each component can have many variants $$V$$. For stating the compatibility between variant of component and required characteristics, I stated the following binary parameter:

• $$G_h{_{c}}_{v}=1$$ if the characteristic $$c$$ can be accomplished by variant $$v$$ of component $$c$$, and zero otherwise

I was wandering to use a 3D numpy array to state this relation. But I if I'm not wrong, I did not find examples using 3D numpy array. Instead, I saw namedTuple, that I guess was used to state similar relation for string elements.

How can I code binary parameters in docplex keeping the index of each element, by accessing the value of each parameter and also its key ?

If someone could help me, I will be very grateful.

One thing I would personally do is stick to dictionaries as accessing each key is easier and faster (Its complexity is $$O(1)$$). If you have three collections for your keys, namely your $$H$$, $$C$$, and $$V$$, then, as you probably know, you can use binary_var_cube where you can see, from the documentation linked:
Using dictionaries will help you tremendously especially in cases where you have a sparse matrix. e.g. only a handful of variants $$V$$ are present in each component $$C$$. That way, rather than having a 3D numpy array or list of list of list, you can have only those indices for your variables that exist. Of course, you can achieve that with tuple or namedTuple, but as I mentioned, accessing dictionaries is faster (you can read more about some of Python data types here)