# Tag Info

## Hot answers tagged mathematical-optimization

4

Your formulation doesn't work because your constraints don't involve variables. The preferred solution was posted as a comment to your question, but for making your original one work you could do: NMaximize[{(p^2)^alpha + ((c - p)^2)^alpha + (1 - (c - p)^2 - p^2)^ alpha, {c/2 - Sqrt[2 - c^2]/2 < p, p < c/2 + Sqrt[2 - c^2]/2, c == 1.2, alpha == ...

4

I am not sure if the return value of Variables meets your standard. If so, this works. Complement[symbolsList, Variables@expression] == {} AbsoluteTiming@ Do[Complement[symbolsList, Variables@expression] == {};, {200000}] {0.575185, Null} As @Szabolcs commented, Level[expression, {-1}] may be a nice alternative. And it's actually faster in this ...

4

Import the data and filenames, cull the datasets of information that is not useful: data = Import /@ FileNames["*.csv"]; filenames = FileNames["*.csv"]; data = data[[All, 2 ;;, {1, 2}]]; ListLinePlot[data, PlotLegends -> filenames] Looks like PT data was either incorrectly collected or is effectively transparent in the region of interest. The ...

3

With[{s = Max[Cases[Log[Rest[Divisors[#]], #], _Integer]]}, {Surd[#, s], s}] &[yourNumberHere] Not surprisingly, most integers are there own "highest power". Here's from 2 to 1000:

3

There are two things that can be done to improve matters. One is to use constraints with weak inequalities that keep the log arguments above a minmium threshold. The other is to use an altered logarithm that allows argumens less-equal to zero and simply returns a suitable large negative. T = 10; J1 = 1; J2 = -0.2; bigValue = 10^6; myLog[x_?NumberQ] := If[x ...

3

It is equivalent to minimize the absolute values. This can be set up as an explicit linear programming problem. The advantage over the approach of @bobthechemist (which is good, and I voted up) is that the problem can then be shipped to special case LP code. vars = Array[x, d2]; linearexprs = mat.vars - vec; constraints = Join[Thread[max >= ...

3

In your comment you gave an explicit example of finding the value of $a$ which maximized $a$ times the area of the region of $x,y\in [0,1]$ such that $y\geq ax$ or $y\geq1/2$. You claim the optimum value of $a$ is 1, but this appears to be incorrect: Integrate[a Boole[y >= a x || y >= 1/2], {x, 0, 1}, {y, 0, 1}] Plot[%, {a, 0, 3}] \begin{cases} a ...

1

Mathematica Learning Center has a nice tutorial about Constrained Optimization and Unconstrained Optimization available in ebook format (PDF). You can find more resources in the learning center if you search for "numerical optimization".

1

Since LeastSquares can be written as NMinimize[Plus @@ ((mat.{x1, x2, x3, x4} - vec)^2), {x1, x2, x3, x4}] Then you can use a similar approach to minimizing your desired function: NMinimize[Max @@ ((mat.{x1, x2, x3, x4} - vec)^2), {x1, x2, x3, x4}] Although whether or not this is the "best" way is likely up for debate.

1

Here is the final result if you are interested. data = Import /@ FileNames["/home/marco/LatexDocs/analytical/uvvis/PHOS_*.CSV"]; data = data[[All, 2 ;;, {1, 2}]]; ListLinePlot[data, PlotLegends -> {"BB", "MR", "PT", "TB", "UI"}, AxesLabel -> {Style["wavelength (nm)" , FontSize -> 16], Style["Absorbance", FontSize -> 16]}, PlotRange ...

1

Of all the approaches not yet presented here this one seems to be the fastest: containsAllSymbols[expr_, s_] := !FreeQ[expr, s] containsAllSymbols[expr_, first_, rest__] := And[!FreeQ[expr, first], containsAllSymbols[expr, rest]] EDIT: I claimed this to be faster than Complement[symbolsList, Variables@expression] but I was wrong, sorry. Note that this ...

1

Here's one way to get an answer: NMaximize[{Sqrt[Abs[p0 q2 + p2 q0]] + Sqrt[Abs[p0 q1 + p1 q0]] + Sqrt[Abs[p1 q3 + p3 q1]] + Sqrt[Abs[p2 q3 + p3 q2]], (0 < p0 < 1) && (0 < p1 < 1) && (0 < p2 < 1) && (0 < p3 < 1) && (0 < q0 < 1) && (0 < q1 < 1) && (0 < q2 < ...

Only top voted, non community-wiki answers of a minimum length are eligible