Generating all possible permutations in the fox, goose and beans problem

I have learned graph theory, and am using it to solve the classic Fox, goose and bag of beans puzzle. If we consider that there are three locations for each of the fox (X), goose (G), farmer (F) and beans (B) (near side of river, in the boat, far side of the river), and there are four characters, there are hence 4^3 = 81 combinations. Two of these combinations would be

(Near)    (Boat)    (Far) F,G,B,X     -         -  (Near)    (Boat)    (Far)  B,X        F,G        - 

…for the starting state and the state when the farmer and the goose have entered the boat respectively.

I want to generate all of these states programatically (in C++, but that is beyond the point), but simply cannot get my head around how to do it. (I know that some of these 81 possible states will be invalid (e.g. that with all characters in the boat at once) but I can search for those and remove them afterwards.)

I am well aware of binary and how I get 81 combinations, and am aware using C++ I could generate all combinations of the characters F,G,X,B, but still cannot figure how to add the three “locations” into this.

Can someone please advise?

EDIT:

OK, can the downvoter explain how “this question does not show any research effort; it is unclear or not useful”. Do you want me to list everything I’ve tried and every single search I’ve done??

(And yes, I have extensively searched for solutions before posting here.)

Generating a set of divergence-free basis

I’m trying to derive an algorithm that would generate a set of divergence-free vectors, which shall be used as basis vectors later on. Using a simple example, a 2D second-order divergence-free basis would look like this:

$ $ \begin{bmatrix} 1 \ 0 \end{bmatrix}, \begin{bmatrix} 0 \ 1 \end{bmatrix}, \begin{bmatrix} x \ -y \end{bmatrix}, \begin{bmatrix} y \ 0 \end{bmatrix}, \begin{bmatrix} 0 \ x \end{bmatrix}, \begin{bmatrix} x^2 \ -2xy \end{bmatrix}, \begin{bmatrix} xy \ -\frac{1}{2} y^2 \end{bmatrix}, \begin{bmatrix} y^2 \ 0 \end{bmatrix}, \begin{bmatrix} 0 \ x^2 \end{bmatrix}. $ $

So far, I have manually implemented these calculations, but it will be quite tedious to work it out for 3D cases and for higher order. As of now, my pseudocode for 2D case looks like this:

switch (order):   order=1:      // manually calculate vectors for first order   order=2:      // manually calculate vectors for second order   [...] 

I would imagine things to be nastier in 3D… As of now, I am trying both to derive the whole basis manually and to come up with an algorithm to do it. Any suggestions?

Generating Latin hypercube samples with numpy

I wrote some code to generate Latin hypercube samples for interpolation over high-dimensional parameter spaces. Latin hypercubes are essentially collections of points on a hypercube that are placed on a cubic/rectangular grid, which possess the property that no two points share any individual coordinate. e.g., for 2 dimensions and 4 total samples, this is a Latin hypercube:

| | | |x| | |x| | | |x| | | | | | |x| | 

One algorithm for generating this is to generate D random permutations of the integers 0 through N-1, where D is the number of dimensions and N is the desired number of samples. Concatenating these together into a DxN matrix gives a list of coordinates which will form a Latin hypercube.

I am also interested in generating a special type of Latin hypercube called a symmetric Latin hypercube. This property essentially means that the hypercube is invariant under spatial inversion. One way of expressing this condition, is that (if the samples are zero-indexed) if the hypercube has the sample (i, j, …, k), for some integer indices i,j,k, then it also has the sample (n-1-i, n-1-j, …, n-1-k), where n is the number of samples. For 2D and n=4, this is an example of a symmetric Latin hypercube:

| |x| | | | | | |x| |x| | | | | | |x| | 

The condensed version of why I want to do this is that I want to evaluate a function which is expensive to compute, and depends on many parameters. I pre-generate a list of values for this function at a set of points and use interpolation over the parameters to extend this list to any desired point within a set range. Latin hypercube samples are used for the pre-computation instead of a grid, with the idea that they will more efficiently sample the behavior of the function and result in lower interpolation errors.

I have tested the code below both using automated tests and by visual inspection of the results for the trivial 2D case. Statistical tests of higher dimensional cases have convinced me it works successfully there as well. The code can produce either random Latin hypercubes or a rather nongeneral set of symmetric ones (I am convinced my second algorithm cannot in principle generate any possible symmetric Latin hypercube, just a specific type). Also, the symmetric algorithm doesn’t really work properly for odd numbers of samples, so I have outright blocked such samples from being generated.

My code can be seen along with specification and performance tests here, although not the visual tests at the moment.

I am aware that my project structure is probably overkill for the amount of code here. I am mostly looking for any insights regarding my algorithms, as while they are very fast even for large dimensions and sample sizes, I don’t doubt improvements exist. However any comments are welcome.

