Tag Info

Hot answers tagged

5

edges = coords /. Line[{a_, b_}] :> UndirectedEdge[a, b]; g = Graph[edges]; starts = VertexList[g, {_, 0}]; ends = VertexList[g, {_, 4}]; Intersection[Join @@ ConnectedComponents[g, starts], ends] != {} (*True*) And we can show all of them ... g = Graph[edges]; g1 = SetProperty[g, VertexCoordinates -> VertexList@g]; paths = ...


4

Here is a general approach, illustrated with a basic Lotka-Volterra model. In this case I simply registered events when the derivative of x is zero (crossing from above), thus there is a local maximum. This is not foolproof as there could be e.g/ a plateau like in case of your blue curve that might trigger the event multiple times due to small numerical ...


2

Bounding the range of n resolves the issue with Maximize Maximize[{(3 n + 4)/(2 n + 1), Element[n, Integers], -100 <= n <= 100}, n] {4, {n -> 0}} Or, Maximize[{(3 n + 4)/(2 n + 1), -100 <= n <= 100}, n, Integers] {4, {n -> 0}} Any large value for the range bound will work since Limit[(3 n + 4)/(2 n + 1), n -> #] & /@ ...


2

One has to provide the variables as a flat list. Therefore you just have to replace z with Flatten[z] in your Minimize: Minimize[{Total[Flatten[z*f]], Total[z] == 10 && NonNegative[Min[z]]}, Flatten@z, Integers]


2

As others have pointed out, this could have been formatted in a more usable manner. Also there are conventions about avoiding capitalizing, and sometimes I like to avoid single letter "variables" other than e.g. loop indices. I will remark that an early attempt at optimizing ran me afoul of real arithmetic (see comment regarding fractional exponent and ...


2

There are a couple of issues. One is that you need to bypass symbolic processing since entities like a[[i]] (with i symbolic) are not defined. We do this by forcing f to only work with explicit Integer inputs. a = {1, 2}; b = {2, 3}; f[i_Integer, j_Integer] := a[[i]]^2 + b[[j]]^2; The scond issue is that we now have an objective that is, in a sense, a ...


1

This demo allows the user to set x- minimum and maximum. It uses Initialization and local variables x1 and x2 to store the values so when the notebook is reopened in another session the last saved inputs are still present. Panel[DynamicModule[{f = x^2 + 3, x1 = -10, x2 = 10}, Column[{ Row[{"function ", InputField[Dynamic[f]]}], Row[{"x min = ", ...


1

So in fact, this is a graph search problem, Right? The normal approaches is to use Depth-First-Search(DFS) or Breadth-First-Search(BFS) to test connected relation of two points. For example, if you want to test whether coordinate (3,0) is connected to coordinate (2, 4), you can just use DFS or BFS to do the test. I think the trick point in your problem ...


1

Diophantine problems are tough and there is no silver bullet. In your example this works: i = IntegerPart; sol = NMaximize[{(3 i@ n + 4)/(2 i@n + 1), n > 1}, n]; i@n /. sol[[2]] (* 1 *)



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