Friday, 15 February 2013

algorithm - Modifying A* to find a path to closest of multiple goals on a rectangular grid -



algorithm - Modifying A* to find a path to closest of multiple goals on a rectangular grid -

the problem: finding path closest of multiple goals on rectangular grid obstacles. moving up/down/left/right allowed (no diagonals). did see this question , answers, and this, and that, among others. didn't see utilize or suggest particular approach. have major error in approach?

my of import constraint here is inexpensive me represent path (or list, matter) "stack", or "singly-linked-list", if want. is, constant time access top element, o(n) reversing.

the obvious (to me) solution search path of goals starting point, using manhattan distance heuristic. first path goal starting point shortest path closest goal (one of many, possibly), , don't need reverse path before next (it in "correct" order, starting point on top , goal @ end).

in pseudo-code:

a*(start, goals) : init_priority_queue(start, goals, p_queue) homecoming path(start, p_queue) init_priority_queue(start, goals, q_queue) : (g in goals) : h = manhattan_distance(start, g) insert(h, g, q_queue) path(start, p_queue) : h, path = extract_min(q_queue) if (top(path) == start) : homecoming path else : expand(start, path, q_queue) homecoming path(start, q_queue) expand(start, path, q_queue) : = top(path) (n in next(this)) : h = mahnattan_distance(start, n) new_path = push(n, path) insert(h, new_path, p_queue)

to me seems natural reverse search in way. there think-o in here?

and question: assuming priority queue stable on elements same priority (if 2 elements have same priority, 1 inserted later come out earlier). have left next above undefined on purpose: randomizing order in possible next tiles on rectangular grid returned seems inexpensive way of finding unpredictable, rather zig-zaggy path through rectangular area free of obstacles, instead of going along 2 of edges (a zig-zag path statistically more probable). correct?

it's right , efficient in big o far can see (n log n long heuristic admissible , consistent, n = number of cells of grid, assuming utilize priority queue operations work in log n). zig-zag work.

p.s. these sort of problem there more efficient "priority queue" works in o(1). these sort of problem mean case effective distance between every pair of nodes little constant (3 in problem).

edit: requested in comment, here details constant time "priority queue" problem.

first, transform graph next graph: allow potential of nodes in graph (i.e., cell in grid) manhattan distance node goal (i.e., heuristic). phone call potential of node p(i). previously, there border between adjacent cells , weight 1. in modified graph, weight w(i, j) changed w(i, j) - p(i) + p(j). same graph in proof why a* optimal , terminates in polynomial time in case heuristic admissible , consistent. note manhattan distance heuristic problem both admissible , consistent.

the first key observation a* in original graph same dijkstra in modified graph. since "value" of node in modified graph distance origin node plus p(i). sec key observation weight of every border in our transformed graph either 0 or 2. thus, can simulate a* using "deque" (or bidirectional linked list) instead of ordinary queue: whenever encounter border weight 0, force front end of queue, , whenever encounter border weight 2, force end of queue.

thus, algorithm simulates a* , works in linear time in worst case.

algorithm search linked-list a-star

DB2 SQL z/OS - variable equivalent of a hex constant -



DB2 SQL z/OS - variable equivalent of a hex constant -

i'm trying extract info (using spufi) db2 table file, 1 of output fields converting decimal field same format cobol comp field. e.g. today's date (20141007) ..ëõ

the sql hex function converts 20141007 013353cf, , doing select of x'013353cf' gives me desired result, that's constant, i'm trying find equivalent function. inverse of hex function.

i've come across couple of suggestions using user defined functions. problem is, we've upgraded db2 10 , new function mode isn't enabled yet, means don't have access command functions in udf.

i suspect i'm out of luck, wondering if has suggestions. appreciate wrong tool job, , easier write cobol programme it, various constraints preventing that. i'm limited sql functions , perchance jcl).

i thought had solution using recursive udf around lack of command functions, that's not allowed either.

sql db2 hex zos

