Finding the shortest path between 2 points namely S and G? It SHOULD pass through points named #. The allowed pathway is denoted as . and the blocked pathway is denoted as #. The upper cap of the number of points inbetween is 19.
Example:
input
########
##....G#
##.#####
#..#..S#
##.....#
########
"It should pass through points named #" - If you can elaborate more on this. OR for the example above, what is the expected solution.
Also statement says "blocked pathway is denoted as X" and in example, we see "#". I believe you meant # as X.
I assume direction of movement would be left, right, up and down.
This can be solved by breadth first search (BFS) on the grid.
Start from S and explore all paths level by level based on given constraint where you can reach and where you can't reach.
We can take two arrays or lists say currentLevel and nextLevel. And a variable, say levelCount.
Store position S in currentLevel.
Loop through positions in currentLevel one by one. If it is G, levelCount is the shortest path.
Else, for all safe positions (left, right, up and down) where we can reach and store them in
nextLevel. "safe position" means that it should not be X, should not go beyond the given
grid extent (i.e. position index should not less than zero and not greater than length)
or other constraint given in problem.
Set currentLevel to nextLevel, increment levelCount and clear nextLevel. Go to step 1.
Related
I try to understand how to input material properties using engineering constants for VTI material ( vertical transverse isotropic) with direction 3 being vertical direction. Does anyone has inp example showing how to input these material properties? For example, I don't know how to input nu12, n13? Thanks
enter image description here
As for transversely isotropic materials you have to provide 5 different parameters (I don't know what the vertical means, I never read this before).
For the convention on the poissons number please see Abaqus online documentation - conventions.
For your example. You should usually have one "master" direction (englisch is not my first language). And you have a plane perpendicular to this which has rotational symmetry. If your 3-direction is this (maybe the direction in which fibers are oriented) then your E11 and E22 values should be identical. Furthermore two of your possion numbers in your case 31 and 32 (prependicular/parallel sometimes called). Also the same directions of shear modules have to be identical.
The last shear modulus can be obtain via
G = E/2(1+nu) where E must be prependicular E modulus (2,1) and the poisson number must be the prependicular one (21)
Your constants: E33, E22=E11, nu31=nu32, nu12, G31=G32 , calculate G21 from above equation
For clarification
from H. Schürmann - Konstruieren mit Faser-Kunststoff-Verbunden (construction with fiber reinforced materials)
NOTE: In this picture the 1 direction is the parallel direction where fibers are oriented, adjust it accordingly or follow what i wrote above.
I am trying to solve with Comsol the problem of the figureTwo blue big electrodes with fixed potentials V1,V2. One red small electrode that moves above the others along x axis at constant distance and voltage V0. The charge in V0 depends on the electric field at each point 8(x). I have one small electrode with a potential V0 moving along x axis above two bigger electrodes with fixed potentials V1,V2.
I can easily compute with comsol the potential and field at each point in 3D and the resulting charge in V0 electrode. However i would like to simulate this charge along the x axis and eventually map it also for z and y direction so i have a V0 charge 2D map at a fixed distance.
How can i do this in COMSOL without changing the geometry coordinates manually and computing again the charge at each point?
Thank you for your answers,
Jorge
I'll describe how to setup the system so that you can move V0 around. Note that this requires changing the mesh throughout the simulation. For this reason, I don't think you want a "time dependent" study but instead you want to use the "parametric sweep" option.
First, go to your Global Parameters and create a parameter called block_x_pos or whatever you want.
Go to Component → Geometry and select V0 and in the appropriate field under the "Position" tab (in the Setting Panel), write block_x_pos in the X Position. This makes that position controllable by whatever value is in block_x_pos.
Right click on the appropriate Study and select "Parametric Sweep". The purpose (as far as I know) for the Parametric Sweep is that when the geometry is changing during computation, it updates the mesh accordingly, so you don't have to do it manually through some painful repetition. Select the "Parametric Sweep" node which has now appeared. Look in the Settings Panel and find the "Study Settings" tab. Below the empty table, you'll see some arrows and a "+" sign. Click the "+". This will add a new sweep parameter to the table. Click the dropdown menu on the table and select the "time" Global Parameter. In the "Parameter Value List" field, write the range of values you'd like to have it take.
i.e. if you want the block_x_pos parameter to vary from 0 to 10 in steps of 0.1, you would write range(0, 0.1, 10). Or you could write '-3 0 1 2 4 5 9 11' and it will take those values.
Now Compute using that same Study.
When you are making plots, be sure to use the correct Solution. It will be labeled something like "Study1/ParametricSolutions1". When you select this as your "Data Set", you will find (in your Settings Panel) a new dropdown menu below the "Data Set" field called "Parametric selection (time)". You can choose to show multiple values for the "time" parameter on most plot types.
Has anyone been able to do spatial operations with #ApacheSpark? e.g. intersection of two sets that contain line segments?
I would like to intersect two sets of lines.
Here is a 1-dimensional example:
The two sets are:
A = {(1,4), (5,9), (10,17),(18,20)}
B = {(2,5), (6,9), (10,15),(16,20)}
The result intersection would be:
intersection(A,B) = {(1,1), (2,4), (5,5), (6,9), (10,15), (16,17), (18,20)}
A few more details:
- sets have ~3 million items
- the lines in a set cover the entire range
Thanks.
One approach to parallelize this would be to create a grid of some size, and group line segments by the grids they belong to.
So for a grid with sizes n, you could flatMap pairs of coordinates (segments of line segments), to create (gridId, ( (x,y), (x,y) )) key-value pairs.
The segment (1,3), (5,9) would be mapped to ( (1,1), ((1,3),(5,9) ) for a grid size 10 - that line segment only exists in grid "slot" 1,1 (the grid from 0-10,0-10). If you chose a smaller grid size, the line segment would be flatmapped to multiple key-value pairs, one for each grid-slot it belongs to.
Having done that, you can groupByKey, and for each group, calculation intersections as normal.
It wouldn't exactly be the most efficient way of doing things, especially if you've got long line segments spanning multiple grid "slots", but it's a simple way of splitting the problem into subproblems that'll fit in memory.
You could solve this with a full cartesian join of the two RDDs, but this would become incredibly slow at large scale. If your problem is smallish, sure, this is an easy and cheap approach. Just emit the overlap, if any, between every pair in the join.
To do better, I imagine that you can solve this by sorting the sets by start point, and then walking through both at the same time, matching one's current interval versus another and emitting overlaps. Details left to the reader.
You can almost solve this by first mapping each tuple (x,y) in A to something like ((x,y),'A') or something, and the same for B, and then taking the union and sortBy the x values. Then you can mapPartitions to encounter a stream of labeled segments and implement your algorithm.
This doesn't quite work though since you would miss overlaps between values at the ends of partitions. I can't think of a good simple way to take care of that off the top of my head.
I have a richedit containing lines using different fonts, styles, languages etc.
I am drawing in a gutter. I would like to start my drawing at the same y pixel position as the corresponding line.
Send the control an em_PosFromChar message. It returns the client coordinates of the character at the given index, although the documentation doesn't say what the coordinates represent (upper left corner, baseline center, or what). You're looking for the character's baseline.
Use em_LineIndex to get a character index for a given line number, if you don't already know the index of a character you're interested in.
I have a little logical problem over here.
As the title says, I try to build a boardgame as a computer-program (maybe with internet-support, but thats another story)
As for now, I have a map, which has some crossroads in it, hence I cannot simply define the fields as '1, 2, 3, 4, ...' because if there is a crossroad at field 10, I would have more than one field which has to be labeled 11 (Because then there is a field left and right of field 10, for example.)
So the problem is, if I cannot define the Board in numbers then I cannot simply get the possible positions a player can take when he rolls 2d6-dices with calculating 'Field-Nr. + RandomRange(1,6) + RandomRange(1,6)'
Does anybody have an idea, how to define a Map like this on another way, where I still can calculate the possible new-fields for Player X with a 2d6-dice-roll?
Thanks in advance.
If i understand well... (i don't thing so) this might help you. Just use dynamic arrays for your boardgame field and change your actions after the dimensions x,y .... Look at this "type Name = array of {array of ...} Base type; // Dynamic array"
It sounds like you have a graph of connected vertices. When a player is at a particular vertex of N edges, assuming N < 12, the new Field will be reached from traversing edge number N % ( rand(6) + rand(6) ).
You could also just do rand(12), but that would have an even distribution, unlike 2d6.
Instead of dynamic arrays, I would recommend using a linked-list of records to describe the surrounding cells, and traverse the player's location and possible moves using that linked-list.
First, define a record that describes each cell in your board's playable grid (the cells on the grid can be four-sided like a chessboard, or hexagonal like in Civilization V) ... each cell record should contain info such as coordinates, which players are also in that cell, any rewards/hazards/etc that would affect gameplay, etc. (you get the idea).
Finally, the linked-list joins all of these cells, effectively pointing to any connected cells. That way, all you'd need is the cell location of Player X and calculate possible moves over n amount of cells (determined by the dice roll), traversing the adjoining cells (that don't have hazards, for example).
If all you want is to track the possible roads, you can also use this approach to identify possible paths (instead of cells) Player X can travel on.