Giter Site home page Giter Site logo

silky / penrose Goto Github PK

View Code? Open in Web Editor NEW

This project forked from penrose/penrose

0.0 2.0 0.0 252.07 MB

a system to automatically visualize mathematics

Home Page: https://www.cs.cmu.edu/~kqy/resources/diagrams_obt.pdf

TeX 3.61% Haskell 96.39%

penrose's Introduction

Penrose

Note: this README is obsolete!

TODO: redocument the code after the dust settles.

Directories

optimization contains the code I'm currently working on, as well as GIFs. layout.hs contains the cleaned-up and commented code. The rest of the files contain irrelevant code relating to the autodiff library.

constraint-code contains the old code for the set theory DSL and simple constraint satisfaction.

documentation only contains the system diagram in Keynote.

byhand contains diagrams made by hand, e.g. in Keynote.


More information

I use the [gloss library]( I use the following library for the graphics/animation/input: https://hackage.haskell.org/package/gloss-1.10.2.3/docs/Graphics-Gloss-Interface-Pure-Game.html) to handle graphics, animation, and user input.

Functionality of the current code:

  • gradient-descent-based layout
  • with backtracking line search
  • for sets only
  • with very simple objective functions provided (e.g. centering)
  • where the layout is animated and interactive (v. useful for debugging)

Pressing limitations:

  • need to add autodiff
  • need to debug line search and add Wolfe condition
  • does not handle arbitrary numbers of objects
  • does not handle labels, points, boxes, or maps (labels were handled at one point, but I removed the functionality)
  • needs more objective functions to handle other cases
  • needs to generalize to sums of objective functions and ones with arbitrary numbers of parameters, including object size
  • need a better debugging interface for optimization, e.g. live parameter tuning

Parameters:

  • picWidth, picHeight: canvas dimensions
  • stepFlag: turns stepping the simulation on and off for debugging (no stepping = objects don't move)
  • clampFlag: turns clamping gradient values on and off for debugging
  • debug: turns on/off the debug print functions
  • constraintFlag: turns constraint satisfaction on/off (currently off because we're doing unconstrained optimization)
  • objFn1: objective function to use
  • btls: turn on/off the backtracking line search for debugging (off = use a fixed timestep specified in the code)
  • alpha and beta: parameters for the backtracking line search (see code for a more detailed description)
  • stopEps: stopping condition sensitivity for gradient descent. Stop when magnitude of gradient is less than stopEps.

Debugging:

  • Use the flags above.
  • I also use ghci, the Haskell REPL. To load the file, do :l filename.hs. To import a library, paste in the normal import statement. To declare something, start with a let statement, e.g. let x = 5.
  • For printing internal values, I use the Debug.Trace library.

Usage for current code

Compile: ghc layout.hs

Install any relevant packages: cabal install $PACKAGE_NAME (though I'm told the Haskell community has moved on to the better stack package manager?)

Run: ./layout.hs

Pressing the R key will resample the configuration. You can also click and drag the objects. The object on top is semi-arbitrary, decided by the order of the objects in the internal list.


Usage for old code

Compile: ghc settheory.hs

Create SVG: ./settheory -w 500 -h 500 -o set.svg (The parameters are the width and height of the rendered picture.)

Open SVG: chrome set.svg

penrose's People

Watchers

 avatar  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.