0

I have an array defined as follows

A = [
[10,20],
[20,10]
]

Now I want to get the entry at a position (i, j). The thing is, j is a CpoFunctionCall object (where i will be an Int), so is not able to be indexed. Is it possible to have the operation of getting the (i,j)-th elemement as a CpoExpression in docplex or is there some other clever way to solve this?

Stackd
  • 683
  • 1
  • 6
  • 12

1 Answers1

0

So the way I solved this is by conversting A[i] to an expression and converting the function call to an expression of boolean array and then taking the inner product.

POSITION = [0,1]
b = build_cpo_expr(A[i])
c = list(map(lambda x: x==j, POSITION))
distance = scal_prod(c, b)
Stackd
  • 683
  • 1
  • 6
  • 12