Hi guys,(adsbygoogle = window.adsbygoogle || []).push({});

I am struggling again NMinimize.

This is my problem:

I am creating a model by using goal programming, my problem now is given a list of list i.e a matrix defined in this way

S = {{5, 2, 7, 9}, {1, 2, 3, 4}, {3, 1, 2, 4}}

extract from the first list {5,2,7,9} a number by passing a variable in extract method.

I mean, this is my model:

NMinimize [{

n1+p1, (this is my objective function)

x1j == 2 (Now i am using a stupid number but this will be modified)

Ʃ Extract[Extract[S,1],x1j]+n1-p1 == 10, (The summation start from j=1 to 2)

n1>= 0,

p1>=0

},{x1j,n1,p1}]

In this case, on my side the result should be x11 = 5, x12 = 5, n1=0, p1=0, but unfortunately this not happen.

This error is launched:

Extract::psl: Position specification Subscript[x, 1,1] in Extract[{5,2,7,9},Subscript[x, 1,1]] is not an integer or a list of integers. >>

NMinimize::bcons: The constraints are not valid. >>

Someone can help me?

Thanks a lot!

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Mathematica, NMinimize extract data from list

**Physics Forums | Science Articles, Homework Help, Discussion**