import numpy as np   class LatinSampler:     def _check_num_is_even(self, num):         if num % 2 != 0:             raise ValueError("Number of samples must be even")      def get_lh_sample(self, param_mins, param_maxes, num_samples):         dim = param_mins.size          latin_points = np.array([np.random.permutation(num_samples) for i in range(dim)]).T          lengths = (param_maxes - param_mins)[None, :]         return lengths*(latin_points + 0.5)/num_samples + param_mins[None, :]      def get_sym_sample(self, param_mins, param_maxes, num_samples):         self._check_num_is_even(num_samples)          dim = param_mins.size          even_nums = np.arange(0, num_samples, 2)         permutations = np.array([np.random.permutation(even_nums) for i in range(dim)])         inverses = (num_samples - 1) - permutations          latin_points = np.concatenate((permutations,inverses), axis=1).T          lengths = (param_maxes - param_mins)[None, :]         return  lengths*(latin_points + 0.5)/num_samples + param_mins[None, :] 

How to Stop a Workflow from Generating Another Workflow – SharePoint 2010

I have two lists, Parent and Child, and both are using InfoPath to create items.

  • When an item is created on either list a SharePoint Designer workflow also creates the same item on the other list.
  • As you may guess, when one workflow creates or updates an item on the other list, the other list’s workflow gets triggered and auto generates its workflow, which creates a duplicate item on the original list. Each workflow uses the others items ID.
  • Example: IF Child:ParentID equals Current Item: ID then update item in Child….Else ..IF Child:ParentID not equals Current Item:ID then create item in Child

How do I prevent duplicating the list items?

Generating a CSV file from all contacts in Outlook Directory

As part of a University, I have been assigned a University email. When I access my email through Outlook, and I go on the “People” section, I am able to access a section with all of the contacts in the University.

However, I am able to export as a CSV file only the contacts that I directly add to my contacts list.

The question is: how can I export all of the contacts in the directory without directly adding them to my contacts?

Generating NMI (non-maskable interrupt) in Mac VM running on VMware Fusion

I’m trying to (kernel-)debug my Mac 10.14.5 VM running on VMWare Fusion (v11.0.2) on my Mac 10.13.6 host. I’m following documentation/blogs in [1], [2].

I am trying to generate an NMI (non-maskable interrupt) in my VM, so that it triggers the VM to wait for the remote debugger connection. But looks like I cannot trigger the NMI. Pressing the given key combination (Command-Option-Control-Shift-Escape) isn’t working. Neither can I seem to simulate it via the below AppleScript:

-- 53 is escape tell application "System Events" to key code 53 using {command down, option down, control down, shift down} 

What has helped make a successful connection with the remote debugger is to manually generate a panic like so: (from [3])

sudo dtrace -w -n "BEGIN{ panic();}" 

But this is not good enough for me — the panic’d session is no longer recoverable, and my goal is to debug/understand regular functioning of the VM.

So my questions, finally:

  • How do I generate the NMI on my VM?
  • Alternatively, is there any other way to trigger a successful connection with the remote debugger such that I can debug regular functioning of the VM?

Thank you!

References:

  1. http://ddeville.me/2015/08/kernel-debugging-with-lldb-and-vmware-fusion
  2. https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/KernelProgramming/build/build.html#//apple_ref/doc/uid/TP30000905-CH221-BABDGEGF
  3. https://www.wikihow.com/Force-a-Kernel-Panic-on-a-Mac

Generating all connected graphs from a set of n-valent vertices?

I would like to have a function generateConnected[list_] that, given a set of vertices with pre-defined valence (number of outgoing edges) generates all possible connected diagrams.

For example, let us choose the following names for vertices of valence 1 through 6:

vertexNames = { x , u , y , z , q , w }; 

which means, a vertex of label x can have only one edge attached to it, u can have only 2 edges, y can have only three edges etc.

Then a set of vertices might be chosen e.g. as follows, so that the output is

set = Flatten[{Array[x, 5], y , z }] generateConnected[set,vertexNames] 

{ x[1] , x[2] , x[3] , x[4] , x[5] , y , z }

enter image description here

Is there an efficient way to do this in Mathematica?

Generating or extracting public certificate and public key

Aim: Achieve two way mutual authentication

Could any one please help me understand how can i generate a publick key and public certificate so that i will share this to my clients so that they can connect my server.

Things i have for my server(tibco ems) CA signed root intermediate and chain certificate Private key

Things i want for my client(java application)

A p12 file which contains a public key and public certificate of my server so that they can connect to my server

Server : apache linux server Application tibco ems(server)

Ideas for Artificially Generating Word of Mouth

I noticed that a lot of companies with something new to promote will hire a team of posters to artificially generate word of mouth about their new offerings. One method they use is to join various forums pretending to be a potential customer wanting to know if anyone has heard about their product or service. They then get other posters to respond to the thread pretending to be interested. If done properly, this thread will usually attract the attention of other members of the forum which…

Ideas for Artificially Generating Word of Mouth