lpsolve 5.5.10.i

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,107 @@
1
+ #!/bin/sh
2
+ # $Id: run_doxygen,v 1.1 2003/11/09 14:11:02 rocky Exp $
3
+
4
+ # Runs doxygen and massages the output files.
5
+ # Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
6
+ #
7
+ # Synopsis: run_doxygen --mode=[user|maint|man] v3srcdir v3builddir
8
+ #
9
+ # Originally hacked together by Phil Edwards <pme@gcc.gnu.org>
10
+
11
+
12
+ # We can check now that the version of doxygen is >= this variable.
13
+ DOXYVER=1.2.15
14
+ doxygen=
15
+
16
+ find_doxygen() {
17
+ v_required=`echo $DOXYVER | \
18
+ awk -F. '{if(NF<3)$3=0;print ($1*100+$2)*100+$3}'`
19
+ testing_version=
20
+ # thank you goat book
21
+ set `IFS=:; X="$PATH:/usr/local/bin:/bin:/usr/bin"; echo $X`
22
+ for dir
23
+ do
24
+ # AC_EXEEXT could come in useful here
25
+ maybedoxy="$dir/doxygen"
26
+ test -f "$maybedoxy" && testing_version=`$maybedoxy --version`
27
+ if test -n "$testing_version"; then
28
+ v_found=`echo $testing_version | \
29
+ awk -F. '{if(NF<3)$3=0;print ($1*100+$2)*100+$3}'`
30
+ if test $v_found -ge $v_required; then
31
+ doxygen="$maybedoxy"
32
+ break
33
+ fi
34
+ fi
35
+ done
36
+ if test -z "$doxygen"; then
37
+ echo run_doxygen error: Could not find Doxygen $DOXYVER in path. 1>&2
38
+ print_usage
39
+ fi
40
+ }
41
+
42
+ print_usage() {
43
+ cat 1>&2 <<EOF
44
+ Usage: run_doxygen --mode=MODE [<options>] <v3-src-dir> <v3-build-dir>
45
+ MODE is one of:
46
+ user Generate user-level HTML library documentation.
47
+ maint Generate maintainers' HTML documentation (lots more;
48
+ exposes non-public members, etc).
49
+ man Generate user-level man pages.
50
+
51
+ more options when i think of them
52
+
53
+ Note: Requires Doxygen ${DOXYVER} or later; get it at
54
+ ftp://ftp.stack.nl/pub/users/dimitri/doxygen-${DOXYVER}.src.tar.gz
55
+
56
+ EOF
57
+ exit 1
58
+ }
59
+
60
+ parse_options() {
61
+ for o
62
+ do
63
+ # Blatantly ripped from autoconf, er, I mean, "gratefully standing
64
+ # on the shoulders of those giants who have gone before us."
65
+ case "$o" in
66
+ -*=*) arg=`echo "$o" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
67
+ *) arg= ;;
68
+ esac
69
+
70
+ case "$o" in
71
+ --mode=*)
72
+ mode=$arg ;;
73
+ --mode | --help | -h)
74
+ print_usage ;;
75
+ *)
76
+ # this turned out to be a mess, maybe change to --srcdir=, etc
77
+ if test $srcdir = unset; then
78
+ srcdir=$o
79
+ elif test $outdir = unset; then
80
+ builddir=${o}
81
+ outdir=${o}/doc/doxygen
82
+ else
83
+ echo run_doxygen error: Too many arguments 1>&2
84
+ exit 1
85
+ fi
86
+ ;;
87
+ esac
88
+ done
89
+ }
90
+
91
+
92
+ # script begins here
93
+ mode=unset
94
+ srcdir=unset
95
+ outdir=unset
96
+ do_html=no
97
+ do_man=no
98
+ enabled_sections=
99
+ DATEtext=`date '+%Y-%m-%d'`
100
+
101
+ parse_options $*
102
+ find_doxygen
103
+ $doxygen ./Doxyfile
104
+
105
+ exit 0
106
+
107
+ # vim:ts=4:et:
@@ -0,0 +1,29 @@
1
+ print routine: don't show 0's in as coefficients. Show SOS sets
2
+ Don't show anything if no columns.
3
+
4
+ Automatically adjust width of 1st column, row names, based on the
5
+ width of the longest row name.
6
+
7
+ is_debug:
8
+ ---------
9
+ mend -> meant.
10
+
11
+ get_solutioncount
12
+ algoritm -> algorithm
13
+
14
+ SOS.html:
15
+ ---------
16
+
17
+ In SOS example
18
+
19
+ sos
20
+ SOS: x1,x2,x3,x4,x5 <= 2;
21
+
22
+ Can't deal with <=2. Use instead:
23
+
24
+ sos2
25
+ sos: x1,x2,x3,x4,x5;
26
+
27
+ is_SOS_var:
28
+ ----------
29
+ Small wording things. should for must.
@@ -0,0 +1,8 @@
1
+ require "rubygems"
2
+ Mypath = File.expand_path(File.dirname(__FILE__))
3
+ old_dir = File.expand_path(Dir.pwd)
4
+ if old_dir != Mypath
5
+ Dir.chdir(Mypath)
6
+ end
7
+ $: << Mypath + '/../ext'
8
+ require "lpsolve"
@@ -0,0 +1,223 @@
1
+ #!/usr/bin/env ruby
2
+ # $Id: demo.rb,v 1.7 2007/03/28 02:11:59 rocky Exp $
3
+ require "rubygems"
4
+ require 'highline/import'
5
+
6
+ Mypath = File.expand_path(File.dirname(__FILE__))
7
+ old_dir = File.expand_path(Dir.pwd)
8
+ if old_dir != Mypath
9
+ Dir.chdir(Mypath)
10
+ end
11
+ $: << Mypath + '/../ext'
12
+ require "lpsolve"
13
+
14
+ def press_ret
15
+ ask("[return]") { |q| q.echo = true }
16
+ end
17
+
18
+ def error()
19
+ STDERR.print "Error\n"
20
+ exit 1
21
+ end
22
+
23
+ lp = LPSolve.new(0, 4)
24
+
25
+ Vers=lp.version
26
+ Vers_str = "%d.%d.%d.%d" % Vers
27
+ puts "lp_solve %s demo\n\n" % Vers_str
28
+
29
+ if not lp
30
+ error
31
+ end
32
+
33
+ puts "This demo will show most of the features of lp_solve %s" % Vers_str
34
+ press_ret
35
+ puts "We start by creating a new problem with 4 variables and 0 constraints"
36
+ puts "We use: lp=make_lp(0,4);"
37
+ press_ret
38
+
39
+ puts "We can show the current problem with print_lp(lp)"
40
+ lp.print_lp
41
+ press_ret
42
+
43
+ puts "Now we add some constraints"
44
+ puts "str_add_constraint(lp, \"3 2 2 1\" ,LE,4)"
45
+ puts "This is the string version of add_constraint. For the normal version"
46
+ puts "of add_constraint see the help file"
47
+
48
+ if not lp.str_add_constraint("3 2 2 1", LPSolve::LE, 4)
49
+ puts "Error in adding constraint"
50
+ error
51
+ end
52
+
53
+ lp.print_lp()
54
+ press_ret
55
+
56
+ puts "str_add_constraint(lp, \"0 4 3 1\" ,GE,3)"
57
+ if not lp.str_add_constraint("0 4 3 1", LPSolve::GE, 3)
58
+ puts "Error in adding constraint"
59
+ error
60
+ end
61
+ lp.print_lp()
62
+ press_ret
63
+
64
+ puts "Set the objective function"
65
+ puts "str_set_obj_fn(lp, \"2 3 -2 3\")"
66
+ if not lp.str_set_obj_fn("2 3 -2 3")
67
+ puts "Error in setting objective function"
68
+ error
69
+ end
70
+ lp.print_lp()
71
+ press_ret
72
+
73
+ puts "Now solve the problem with printf(solve(lp));"
74
+ solution = lp.solve
75
+ puts "%d" % solution
76
+ press_ret
77
+
78
+ puts "The value is 0, this means we found an optimal solution"
79
+ puts "We can display this solution with print_objective(lp) and print_solution(lp)"
80
+
81
+ lp.print_objective
82
+ lp.print_solution(1)
83
+ lp.print_constraints(1)
84
+ press_ret
85
+
86
+ puts "The dual variables of the solution are printed with"
87
+ puts "print_duals(lp);"
88
+ lp.print_duals()
89
+ press_ret
90
+
91
+ puts "We can change a single element in the matrix with"
92
+ puts "set_mat(lp,2,1,0.5)"
93
+
94
+ if (!lp.set_mat(2,1,0.5))
95
+ error
96
+ end
97
+
98
+ lp.print_lp
99
+ press_ret
100
+ puts "If we want to maximize the objective function use set_maxim(lp);"
101
+ lp.set_maxim
102
+ lp.print_lp
103
+ press_ret
104
+ puts "after solving this gives us:\n"
105
+ lp.solve
106
+ lp.print_objective
107
+ lp.print_solution(1)
108
+ lp.print_constraints(1)
109
+ lp.print_duals
110
+ press_ret
111
+ puts "Change the value of a rhs element with set_rh(lp,1,7.45)"
112
+ lp.set_rh(1,7.45)
113
+ lp.print_lp
114
+ lp.solve
115
+ lp.print_objective
116
+ lp.print_solution(1)
117
+ lp.print_constraints(1)
118
+ press_ret
119
+ puts "We change %s to the integer type with" % lp.get_col_name(4)
120
+ puts "set_int(lp, 4, TRUE)"
121
+ lp.set_int(4, true)
122
+ lp.print_lp
123
+ puts "We set branch & bound debugging on with set_debug(lp, TRUE)"
124
+ lp.set_debug(true)
125
+ puts "and solve..."
126
+ press_ret()
127
+ lp.solve
128
+ lp.print_objective
129
+ lp.print_solution(1)
130
+ lp.print_constraints(1)
131
+ press_ret()
132
+ puts "We can set bounds on the variables with"
133
+ puts "set_lowbo(lp,2,2); & set_upbo(lp,4,5.3)"
134
+ lp.set_lowbo(2,2)
135
+ lp.set_upbo(4,5.3)
136
+ lp.print_lp
137
+ press_ret
138
+ lp.solve
139
+ lp.print_objective
140
+ lp.print_solution(1)
141
+ lp.print_constraints(1)
142
+ press_ret
143
+ puts "Now remove a constraint with del_constraint(lp, 1)"
144
+ lp.del_constraint(1)
145
+ lp.print_lp
146
+ puts ("Add an equality constraint")
147
+ if not lp.str_add_constraint("1 2 1 4", LPSolve::EQ, 8)
148
+ error()
149
+ end
150
+ lp.print_lp
151
+ press_ret
152
+ printf("A column can be added with:\n")
153
+ printf("str_add_column(lp,\"3 2 2\");\n")
154
+ if (not lp.str_add_column("3 2 2"))
155
+ error
156
+ end
157
+ lp.print_lp
158
+ press_ret
159
+ printf("A column can be removed with:\n");
160
+ printf("del_column(lp,3);\n");
161
+ lp.del_column(3)
162
+ lp.print_lp
163
+ press_ret
164
+ printf("We can use automatic scaling with:\n")
165
+ printf("set_scaling(lp, SCALE_MEAN);\n")
166
+ lp.set_scaling(LPSolve::SCALE_MEAN)
167
+ lp.print_lp
168
+ press_ret
169
+
170
+ printf("The function get_mat(lprec *lp, int row, int column) returns a single\n");
171
+ printf("matrix element\n");
172
+ printf("%s get_mat(lp,2,3), get_mat(lp,1,1); gives\n","printf(\"%f %f\\n\",");
173
+ printf("%f %f\n", lp.get_mat(2,3), lp.get_mat(1,1));
174
+ printf("Notice that get_mat returns the value of the original unscaled problem\n");
175
+ press_ret();
176
+ printf("If there are any integer type variables, then only the rows are scaled\n");
177
+ printf("set_int(lp,3,FALSE);\n");
178
+ printf("set_scaling(lp, SCALE_MEAN);\n");
179
+ lp.set_scaling(LPSolve::SCALE_MEAN);
180
+ lp.set_int(3,FALSE);
181
+ lp.print_lp
182
+ press_ret
183
+ lp.solve
184
+ printf("print_objective, print_solution gives the solution to the original problem\n");
185
+ lp.print_objective
186
+ lp.print_solution(1);
187
+ lp.print_constraints(1);
188
+ press_ret
189
+
190
+ printf("Scaling is turned off with unscale(lp);\n");
191
+ lp.unscale;
192
+ lp.print_lp
193
+ press_ret();
194
+ printf("Now turn B&B debugging off and simplex tracing on with\n");
195
+ printf("set_debug(lp, FALSE), set_trace(lp, TRUE) and solve(lp)\n");
196
+ lp.set_debug(FALSE);
197
+ lp.set_trace(TRUE);
198
+ press_ret();
199
+ lp.solve
200
+
201
+ printf("Where possible, lp_solve will start at the last found basis\n");
202
+ printf("We can reset the problem to the initial basis with\n");
203
+ printf("default_basis(lp). Now solve it again...\n");
204
+ press_ret();
205
+ lp.default_basis
206
+ lp.solve
207
+
208
+ printf("It is possible to give variables and constraints names\n");
209
+ printf("set_row_name(lp,1,\"speed\"); & set_col_name(lp,2,\"money\")\n");
210
+ if (not lp.set_row_name(1,"speed"))
211
+ error();
212
+ end
213
+ if (!lp.set_col_name(2,"money"))
214
+ error();
215
+ end
216
+ lp.print_lp
217
+ printf("As you can see, all column and rows are assigned default names\n");
218
+ printf("If a column or constraint is deleted, the names shift place also:\n");
219
+ press_ret();
220
+ printf("del_column(lp,1);\n");
221
+ lp.del_column(1);
222
+ lp.print_lp
223
+ press_ret();
@@ -0,0 +1,9 @@
1
+ /* Objective function */
2
+ Maximize: +3 money +3 C3 +3 C4;
3
+
4
+ speed: +4 money +C3 +2 C4 >= 3;
5
+ +2 money +4 C3 +2 C4 = 8;
6
+
7
+ /* Variable bounds */
8
+ money >= 2;
9
+ C3 <= 5.3;
@@ -0,0 +1,25 @@
1
+ *<meta creator='lp_solve v5.5'>
2
+ *<meta rows=2>
3
+ *<meta columns=3>
4
+ *<meta equalities=1>
5
+ *<meta integers=0>
6
+ *<meta origsense='MAX'>
7
+ *
8
+ NAME
9
+ ROWS
10
+ N R0
11
+ G speed
12
+ E R2
13
+ COLUMNS
14
+ money R0 -3.000000000 speed 4.0000000000
15
+ money R2 2.0000000000
16
+ C3 R0 -3.000000000 speed 1.0000000000
17
+ C3 R2 4.0000000000
18
+ C4 R0 -3.000000000 speed 2.0000000000
19
+ C4 R2 2.0000000000
20
+ RHS
21
+ RHS speed 3.0000000000 R2 8.0000000000
22
+ BOUNDS
23
+ LO BND money 2.0000000000
24
+ UP BND C3 5.3000000000
25
+ ENDATA
@@ -0,0 +1,8 @@
1
+ /* model.lp */
2
+
3
+ max: 143 x + 60 y;
4
+
5
+ 120 x + 210 y <= 15000;
6
+ 110 x + 30 y <= 4000;
7
+ x + y <= 75;
8
+
@@ -0,0 +1,16 @@
1
+ * model.mps
2
+ NAME
3
+ ROWS
4
+ N R0
5
+ L R1
6
+ L R2
7
+ L R3
8
+ COLUMNS
9
+ x R0 143.00000000 R1 120.00000000
10
+ x R2 110.00000000 R3 1.0000000000
11
+ y R0 60.00000000 R1 210.00000000
12
+ y R2 30.000000000 R3 1.0000000000
13
+ RHS
14
+ RHS R1 15000.000000 R2 4000.0000000
15
+ RHS R3 75.000000000
16
+ ENDATA
@@ -0,0 +1,215 @@
1
+ #!/usr/bin/env ruby
2
+ # $Id: demo.rb,v 1.7 2007/03/28 02:11:59 rocky Exp $
3
+ require "rubygems"
4
+ require 'highline/import'
5
+
6
+ Mypath = File.expand_path(File.dirname(__FILE__))
7
+ old_dir = File.expand_path(Dir.pwd)
8
+ if old_dir != Mypath
9
+ Dir.chdir(Mypath)
10
+ end
11
+ $: << Mypath + '/../ext'
12
+ require "lpsolve"
13
+
14
+ def press_ret
15
+ ask("[return]") { |q| q.echo = true }
16
+ end
17
+
18
+ def error()
19
+ STDERR.print "Error\n"
20
+ exit 1
21
+ end
22
+
23
+ Vers=LPsolve::version
24
+ Vers_str = "%d.%d.%d.%d" % Vers
25
+ puts "lp_solve %s demo\n" % Vers_str
26
+
27
+ puts "This demo will show most of the features of lp_solve %s" % Vers_str
28
+ press_ret
29
+ puts "We start by creating a new problem with 4 variables and 0 constraints"
30
+ puts "We use: lp = LPSolve.new(0,4)"
31
+ lp = LPSolve.new(0, 4)
32
+ error if not lp
33
+ press_ret
34
+
35
+ puts "We can show the current problem with lp.print_lp"
36
+ lp.print_lp
37
+ press_ret
38
+
39
+ puts "Now we add some constraints"
40
+ puts 'lp.str_add_constraint("3 2 2 1", LPSolve::LE, 4)'
41
+ puts "This is the string version of add_constraint. For the normal version"
42
+ puts "of add_constraint see the help file"
43
+
44
+ if not lp.str_add_constraint("3 2 2 1", LPSolve::LE, 4)
45
+ puts "Error in adding constraint"
46
+ error
47
+ end
48
+
49
+ lp.print_lp()
50
+ press_ret
51
+
52
+ puts 'lp.str_add_constraint("0 4 3 1\" ,GE,3)'
53
+ if not lp.str_add_constraint("0 4 3 1", LPSolve::GE, 3)
54
+ puts "Error in adding constraint"
55
+ error
56
+ end
57
+ lp.print_lp()
58
+ press_ret
59
+
60
+ puts "Set the objective function"
61
+ puts 'lp.str_set_obj_fn("2 3 -2 3")'
62
+ if not lp.str_set_obj_fn("2 3 -2 3")
63
+ puts "Error in setting objective function"
64
+ error
65
+ end
66
+ lp.print_lp()
67
+ press_ret
68
+
69
+ puts "Now solve the problem with lp.solve;"
70
+ solution = lp.solve
71
+ puts "%d" % solution
72
+ press_ret
73
+
74
+ puts "The value is 0, this means we found an optimal solution"
75
+ puts "We can display this solution with lp.print_objective and lp.print_solution"
76
+
77
+ lp.print_objective
78
+ lp.print_solution(1)
79
+ lp.print_constraints(1)
80
+ press_ret
81
+
82
+ puts "The dual variables of the solution are printed with"
83
+ puts "lp.print_duals"
84
+ lp.print_duals()
85
+ press_ret
86
+
87
+ puts "We can change a single element in the matrix with"
88
+ puts "lp.set_mat(2,1,0.5)"
89
+
90
+ error if not lp.set_mat(2,1,0.5)
91
+
92
+ lp.print_lp
93
+ press_ret
94
+ puts "If we want to maximize the objective function use lp.set_maxim"
95
+ lp.set_maxim
96
+ lp.print_lp
97
+ press_ret
98
+ puts "after solving this gives us:\n"
99
+ lp.solve
100
+ lp.print_objective
101
+ lp.print_solution(1)
102
+ lp.print_constraints(1)
103
+ lp.print_duals
104
+ press_ret
105
+ puts "Change the value of a rhs element with set_rh(lp,1,7.45)"
106
+ lp.set_rh(1,7.45)
107
+ lp.print_lp
108
+ lp.solve
109
+ lp.print_objective
110
+ lp.print_solution(1)
111
+ lp.print_constraints(1)
112
+ press_ret
113
+ puts "We change %s to the integer type with" % lp.get_col_name(4)
114
+ puts "lp.set_int(4, TRUE)"
115
+ lp.set_int(4, true)
116
+ lp.print_lp
117
+ puts "We set branch & bound debugging on with lp.set_debug(TRUE)"
118
+ lp.set_debug(true)
119
+ puts "and solve..."
120
+ press_ret()
121
+ lp.solve
122
+ lp.print_objective
123
+ lp.print_solution(1)
124
+ lp.print_constraints(1)
125
+ press_ret()
126
+ puts "We can set bounds on the variables with"
127
+ puts "lp.set_lowbo(2,2); & lp.set_upbo(4,5.3)"
128
+ lp.set_lowbo(2,2)
129
+ lp.set_upbo(4,5.3)
130
+ lp.print_lp
131
+ press_ret
132
+ lp.solve
133
+ lp.print_objective
134
+ lp.print_solution(1)
135
+ lp.print_constraints(1)
136
+ press_ret
137
+ puts "Now remove a constraint with lp.del_constraint(1)"
138
+ lp.del_constraint(1)
139
+ lp.print_lp
140
+ puts ("Add an equality constraint")
141
+ if not lp.str_add_constraint("1 2 1 4", LPSolve::EQ, 8)
142
+ error()
143
+ end
144
+ lp.print_lp
145
+ press_ret
146
+ puts "A column can be added with:"
147
+ puts 'lp.str_add_column("3 2 2")'
148
+ error if not lp.str_add_column("3 2 2")
149
+ lp.print_lp
150
+ press_ret
151
+ puts "A column can be removed with:"
152
+ puts "del_column(lp,3)"
153
+ lp.del_column(3)
154
+ lp.print_lp
155
+ press_ret
156
+ puts "We can use automatic scaling with:"
157
+ puts "lp.scaling = LPSolve::SCALE_MEAN"
158
+ lp.scaling = LPSolve::SCALE_MEAN
159
+ lp.print_lp
160
+ press_ret
161
+
162
+ puts "The function lp.get_mat(row, column) returns a single"
163
+ puts "matrix element"
164
+ printf("%s get_mat(lp,2,3), get_mat(lp,1,1); gives\n","printf(\"%f %f\\n\",");
165
+ printf("%f %f\n", lp.get_mat(2,3), lp.get_mat(1,1))
166
+ puts "Notice that get_mat returns the value of the original unscaled problem"
167
+ press_ret
168
+ puts "If there are any integer type variables, then only the rows are scaled"
169
+ puts "lp.set_int(3,FALSE)"
170
+ puts "lp.scaling = LPSolve::SCALE_MEAN"
171
+ lp.scaling = LPSolve::SCALE_MEAN
172
+ lp.set_int(3,FALSE)
173
+ lp.print_lp
174
+ press_ret
175
+ lp.solve
176
+ puts "print_objective, print_solution gives the solution to the original problem"
177
+ lp.print_objective
178
+ lp.print_solution(1)
179
+ lp.print_constraints(1)
180
+ press_ret
181
+
182
+ puts "Scaling is turned off with lp.unscale;"
183
+ lp.unscale;
184
+ lp.print_lp
185
+ press_ret
186
+ puts "Now turn B&B debugging off and simplex tracing on with"
187
+ puts "lp.debug = FALSE, lp.trace = TRUE) and lp.solve"
188
+ lp.set_debug(FALSE);
189
+ lp.set_trace(TRUE);
190
+ press_ret();
191
+ lp.solve
192
+
193
+ puts "Where possible, lp_solve will start at the last found basis"
194
+ puts "We can reset the problem to the initial basis with"
195
+ puts "default_basis(lp). Now solve it again..."
196
+ press_ret
197
+ lp.default_basis
198
+ lp.solve
199
+
200
+ puts "It is possible to give variables and constraints names"
201
+ puts 'lp.set_row_name(1, "speed"); & lp.set_col_name(2,"money")'
202
+ if (not lp.set_row_name(1,"speed"))
203
+ error();
204
+ end
205
+ if (!lp.set_col_name(2,"money"))
206
+ error();
207
+ end
208
+ lp.print_lp
209
+ puts "As you can see, all column and rows are assigned default names"
210
+ puts "If a column or constraint is deleted, the names shift place also:"
211
+ press_ret
212
+ puts "lp.del_column(1)"
213
+ lp.del_column(1)
214
+ lp.print_lp
215
+ press_ret