Coder Social home page Coder Social logo

rpl's Introduction

#Experiments

A collection of namespaces that allow for REPL exploration of a variety of interesting topics

Setup

This "project" is really just a collection of disjoint namespaces, each intended to explore a single Clojure library or topic. As such, there is no notion of "running" the project. It is designed to work only from the REPL.

Configuring a REPL using Cursive

Use Edit Configurations... to create a run configuration. The click the + button to Add New Configuration. Select Clojure REPL and the Local.

In the right-hand panel, give the configuration a name, select nREPL and Run with Deps. Click Ok to save and close th Configuration panel.

Now you can start the REPL using the run VCR control button and after a few seconds a shiny new REPL will be started and ready for use.

Evaluating Code

By default, Cursive will automatically in-ns the namespace as you switch files in the editor. Just be sure to evaluate the namespace for itself to be sure the namespace is available in the REPL.

Crux

hello.clj provides a playground for experimenting with Crux.

space_port.clj follows the Crux tutorial found here

Resource Allocation

One of our early tasks was to develop a demonstration of "Open Channel Planning." Setting aside for a moment, exactly what that phrase means, we can say that it is fundamentally a "resource allocation" problem. We have a constrained resource (channel) and we have "requestors" who would like to use it. The problem then is:

How do we allocate this resource to make all the requestors happy?

(see allocation-try-2.clj)

Let's start with the information model of the resource itself. To keep things as simple as possible, both to get going and to have a solid foundation for enhancements, we will model "channels" as s Clojure vector of abstract fixed-unit "slots":

[slot-1 slot 2 slot3]

If we view the slots as the X-axis then we can model Time as the Y-axis using another vector of the first:

  [[slot-1 slot-2 slot-3]
   [slot-4 slot-5 slot-6]
   [slot-7 slot-8 slot-9]]

Pretty simple. To handle the allocation, we will put a marker into each slot to show which request is using it:

  [[:a   :b    _]
   [ _    _    _]
   [ _    _    _]]

We'll actually make each slot hold a Clojure set of the request IDs:

  [[#{:a} #{:b}  #{  }]
   [#{  } #{  }  #{  }]
   [#{  } #{  }  #{  }]]

Using sets makes this much easier, since we can take advantage of the (disj...) function to remove unwanted IDs if we need to (and we need to).

Constraints Programming

Now that we have a basic information model for our resources, we can start to expand to bring it closer to how we might want to use it in the real world.

For example, currently, the allocation model expects each request to specify exactly which resources it wants to use, both the channel and the time-slot. This isn't very flexible. What if the requestor didn't care which channel it got, just that it got some channel at the needed times?

This is where Constraint Programming comes in. What if we could express the requests as a range of options each rquestor could accept and let the computer figure out how to satisfy them all?

For this experiment, we will use the loco library, by Alex Engleberg. loco is a declarative, functional wrapper around the Choco Java library (See the advantages of being hosted?)

Excel Programming

excel_play.clj provides a playground to work with docjure

Oz

simple_oz.clj is a REPL-based playgorund for Oz

rpl's People

Contributors

cawasser avatar

Watchers

 avatar

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.