Contributive Sensitive Maps

  • 5 Replies
  • 3506 Views
*

Zero

  • Eve
  • ***********
  • 1287
Contributive Sensitive Maps
« on: April 04, 2022, 04:31:19 pm »
The evolution of the SMaps presented in the Postcard NoSQL thread is CSMaps.
SMap was about "sensing" when you set values. CSMap is the other way around: it adds an "acting when you get" values.
The idea is to "pull" computation: if you're getting values, it means you're curious about them, which means that work should be made around these values to enhance them, complete them, ...etc. It's exactly like focusing on something: when you direct your attention on something, you drive your "computations" on it.

The code is still super-small scale:

Code

// Contributive Sensitive Maps

class CSMap extends Map {

    sensors = {};
    contributors = {};

    constructor(content) {
        super();
        if (content)
            for (let [k, v] of content) this.set(k, v);
    }

    sense(id) {
        return this.sensors[id].solution;
    }

    removeContributor(id) {
        delete this.contributors[id];
    }

    contributor(id, parameters, mapper) {
        this.contributors[id] = { parameters, mapper };
    }

    removeSensor(id) {
        delete this.sensors[id];
    }

    sensor(id, initial, reducer) {
        this.sensors[id] = { reducer, solution: initial };
        this.forEach((value, key) => {
            this.sensors[id].solution =
                this.sensors[id].reducer(
                    this.sensors[id].solution,
                    key,
                    value
                )
        });
    }

    touch(key, previous) {
        for (let s in this.sensors)
            this.sensors[s].solution =
                this.sensors[s].reducer(
                    this.sensors[s].solution,
                    key,
                    super.get(key),
                    previous
                );
    }

    get(...args) {
        let result = super.get(...args);
        for (let c in this.contributors)
            this.contributors[c].mapper.call(
                this,
                args[0],
                result,
                this.contributors[c].parameters
            );
        return result;
    }

    set(...args) {
        let previous = super.get(args[0]);
        let result = super.set(...args);
        this.touch(args[0], previous);
        return result;
    }

    delete(...args) {
        let previous = super.get(args[0]);
        let result = super.delete(...args);
        this.touch(args[0], previous);
        return result;
    }
}


Example usage:

Code: text

let csmap = new CSMap();

csmap.set('i1', "foo");

csmap.set('i2', "bar");

csmap.sensor("string counter", 0, function (solution, key, newValue, oldValue) {

    if (typeof oldValue != "string" && typeof newValue == "string") ++solution;
    if (typeof oldValue == "string" && typeof newValue != "string") --solution;

    return solution;
})

csmap.sensor("string selector", new Set(), function (solution, key, newValue, oldValue) {

    if (typeof newValue == "string") solution.add(key);
    else solution.delete(key);

    return solution;
});

csmap.contributor("curious about numbers", { stuff: 55 }, function (key, value, parameters) {

    if (typeof value == "number")
        csmap.set("curious about", { what: key, myStuff: parameters.stuff });
});

csmap.set('i3', "baz");

console.log("counter:", csmap.sense("string counter"));

csmap.set('i3', 4);

console.log("counter:", csmap.sense("string counter"));
console.log("selector:", csmap.sense("string selector"));

console.log("getting i3:", csmap.get('i3'));

console.log("csmap:", csmap);

/* CONSOLE >>

    counter: 3
    counter: 2
    selector: Set(2) { 'i1', 'i2' }
    getting i3: 4
    csmap: CSMap(4) [Map] {
        'i1' => 'foo',
        'i2' => 'bar',
        'i3' => 4,
        'curious about' => { what: 'i3', myStuff: 55 },
        sensors: {
            'string counter': { reducer: [Function (anonymous)], solution: 2 },
            'string selector': { reducer: [Function (anonymous)], solution: [Set] }
        },
        contributors: {
            'curious about numbers': { parameters: [Object], mapper: [Function (anonymous)] }       
        }
    }
*/

*

MagnusWootton

  • Replicant
  • ********
  • 646
Re: Contributive Sensitive Maps
« Reply #1 on: April 04, 2022, 09:36:34 pm »
so are you "detecting" what the semantic of the variable is coming into the system via context?
Otherwise you couldn't "concentrate" the program on it... or am I way off the mark...

*

Zero

  • Eve
  • ***********
  • 1287
Re: Contributive Sensitive Maps
« Reply #2 on: April 05, 2022, 08:55:31 am »
In this scheme, "contributors" are meant to be minimal hooks executed on each read access. Variables are supposed to carry their own semantics (see Wild ontology). These hooks have parameters that can be modified at runtime.

The idea is to generate activity where values are interesting, that is, where you "get" values.

*

MagnusWootton

  • Replicant
  • ********
  • 646
Re: Contributive Sensitive Maps
« Reply #3 on: April 05, 2022, 09:08:04 am »
If you want to supply a variable which has a definite semantic,  it needs to what row its going into the database,   usually that's impossible for a computer to do by itself.     As far as I know you have to pre-know what it is,  you cant work it out afterwards.

*

Zero

  • Eve
  • ***********
  • 1287
Re: Contributive Sensitive Maps
« Reply #4 on: April 05, 2022, 09:29:16 am »
There's no row / no column, it's a NoSQL-style document store. Sorry I don't understand your reply.

*

Zero

  • Eve
  • ***********
  • 1287
Re: Contributive Sensitive Maps
« Reply #5 on: April 05, 2022, 11:39:24 am »
I think I'll build something along the lines of PLEXIL now, inside of CSMap, and through the IntentManager.

But first, I need linked data.
« Last Edit: April 05, 2022, 01:58:53 pm by Zero »

 


Requirements for functional equivalence to conscious processing?
by DaltonG (General AI Discussion)
November 19, 2024, 11:56:05 am
Will LLMs ever learn what is ... is?
by HS (Future of AI)
November 10, 2024, 06:28:10 pm
Who's the AI?
by frankinstien (Future of AI)
November 04, 2024, 05:45:05 am
Project Acuitas
by WriterOfMinds (General Project Discussion)
October 27, 2024, 09:17:10 pm
Ai improving AI
by infurl (AI Programming)
October 19, 2024, 03:43:29 am
Atronach's Eye
by WriterOfMinds (Home Made Robots)
October 13, 2024, 09:52:42 pm
Running local AI models
by spydaz (AI Programming)
October 07, 2024, 09:00:53 am
Hi IM BAA---AAACK!!
by MagnusWootton (Home Made Robots)
September 16, 2024, 09:49:10 pm
LLaMA2 Meta's chatbot released
by spydaz (AI News )
August 24, 2024, 02:58:36 pm
ollama and llama3
by spydaz (AI News )
August 24, 2024, 02:55:13 pm
AI controlled F-16, for real!
by frankinstien (AI News )
June 15, 2024, 05:40:28 am
Open AI GPT-4o - audio, vision, text combined reasoning
by MikeB (AI News )
May 14, 2024, 05:46:48 am
OpenAI Speech-to-Speech Reasoning Demo
by MikeB (AI News )
March 31, 2024, 01:00:53 pm
Say good-bye to GPUs...
by MikeB (AI News )
March 23, 2024, 09:23:52 am
Google Bard report
by ivan.moony (AI News )
February 14, 2024, 04:42:23 pm
Elon Musk's xAI Grok Chatbot
by MikeB (AI News )
December 11, 2023, 06:26:33 am

Users Online

344 Guests, 0 Users

Most Online Today: 532. Most Online Ever: 2369 (November 21, 2020, 04:08:13 pm)

Articles