Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #2513 > unrolled thread

Maximize a single variable and solve for the rest

Started byRamiro <ramiro.barrantes@gmail.com>
First post2011-05-20 10:38 +0000
Last post2011-05-21 10:49 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Maximize a single variable and solve for the rest Ramiro <ramiro.barrantes@gmail.com> - 2011-05-20 10:38 +0000
    Re: Maximize a single variable and solve for the rest Peter Pein <petsie@dordos.net> - 2011-05-21 10:49 +0000

#2513 — Maximize a single variable and solve for the rest

FromRamiro <ramiro.barrantes@gmail.com>
Date2011-05-20 10:38 +0000
SubjectMaximize a single variable and solve for the rest
Message-ID<ir5gat$t3f$1@smc.vnet.net>
Hello,

I have a problem where I would like to solve an equation (namely (h+s+b
+d==1) with some constraints, while maximizing for a related variable
"c" (c<=9).  Please see below,  any suggestions?

r1 = 3/4;
r2 = 1;
Block[{h, s, b, d, c},
 NMaximize[{h + s + b + d,
   b == c*r1 && h + s + b + d == 1 && d == c*r2 && h == s &&
    b + d <= 0.9}, {h, s, b, d, c}]]

 {1., {h -> 0.5, s -> 0.5, (3 c)/4 -> 0., c -> 0., c -> 0.}}

Should I be using NSolve?

Thanks in advance,
Ramiro

[toc] | [next] | [standalone]


#2572

FromPeter Pein <petsie@dordos.net>
Date2011-05-21 10:49 +0000
Message-ID<ir85bp$bhm$1@smc.vnet.net>
In reply to#2513
Am 20.05.2011 12:38, schrieb Ramiro:
> Hello,
> 
> I have a problem where I would like to solve an equation (namely (h+s+b
> +d==1) with some constraints, while maximizing for a related variable
> "c" (c<=9).  Please see below,  any suggestions?
> 
> r1 = 3/4;
> r2 = 1;
> Block[{h, s, b, d, c},
>  NMaximize[{h + s + b + d,
>    b == c*r1 && h + s + b + d == 1 && d == c*r2 && h == s &&
>     b + d <= 0.9}, {h, s, b, d, c}]]
> 
>  {1., {h -> 0.5, s -> 0.5, (3 c)/4 -> 0., c -> 0., c -> 0.}}
> 
> Should I be using NSolve?
> 
> Thanks in advance,
> Ramiro
> 
Maybe - or surely! - I misunderstand your question. You've got the
solution in your posting

 The only thing to keep in mind is that s >= 1/20:

In[15]:=
Block[{h,s,b,d,c},Reduce[{b==c*r1&&h+s+b+d==1&&d==c*r2&&h==s&&b+d<=9/10},{h},Backsubstitution->True]]
Out[15]= Re[s]>=1/20&&Im[s]==0&&d==-(4/7) (-1+2 s)&&c==-(4/7) (-1+2
s)&&b==-(3/7) (-1+2 s)&&h==s
In[16]:= ToRules[Drop[%,2]]
Out[16]= {d->-(4/7) (-1+2 s),c->-(4/7) (-1+2 s),b->-(3/7) (-1+2 s),h->s}
In[17]:= h+s+b+d/.%
Out[17]= 1

Peter

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web