Giter Club home page Giter Club logo

Comments (8)

steverob avatar steverob commented on June 14, 2024

This could be the facts -

engine << [ "CompanyA", "offers", "serviceA" ]
engine << [ "CompanyB", "offers", "serviceB" ]
engine << [ "CompanyA", "offers", "serviceB" ]
engine << [ "CompanyB", "offers", "serviceC" ]
engine << [ "IncidentA", "requires", "serviceC" ]
engine << [ "IncidentA", "requires", "serviceA" ]

from wongi-engine.

ulfurinn avatar ulfurinn commented on June 14, 2024

One way of doing it:

q = engine.query( "demo" ) {
  search_on :Incident
  forall {
    has :Incident, "requires", :Service
    has :Company, "offers", :Service
  }
}

engine.execute "demo", Incident: "IncidentA"
q.tokens.each do |token|
  puts token[:Company]
end

from wongi-engine.

ulfurinn avatar ulfurinn commented on June 14, 2024

Or do you mean that a single company should satisfy all requirements?

from wongi-engine.

steverob avatar steverob commented on June 14, 2024

Thanks @ulfurinn. yes that's exactly it. It should satisfy all requirements i.e we need companies that offer all the services required by the Incident. Would love a pointer as to how I can do that :)

from wongi-engine.

ulfurinn avatar ulfurinn commented on June 14, 2024

In that case:

engine.query( "demo" ) {
  search_on :Incident
  forall {
    has :Incident, "requires", :Service
    has :Company, "offers", :Service
    none {
      has :Incident, "requires", :OtherService
      neg :Company, "offers", :OtherService
    }
  }
}

Translated back into English, "if a company offers one of the services, there do not exist any other services that are required but not offered by the same company".

from wongi-engine.

steverob avatar steverob commented on June 14, 2024

Wow. That's awesome man. Thanks for this 👍

from wongi-engine.

steverob avatar steverob commented on June 14, 2024

@ulfurinn I understand now how to write these rules. But I still cant understand how I can use Rails models in place of these strings (services, incidents & companies). Do I just use a string representation of the model - like service_#{service.id}?

Are there any best practices to load the facts into the engine? Initializing the engine in the app, etc.

from wongi-engine.

ulfurinn avatar ulfurinn commented on June 14, 2024

Any Ruby value with a sane implementation of operator == can be used inside fact triples, expect symbols with special meanings.

from wongi-engine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.