google maps - a custom marker for each type of place -



google maps - a custom marker for each type of place -

i want create map shows hotspots.

a bit illustration does: google maps example

for illustration i'm going on holiday , want know nearest supermarket, nightclubs , bars. want type in location , shows me these spots custom marker.

i can figure of out myself can't seem multiple custom markers in there.

the results returned placessearch contain multiple properties each result, 1 of them icon-property contains url of icon, e.g.:http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png

google-maps google-maps-api-3 google-places-api

ios8 - Location services not updating in background -



ios8 - Location services not updating in background -

for ios 8 have added next key plist:

nslocationalwaysusagedescription

i added:

// check ios 8 if ([_locationmanager respondstoselector:@selector(requestalwaysauthorization)]) { [_locationmanager requestalwaysauthorization]; }

i deleted app phone. upon launch prompted if ok run location services in background expected. click yes. while app running locations , location active icon in status bar.

however if leave app location active icon disappears status bar , no longer locations.

do need re setup location manager when app enters background? location manager property/variable need defined in appdelegate such never goes away?

you have set location updates in background modes of capabilities.

ios8 core-location

java ee - Avoiding timeout on container-managed EntityManager -



java ee - Avoiding timeout on container-managed EntityManager -

i have j2ee application beans have container-managed entitymanager's. in long running method calls, trying merge info throws

rollbackexception (timed out)

i have tried using entitymanagerfactory doesn't seem allowed:

cannot utilize entitytransaction while using jta

how can run arbitrarily long processes without setting unreasonable timeout? can't jta create new transaction when needed?

following comments question, question , documentation here, solved problem using container-managed entitymanager , transactionattributetype annotations.

the bean method caused timeout multiple calls different method handles subtask, such each method phone call executes within different transaction. utilize not_supported attribute type since:

if client not associated transaction, container not start new transaction before running method.

with arrangement, smaller processdoc method creates transactions shouldn't timeout.

public class mybean { @ejb private docsbean docsbean; /** * method transaction risks timeout * no transaction created not_supported */ @transactionattribute(transactionattributetype.not_supported) public void longrunning(list<document> docs) { (document doc : docs) { // different transaction used each element docsbean.processdoc(doc); } } } public class docsbean { /** runs within new transaction */ @transactionattribute(transactionattributetype.requires_new) public void processdoc(document document) { // takes time under timeout // ... } }

.

java-ee jpa ejb jta oc4j

IOS Parse - Pointer -



IOS Parse - Pointer -

i have class called subcategory column named category pointer. trying phone call , store pointer specific row. nil beingness stored self.categoryname.text? looking.

here code:

pfquery *query = [pfquery querywithclassname:@"subcategory"]; [query wherekey:@"user" equalto:[pfuser currentuser]]; [query wherekey:@"name" equalto:@"food"]; [query findobjectsinbackgroundwithblock:^(nsarray *objects, nserror *error) { (pfobject *object in objects) { self.subcategoryname.text = object[@"name"]; self.categoryname.text = object[@"category"]; } }];

use query this

[query wherekey:@"user" equalto:[pfuser currentuser]]; [query includekey:@"food"];

ios

How to delete the empty TAGS while publishing XML in Informatica Target -



How to delete the empty TAGS while publishing XML in Informatica Target -

i publishing xml informatica target , getting empty tags in published file. have treid below mentioned settings still empty tags coming. xml null content representation-> no tag xml empty string content representation->no tag xml null attribute representation->no attribute xml empty string attribute representation->no attribute , below mentioned custom properties writenullxmlfile=no;suppressnilcontentmethod=bytree;

i came across in kb. please check if applicable in case.

when attribute of element in mapping projected , not element itself, when null passed attribute, attribute suppressed. however, empty element tag still created in target xml filebecause, null content representation=no tag in effect when element projected.

solution

to suppress empty element tags, project these elements in mapping , pass null value

xml informatica informatica-powercenter