npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

choicelogics

v1.2.3

Published

This npm package provides a general framework for choice logics. It offers a flexible and extensible foundation for preference modeling and reasoning, encapsulating various choice logics, including Qualitative Choice Logic (QCL) and Conjunctive Choice Log

Readme

choicelogics

This Code is a practical implementation of Bernreiter, Michael, Jan Maly, and Stefan Woltran. "Choice logics and their computational properties." Artificial Intelligence 311 (2022): 103755 This npm package provides a general framework for choice logics. It offers a flexible and extensible foundation for preference modeling and reasoning, encapsulating various choice logics, including Qualitative Choice Logic (QCL) and Conjunctive Choice Logic (CCL), while allowing the definition of new ones.

Installation

To install the package, use npm:

npm install choicelogics

Usage

Importing the Module

import { QCCL, PropositionalLogic, ChoiceResult, normalizeChoiceResult, choiceResultToBool, boolToChoiceResult, validateChoiceResult } from "choicelogics";

Example

const a: ChoiceResult = { degree: 2, optionality: 1 };
const b: ChoiceResult = { degree: Infinity, optionality: 2 };

const result1 = QCCL.orderedDisjunction(a, b);
console.log(result1); // { degree: 2, optionality: 3 }

const result2 = PropositionalLogic.and(a, b);
console.log(result2); // { degree: Infinity, optionality: 2 }

const boolResult = choiceResultToBool(a);
console.log(boolResult); // true

const choiceResult = boolToChoiceResult(false);
console.log(choiceResult); // { degree: Infinity, optionality: 1 }

const isValid = validateChoiceResult(a);
console.log(a) // true

API

Classes

QCCL (Extends PropositionalLogic)

A combination of QCL and CCL

  • static orderedDisjunction(a: ChoiceResult, b: ChoiceResult): ChoiceResult
  • static orderedConjunction(a: ChoiceResult, b: ChoiceResult): ChoiceResult

PropositionalLogic

  • static and(a: ChoiceResult, b: ChoiceResult): ChoiceResult
  • static or(a: ChoiceResult, b: ChoiceResult): ChoiceResult
  • static negation(a: ChoiceResult): ChoiceResult

Types

ChoiceResult

type ChoiceResult = {
  degree: number;
  optionality: number;
};

ConnectiveFunction

type ConnectiveFunction = (a: ChoiceResult, b: ChoiceResult) => ChoiceResult;

ModifierFunction

type ModifierFunction = (a: ChoiceResult) => ChoiceResult;

ConnectMultipleFunction

type ConnectMultipleFunction = (...args: ChoiceResult[]) => ChoiceResult;

Util Functions

normalizeChoiceResult(result: ChoiceResult): ChoiceResult

boolToChoiceResult(value: boolean): ChoiceResult

choiceResultToBool(result: ChoiceResult): boolean

validateChoiceResult(result: ChoiceResult): boolean

Extending the Logic

You can extend the existing logic by inheriting from the provided classes and using the function types ConnectiveFunction, ModifierFunction, and ConnectMultipleFunction. Here is an example of how to create a new logic class by extending PropositionalLogic:

import { PropositionalLogic, ChoiceResult, ConnectiveFunction, ModifierFunction } from "choicelogics";

class CustomLogic extends PropositionalLogic {
  public static customOperation: ConnectiveFunction = (a, b) => {
    // Custom logic implementation
    return {
      degree: a.degree + b.degree,
      optionality: a.optionality * b.optionality,
    };
  };

  public static customModifier: ModifierFunction = (a) => {
    // Custom modifier logic
    return {
      degree: a.degree * 2,
      optionality: a.optionality * 2,
    };
  };
}

const a: ChoiceResult = { degree: 2, optionality: 1 };
const b: ChoiceResult = { degree: 3, optionality: 2 };

const result = CustomLogic.customOperation(a, b);
console.log(result); // { degree: 5, optionality: 2 }

const modifierResult = CustomLogic.customModifier(a);
console.log(negationResult); // { degree: 4, optionality: 2 }

License

This project is licensed under the ISC License.