source: coopr.pyomo/trunk/examples/pyomo/diet/README.txt @ 4517

Revision 4517, 3.2 KB checked in by tekl, 3 years ago (diff)

Add SQLite files for diet example

Line 
1========================================
2Using Pyomo on the classic diet problem.
3========================================
4
5The goal of this problem is to minimize cost while ensuring that the diet
6meets certain requirements. To fully illustrate the capabilities of Pyomo,
7two examples are given:
8
9* Diet 1 ensures a rounded meal (entree, side, and drink) for minimal cost.
10* Diet 2 maximizes nutritional value for minimal cost.
11
12A common data file is used for both diets; however, the models differ, and
13certain styles of model (e.g. using an Access database, written in AMPL) are
14only available for a certain diet. These availabilities are listed below:
15
16               | Diet1 | Diet2
17-----------------------------
18Pyomo / .dat   |   Y   |   Y
19 AMPL / .dat   |   N   |   Y
20Pyomo / .mdb   |   Y   |   N
21Pyomo /  SQL   |   Y   |   N
22Pyomo / SQLite |   Y   |   N
23
24======
25Diet 1
26======
27
28Diet 1 provides a model with certain hardcoded constraints: it requires the
29purchase of an entree (a sandwich of some kind), a side (either fries or a
30McMuffin), and a drink. It attempts to minimize the cost of purchasing this
31full meal.
32
33Optimal function value: 2.81
34
35Running with Pyomo
36------------------
37
38Files: diet1.py, diet.dat
39
40Run: pyomo diet1.py diet.dat
41
42Running with Pyomo and Access
43-----------------------------
44
45Files: diet1.py, diet.db.dat, diet.mdb
46
47Run: pyomo diet1.py diet.db.dat
48
49Notes: The diet.db.dat file is a Pyomo data command file that tells Pyomo
50       to import data from the Access database stored in diet.mdb.
51
52Running with Pyomo and MySQL
53----------------------------
54
55Files: diet1.py, diet.sql, diet1.sql.dat
56
57Run: mysql -D diet < diet.sql
58     pyomo diet1.py diet1.sql.dat
59
60Notes: The diet.sql file is a copy of diet.dat suitable for importing data
61       into a MySQL server. It will create the relevant tables; you must
62       provide access for the account 'coopr'@'localhost' (with password
63       'cooprpass') to the 'diet' database. In addition, your MySQL account
64       must have the ability to create tables in the 'diet' database, and
65       to insert values into those tables.
66
67Running with Pyomo and SQLite
68-----------------------------
69
70Files: diet1.py, diet.sqlite, diet1.sqlite.dat
71
72Run: pyomo diet1.py diet1.sqlite.dat
73
74Notes: The diet.sqlite file is a copy of diet.dat in the SQLite 3 format. It
75       contains identical data to the original .dat file and can be used
76       as-is with the built-in Python sqlite3 module. You must be running
77       Python 2.5 or newer, since sqlite3 was introduced into the Python
78       standard library with that version.
79
80======
81Diet 2
82======
83
84Diet 2 uses additional data about the nutritional value of each menu item
85in order to find the meal with the best nutrition while still minimizing
86cost.
87
88Optimal function value: 15.05
89
90Running with AMPL
91-----------------
92
93Files:
94
95  diet.dat
96  diet2.mod     - The AMPL model
97  diet2.ampl    - An AMPL script to solve the diet1 problem
98                  (This uses PICO, but other solvers could be used that
99                  can read in AMPL *.nl files.)
100
101Run: ampl diet2.ampl
102
103Notes: The directory containing the `cplex` executable must be in your
104       system's PATH environment variable.
105
106Running with Pyomo
107------------------
108
109Files: diet2.py, diet.dat
110
111Run: pyomo diet2.py diet.dat
Note: See TracBrowser for help on using the repository browser.