1
$\begingroup$

Consider this example with set A={100,50,150}. Min value in this set is 50. How to find out that the index of 50 is 2 in this set? I need 2 as the answer to put it in another constraint

$\endgroup$
2
  • 1
    $\begingroup$ Are the entries in $A$ variables in your model? $\endgroup$
    – prubin
    Mar 16 at 20:13
  • $\begingroup$ Yes , A variables are answer of another constraint ! I want find index of min between them to put index number as input in next constraint .@prubin $\endgroup$ Mar 17 at 5:18

1 Answer 1

1
$\begingroup$

I think it likely would be an algorithmic way rather than being an optimization model. B.T.W, you can do what you want by the following MIP model:

\begin{array}{l} \text{Min} \ z = \sum_{i} A.val_i*x_i\\ \text{subject to:} \\ \sum_i x_i = 1\\ y_i = i .x_i \quad i=1, \ldots, m\\ x_{i} \in\{0,1\}, y_{i} \in \mathbb{Z}^+ \quad i\in m\\ \end{array}

As a simple example, with your data, the results are:

----     15 VARIABLE min_.L                =       50.000  

----     15 VARIABLE x.L  

50 1.000


----     15 VARIABLE y.L  

50 2.000
$\endgroup$
3
  • $\begingroup$ Or may be like $\max \sum_i a_ix_i$ s.t. $\sum_i a_ix_i \le a_i \quad \forall i= 1...n$ and ofcourse $y_i = \sum_i ix_i$ $\endgroup$ Mar 17 at 1:32
  • $\begingroup$ I think its need sum(i in n) x[i]=1; isnt it ? $\endgroup$ Mar 17 at 9:10
  • $\begingroup$ Since the A values are variables, the objective here is (nonconvex) quadratic. Fortunately, it can be linearized by the usual tricks, assuming that finite a priori bounds for the A variables exist. $\endgroup$
    – prubin
    Mar 17 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.