19

Turning a comment into an answer. This is more or less a straight-forward adaptation of a solution in Efficient solution for a discrete assignment problem with pairwise costs to the problem. This method performs small weighted permutations of an ordered list representing the truck-post schedule. Permutations are accepted if they improve the metric, but may ...


16

Not sure if this is the best way, but you could consider something like this: Manipulate[ {x, y}, {x, Manipulator[Dynamic[x, (x = #; y = 1/#) &], {.1, 10}] &}, {y, Manipulator[Dynamic[y, (y = #; x = 1/#) &], {.1, 10}] &}, Initialization :> ({x, y} = {1, 1})] Edit V10 Since V10 one can use a shorter form: Manipulate[ {x, y} , {...


16

One approach would be to run the evaluation in a second kernel which is controlled from a main kernel through MathLink/WSTP. Then your main kernel can detect if the MathLink connection dies. You can implement this manually (a lot of work), or you can try to do it using the parallel computing tools, where much of the groundwork is already laid down. In ...


15

Thanks to Mike Honeychurch we know it's a bug: WRI tech support confirm that this is a bug – Mike Honeychurch 10 hours ago What can we do? In simple cases, just add a stupid vanishing wrapper: Dynamic[First @ List @ x] both examples are working with that. But it has a limitation, e.g. when the Dynamic we are talking about is in some kind of ...


13

This is my third answer to this question. To summarize what follows: I do not longer think it is a bug. What we see is completely predictable and can be considered at most as undesirabable behaviour in a slightly pathological example. Some terminology. I will call a displayed Dynamic expression a dynamic object. As everything shown in a notebook, it is ...


13

Assuming FrontEnd survives, prepare 3 cells: (*init cell, won't be needed later*) state = CurrentValue[EvaluationNotebook[], {"TaggingRules", "state"}] = 0; SetOptions[ #, {CellTags -> {"Procedure"}, ShowCellTags -> True} ]& /@ {NextCell[], NextCell @ NextCell[]}; CurrentValue[$FrontEndSession, "ClearEvaluationQueueOnKernelQuit"] = False; ...


11

The reason is because Button actions are calculated on a preemptive link, meaning they preempt any other evaluation, but are only allowed a certain amount of time to evaluate. That indicates: the front end sends one evaluation at a time and waits for the result before continuing with its other work Tutorial / Advanced Dynamic Functionality / ...


11

By default, DynamicModule uses SynchronousInitialization -> True. This causes the initialization to be performed on the preemptive link, disabling any updates to the front-end. In particular, print statements, cell creation and dynamic box updates will all be deferred until the initialization completes. If we wish to monitor that initialization within ...


10

Edit Can you think of another way to accomplish the same thing [...]? It would be nice to have a solution that didn't involve duplicating each slider. -nibudd DynamicModule[{a = 1, tempA = 1, auto = True} , ifAuto = Dynamic[ If[auto, Identity, Setting]@#, TrackedSymbols :> {auto} ] &; Column[{ ifAuto @ Dynamic @ Plot[Sin[a ...


10

There is an optimization in the front end that's catching this case. Specifically, when the FE requests the evaluation of the Dynamic, it checks to see if the resulting expression that came back is different from the previous expression. If it's the same, then it does not destroy and recreate the boxes. Since this is a typeset DynamicBox, it's sending a ...


9

You can define a function that creates Manipulates with a "fake" SetterBar and a specific AutorunSequencing m[k_, seq_] := Manipulate[ Plot[{Sin[a*x] + b*Cos[3 a*x], k*x}, {x, 0, Pi}, ImageSize -> 400], {a, 1, 2}, {b, 0, 1}, Grid@{{"k", SetterBar[k, {0, .5, 1}]}}, AutorunSequencing -> seq, ContentSize -> {420, 270}] then create the frames for ...


9

On Windows this works for me: Pause[1]; 1 + 1 (*you can add Save or Export here ofc*) NotebookSave @ EvaluationNotebook[]; Run["shutdown -t 2 -s"]; NotebookClose[] For command explanation take a look at the link Öskå has provided: SO:162305


9

Some notes First of all Dynamic[++i] does nothing unless it is displayed, and ScheduledTask is evaluated in Kernel without sending DynamicBoxes to the Notebook. You can read more about that in: Why does ; suppress Dynamic output? or in tutorials: IntroductionToDynamic Correct syntax: use ScheduledTasks[++i...] There is a bug that affects crude Dynamic[...


8

You could also build a custom Manipulate-like object using sliders Panel[DynamicModule[{x, y}, Column[{ Grid[{ {"x", Slider[Dynamic[x, (x = #; y = 1/#) &], {0.1, 10}], Dynamic[x]}, {"y", Slider[Dynamic[y, (y = #; x = 1/#) &], {0.1, 10}], Dynamic[y]} }], Panel[{Dynamic[x], Dynamic[y]}, ImageSize -&...


8

The short answer is: no, Mathematica is simply not suitable for time-critical applications. There are several reasons for this: Mathematica is a slow interpreted language and the time taken by various operations can be close to your threshold of milliseconds There are several things that may interrupt the Mathematica kernel while it's doing calculations, ...


8

I wrote something to do something a little like what you wanted. Here I've adapted it so you can get a run through for each setting of the SetterBar. Some description of the functions. autolist[control_pattern] := list of manipulate settings for the animation specs is a pattern for culling variable specifications out of a Manipulate rulefunction[...


8

Try (in version 10.1): TimelinePlot[{{Interval[{DateObject[{2015, 4, 27, 6, 30, 15}], DateObject[{2015, 4, 28, 9, 15, 45}]}], DateObject[{2015, 4, 28, 12, 0, 0}], Interval[{DateObject[{2015, 4, 28, 15, 30, 0}], DateObject[{2015, 4, 29, 10, 0, 0}]}]}, {Interval[{DateObject[{2015, 4, 28, 11, 0, 0}], DateObject[{2015, 4, ...


8

It's hard to say much without details but let's try: globalVar = 0; DynamicModule[{ localVar = 0}, Column[{ Button["Stop", RemoveScheduledTask@ScheduledTasks[]], Dynamic@List@localVar }] , Initialization :> ( RunScheduledTask[ If[localVar != globalVar, localVar = globalVar; FinishDynamic[]], 1, 2 ] ) ] This is kind of ...


7

The export to movie is easy. (just write p=Manipulate[..] then export p to movie. Controlling the sequences as you want, I think have to be programmed in. Autorunsquences does not give one full control of all the scenario needed. Here is the Manipulate you have. It runs in 2 modes. Automode, runs pre-programmed scenario. Click again, turn this off, so you ...


7

This is just an idea how to prepare frames to export, don't have time for more now: f = Interpolation[ { {0, {1, 0, 0}}, {1, {2, 0, 0}}, {2, {2, 1, 0}}, {2.02, {1, 0, .5}}, {3, {1, 0, .5}}, {4, {2, 0, .5}}, {5, {2, 1, .5}}, {5.02, {1, 0, 1}}, {6, {1, 0, 1}}, {7, {2, 0, 1}}, {8, {2, 1, 1}} }, InterpolationOrder -> 1]...


7

A better way to check if any scheduled tasks are active is Or @@ ScheduledTaskActiveQ /@ ScheduledTasks[] The reason why this is better is that it uses an API, thus it is more likely to be robust against future changes in the structure of ScheduledTaskObject. In the Raspberry Pi version current as of 2014-06-18, ScheduledTaskObject includes extra options ...


7

I found a way to check for running scheduled tasks, but I am not sure, if the blocking behaviour of Pause is the best thing to do. RunScheduledTask[Print["Bazinga!"], {5, 10}] (* a lot of code *) (* till the end of script *) While[ Or@@ScheduledTasks[][[All, 5]], Print[DateString[]]; Pause[1]] Output: C:\Software\Dev>math -script test.m "Wed 18 Jun ...


7

Keep in mind it is a toy answer, from my tests it appears it is not general enough. MMA is well designed to fix problems it creates :) What I've found is that Dynamic aren't stable but Initialization triggers as it should. Let's use it to overwrite it's content when new session occurs: restartProtect[Dynamic[DateString[], UpdateInterval -> 1]] ...


7

For a simple schedule you can use build-in RunScheduledTask. For example, the following will print current time if the number of seconds is multiple of 10 RunScheduledTask[Print@Now, 10, Ceiling[AbsoluteTime[], 10]] RemoveScheduledTask[ScheduledTasks[]];


7

What is going on By default the Dynamic, EventHandlers and various controllers like Button and Slider use a PreemptiveLink to communicate with the kernel. Synchronous versus Asynchronous Dynamic Evaluations about the PreemptiveLink: [...] There is no queue; instead, the front end sends one evaluation at a time and waits for the result before continuing ...


7

This is not really an answer, because it involves speculation on my part. However, I think it casts some light on the issue you are reporting. Consider the following extension of your code: x = 0; Dynamic[Row[{x++, " ", MousePosition["Graphics"]}], UpdateInterval -> 2, TrackedSymbols :> {}] Graphics @ Disk[] Note that, as long as the mouse cursor ...


7

Removing Those three actions are using the same functionality, pick whatever is more convenient: Assuming the desired cell is selected: menu item Evaluation / Remove from evaluation queue shortcut Shift+Alt+. token FrontEndExecute @ FrontEndToken @ "RemoveFromEvaluationQueue" Inserting I don't know if there is a general way because cells can be queued ...


6

Use the Pause function: SetAttributes[delayedFunction, {HoldFirst}]; delayedFunction[function_] := (Pause[5]; function);


6

Summing up: There is no built-in way to track part of a symbol. Albert's answer uses additional symbol for each part we track. It is useful to digest that code as this idiom can help in variety of cases (e.g. listening to Length[a], etc). Unfortunately it does not scale when you want to track hundreds of indices or you don't know how many you will need. ...


6

Using the quartz library implemented in Java we can have access to the next execution date of a scheduled task given a cron specification. Then the code below creates a scheduled task that executes at the next execution date and extends itself after the task has been executed. Other helper functions are provided. You can download the quartz library at the ...


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