0
$\begingroup$

I understand, that similar questions have been asked before, but I am absolutely new to Mathematica and can not solve it myself:

In nuce it is the following: I want to calculate

NMinimize[NMaximize[RegionDistance[reg1,{x,y,z}], {x,y,z} el f[a,b]][[1]],
{a,b} el Disk[{0,0},15]]

So I want to find parameters a,b in a certain Disk, so that the maximum distance from a point in f[a,b] - where f[a,b] evaluates for numeric values of a,b to a Region[] - to the region reg1 is minimized. (Note, I wrote "el" for the element sign in Mathematica).

I defined f[a,b] already with f[a_?NumericQ, b_?NumericQ] but it did not help. What can I do?

NOTE ADDED(!): I found a solution by making the inner function of NMinimize separate with conditions a_?NumericQ and b_?NumericQ:

dfmq = RegionDistance[Region[myQuartic]]

innerfun[a0_?NumericQ, b0_?NumericQ] := 
 NMaximize[
   dfmq[{x, y, z}], {x, y, z} \[Element] eqreg[a0, b0, 8/50.0]][[1]]

NMinimize[innerfun[a0, b0], {a0, b0} \[Element] Disk[{0, 0}, 15]]

Is this the only/correct way to solve it in all similar cases?

For completeness, I attach the ASCII transcript of my notebook:

In[5]:= myQuartic = Import["/home/juergen/renderstl/quartic-19022016-reduced/model-scaled-x7.stl", "BoundaryMeshRegion"]
Out[5]= 
In[7]:= RegionBounds[myQuartic]
Out[7]= {{-48.5411,48.4823},{-49.0028,49.0095},{-49.0087,49.0065}}
In[1]:= 
queq = -10+a x^2 + b y^2 + a x^2  z + b y^3 z + a x z^2
Out[1]= -10+a x^2+b y^2+a x^2 z+b y^3 z+a x z^2

In[39]:= Clear[eqreg]
In[40]:= eqreg[a0_?NumericQ, b0_?NumericQ, c_ ?NumericQ] := ImplicitRegion[(queq /. {x->(c x), y->(c y),z->(c z),a->a0,b->b0}) == 0 && ((c x)^2+(c y)^2+(c z)^2) <= 64,{x,y,z}]
In[41]:= newqueq = Region[eqreg[-1,-1, 8/50.0]]
Out[41]= 
In[15]:= RegionBounds[%]
Out[15]= {{-49.9903,18.3818},{-13.8827,50.},{-50.,-0.977203}}
In[16]:= dfmq = RegionDistance[myQuartic]
Out[16]= RegionDistanceFunction[Embedding dimension: 3
Region dimension: 3


Data not in notebook; Store now »

]
In[42]:= NMinimize[NMaximize[RegionDistance[myQuartic,{x,y,z}],{x,y,z} ∈ Region[eqreg[a0, b0, 8/50.0]]][[1]], {a0, b0} ∈ Disk[{0,0}, 15]]
During evaluation of In[42]:= Region::reg: eqreg[a0,b0,0.16] is not a correctly specified region.
During evaluation of In[42]:= NMinimize::nnum: The function value RegionDistance[,{x,y,z}] is not a number at {a0,b0} = {4.57403,-13.6426}.
Out[42]= NMinimize[RegionDistance[,{x,y,z}],{a0,b0}∈Disk[{0,0},15]]
In[32]:= Maximize[RegionDistance[myQuartic, {x,y,z}], {x,y,z} ∈ Region[eqreg[-1,-1,8/50.0]]][[1]]
Out[32]= 5.40186
In[43]:= eqreg[a,b,c]
Out[43]= eqreg[a,b,c]
In[44]:= eqreg[1,2,3]
Out[44]= ImplicitRegion[-10+x^2+2 y^2+x^2 z+2 y^3 z+x z^2==0&&9 x^2+9 y^2+9 z^2<=64,{x,y,z}]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.