Message Boards Message Boards

0
|
3362 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Demonstration: finding feasible points for constraint sets

Posted 11 years ago
There are times where one might want to find multiple feasible points from a set of constraints.  One way to do this is to use the Global Optimization package (www.wolfram.com/products/applications globalopt).  Setting a dummy objective function,  solutions to the constraint set y <= 1 && x^2 + y^2 <= 2 can be found as follows :

 In[307]:= res =
 GlobalSearch[
 2, {y - 1, x^2 + y^2 - 2}, , {{x, -2, 2}, {y, -2, 2}}, .0001,Starts -> 20]
 Out[307]= {{{x -> -1.41416, y -> 0.0125637},
 2}, {{x -> -1.41136, y -> 0.0898447},
 2}, {{x -> -1.41312, y -> 0.0555454},
 2}, {{x -> -1.4059, y -> -0.153154},
 2}, {{x -> -1.34483, y -> -0.437534},
 2}, {{x -> -1.38462, y -> 0.287784},
2}, {{x -> -1.41226, y -> -0.0742761},
2}, {{x -> -1.41228, y -> 0.0739751},
2}, {{x -> -1.41421, y -> -0.00238709},
2}, {{x -> -1.40694, y -> 0.14328},
2}, {{x -> -1.4142, y -> 0.00573651},
2}, {{x -> -1.41417, y -> 0.0105029},
2}, {{x -> -1.41175, y -> 0.0834923},
2}, {{x -> -1.4141, y -> -0.0176356},
2}, {{x -> -1.41421, y -> -0.00262904},
2}, {{x -> -1.41272, y -> -0.0649679},
2}, {{x -> -1.41173, y -> 0.0837614},
2}, {{x -> -1.4123, y -> 0.0734826},
2}, {{x -> -1.41421, y -> -0.00320179},
2}, {{x -> -1.40906, y -> 0.120677}, 2}}

A second function in this package operates slightly differently and finds different solutions:
 In[308]:= res =
  GlobalPenaltyFn[
   2, {-y + 1, x^2 + y^2 - 2}, , {{x, -3, 3}, {y, -3, 3}}, .0001,
   Starts -> 20]
 Out[308]= {{{x -> 0.998563, y -> 1.00096},
   2}, {{x -> -0.925719, y -> 1.05703},
   2}, {{x -> 0.000472617, y -> 1.33283},
   2}, {{x -> 0.689673, y -> 1.0198},
   2}, {{x -> 0.999061, y -> 1.00063},
  2}, {{x -> -0.999091, y -> 1.00061},
  2}, {{x -> 0.0311511, y -> 1.21628},
  2}, {{x -> 0.999488, y -> 1.00034},
  2}, {{x -> -0.99948, y -> 1.00035},
  2}, {{x -> 0.999309, y -> 1.00046},
  2}, {{x -> 0.999306, y -> 1.00046},
  2}, {{x -> -0.0123082, y -> 1.19216},
  2}, {{x -> 0.998646, y -> 1.0009},
  2}, {{x -> -0.0497191, y -> 1.26403},
  2}, {{x -> -0.0282922, y -> 1.18861},
  2}, {{x -> 0.999449, y -> 1.00037},
  2}, {{x -> 0.999237, y -> 1.00051},
  2}, {{x -> -0.62985, y -> 1.03042},
  2}, {{x -> -0.0443647, y -> 1.29435},
  2}, {{x -> 0.999127, y -> 1.00058}, 2}}
POSTED BY: Craig Loehle
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