Message Boards Message Boards

Domain restrictions for Maximize

Posted 8 years ago

Dear all,

I'm new to Mathematica, so please be forbearing with me :D

I would like to use NMaximize together with domain restriction (where the domain is a custom domain).

I've got an example:

dom = {1, 2, 6, 10};
NMaximize[{UP[fl, a, p], UA[fl, a, p] >= resutil, 
  D[UAS[fl, a, p], X[a]] == D[DA[a], a], MemberQ[dom, a] == True}, {a,
   p}]

I would like to maximize UP(.), subject to the given constraints (including that the result for a is a member of dom).

The maximization works fine if I set the constraint to a [Element] Integers:

NMaximize[{UP[fl, a, p], UA[fl, a, p] >= resutil, 
  D[UAS[fl, a, p], X[a]] == D[DA[a], a], a \[Element] Integers}, {a, 
  p}]

So, let's assume that the solution where a is an element of Integers is a=4 and p=0.25. I would like to know the solution for a and p where a is a member of dom.

Is there a way to include such a constraint into Maximize?

Thank you very much :)

POSTED BY: Stephan Leitner
2 Replies

Perhaps an Or constraint would work.

For example:

dom = {1, 2, 6, 10};

In[7]:= NMaximize[{x, x <= 12, Or @@ Thread[x == dom]}, x]

Out[7]= {10., {x -> 10.}}
POSTED BY: Frank Kampas

Thank you very much for your help, that's exactly what I am looking for :)

POSTED BY: Stephan Leitner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract