Friday, January 18, 2013

Cooking functionally

I am not actually using functional programming in the kitchen :-)

I am re-writing my old cookingspace.com web app in Clojure with a new twist: the new web app will be an AI agent for planning recipes based on the food you have on-hand and based on a user's history, preferences, and the general mood they are in (food-wise). I have written some tools to convert my old relational database code for (more or less) static data (USDA nutrition information, recipes) to Clojure literal data.

Based on the type of food a user feels like cooking and what food they have on-hand, I need to transform recipes in an intelligent way to (hopefully!) also taste great after ingredients have substituted or morphed because a user would prefer a different type of sauce over a base recipe, etc., etc.

Anyway, working in Lisp and experimenting in a repl is making the entire process easier.

My wife and I are both very good cooks and we can make up super-tasty recipes on the fly with whatever ingredients we have on hand. I am betting on two things: I can automate our expertise and that people will enjoy using the system when it is finished.

9 comments:

Ivan Pierre said...

Very nice project idea ;)

Dmitri Sotnikov said...

Hi Mark,

I recently started a project for setting up default web application templates http://www.luminusweb.net/ it might come in handy, and I'm always open to suggestions and ideas.

The template simply provides a sane default configuration for a Ring/Compojure app. And I'm working on creating good documentation around using these libraries to save people from having to scour google to figure out basic things. :)

Franklin Chen said...

Sounds exciting! It's my turn to do the cooking at home tomorrow and my "method" for coming up with something tends to be to find out what we have on hand and then Google and then come up with something based on the search results and my own experience. Automation of some of the decision-making could definitely be useful.

Mark Watson, author and consultant said...

Thanks Ivan. Wish me luck!

grant rettke said...

I was thinking of doing something like this as a vehicle to learning a rules engine. Where does the AI part fit in beyond leveraging user's preferences and history? I mean does the system "learn" (by some open ended term) or???

Mark Watson, author and consultant said...

Hello Grant,

I am not using a rules engine, rather I am hard-coding rules for substituting ingredients based on what ingredients taste good together.

I am breaking recipes up into ingredient and directions "chunks."

I may end up writing my own case based reasoning engine - not sure, really - just getting started.

Mark Watson, author and consultant said...

re: "I may end up writing my own case based reasoning engine - not sure, really - just getting started."

if you read the literature for AI recipe agents (e.g., Chef) they handled narrow domains. I am trying to handle all general types of recipes, so I believe that I have chosen a difficult problem!

Vincent Murphy said...

It may be useful to model recipes as projects are modelled in project management. This way you can break a recipe down starting with the set of deliverables at the end (plates of food ready to serve), which is then decomposed in to the work required to deliver them. Subject to the capacity constraints of your kitchen, you want everything for a course to arrive at the same time, so it may be amenable to reverse scheduling.

Using this modelling approach, it may be possible to use the more visual presentations (e.g. adapted Gantt chart, musical notation) instead of prose.

A valuable feature would be to scale ingredient quantities for serving a different size party to that used in the original recipe, and to provide useful conversions between weight and volume for common ingredient densities and measurement units.

The ingredients knowledge base could be derived from a semantic wiki.

Mark Watson, author and consultant said...

Thanks Vincent - good ideas, and sort of what I have in mind.

If this all works out well I will either write a series of blog articles on the back end tech, or perhaps even a short book. First though, I need to finish the project :-)