|
Revision 170, 0.8 kB
(checked in by dmitrey, 2 years ago)
|
move some files
|
| Line | |
|---|
| 1 |
""" |
|---|
| 2 |
The example illustrates oosolver usage |
|---|
| 3 |
You should pay special attention for "isInstalled" field |
|---|
| 4 |
|
|---|
| 5 |
oosolver work is untested for converters |
|---|
| 6 |
""" |
|---|
| 7 |
from openopt import oosolver, NLP |
|---|
| 8 |
|
|---|
| 9 |
ipopt = oosolver('ipopt', color='r') # oosolver can hanlde prob parameters |
|---|
| 10 |
ralg = oosolver('ralg', color='k', alp = 4.0) # as well as solver parameters |
|---|
| 11 |
asdf = oosolver('asdf') |
|---|
| 12 |
|
|---|
| 13 |
solvers = [ralg, asdf, ipopt] |
|---|
| 14 |
# or just |
|---|
| 15 |
# solvers = [oosolver('ipopt', color='r'), oosolver('asdf'), oosolver('ralg', color='k', alp = 4.0)] |
|---|
| 16 |
|
|---|
| 17 |
for solver in solvers: |
|---|
| 18 |
if not solver.isInstalled: |
|---|
| 19 |
print 'solver ' + solver.__name__ + ' is not installed' |
|---|
| 20 |
continue |
|---|
| 21 |
p = NLP(x0 = 15, f = lambda x: x**4, df = lambda x: 4 * x**3, iprint = 0) |
|---|
| 22 |
r = p.solve(solver, plot=1, show = solver == solvers[-1]) |
|---|