Multi-Variable, Multi-Dimensional Searches
Hi,
Below is an example of the use of the GRAPH built-in. A very handy function when you want to search some multi-dimensional space (In the example below I've used holiday selection with 3 search criteria/dimensions) with a range of values (an OR of values).
Obviously easily extendable to as many dimensions as you like. Even with as low a number as 5 dimensions alternative approaches that don't use GRAPH start to look very messy.
YouTube Video explaining GRAPH: https://youtu.be/O8L83FxAa6s
Yours
Allan
Below is an example of the use of the GRAPH built-in. A very handy function when you want to search some multi-dimensional space (In the example below I've used holiday selection with 3 search criteria/dimensions) with a range of values (an OR of values).
- Code: Select all
d := DATASET([{'A',1,100,0}
,{'B',2,200,0}
,{'C',2,200,2000}
,{'D',2,100,2000}
,{'E',2,100,0}
,{'F',3,200,0}
,{'G',3,200,2000}
,{'H',3,100,2000}
,{'I',3,100,0}
,{'J',3,300,0}
,{'K',3,300,3000}
,{'L',3,100,3000}
,{'M',3,100,0}
],{STRING1 Holiday;UNSIGNED TourOperator,UNSIGNED Price,UNSIGNED HolidayClass});
Select(SET OF UNSIGNED pTourOperator = [],SET OF UNSIGNED pPrice = [],SET OF UNSIGNED pHolidayClass = []) := FUNCTION
DFilters:= [DATASET(pTourOperator,{UNSIGNED itm}),DATASET(pPrice,{UNSIGNED itm}),DATASET(pHolidayClass,{UNSIGNED itm})];
RunFilter(SET OF DATASET(RECORDOF(d)) ds,UNSIGNED c) := FUNCTION
j := JOIN(ds[c-1],DFilters[c],CASE(C, 1 => LEFT.TourOperator = RIGHT.itm
, 2 => LEFT.Price = RIGHT.itm
, LEFT.HolidayClass = RIGHT.itm),TRANSFORM(LEFT),ALL);
RETURN IF(EXISTS(DFilters[c]),j,ds[c-1]);
END;
RETURN GRAPH(d,3,RunFilter(ROWSET(LEFT),COUNTER));
END;
Select(,,);
Select([3],,[3000,0]);
Select(,[100],[3000,0]);
Obviously easily extendable to as many dimensions as you like. Even with as low a number as 5 dimensions alternative approaches that don't use GRAPH start to look very messy.
YouTube Video explaining GRAPH: https://youtu.be/O8L83FxAa6s
Yours
Allan
- Allan
- Posts: 444
- Joined: Sat Oct 01, 2011 7:26 pm
1 post
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest