質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
最適化

最適化とはメソッドやデザインの最適な処理方法を選択することです。パフォーマンスの向上を目指す為に行われます。プログラミングにおける最適化は、アルゴリズムのスピードアップや、要求されるリソースを減らすことなどを指します。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

0回答

1721閲覧

ipoptによる非線形最適化のエラー

mu08

総合スコア16

最適化

最適化とはメソッドやデザインの最適な処理方法を選択することです。パフォーマンスの向上を目指す為に行われます。プログラミングにおける最適化は、アルゴリズムのスピードアップや、要求されるリソースを減らすことなどを指します。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2021/11/19 05:23

前提・実現したいこと

ipoptによる最適化ができません。

発生している問題・エラーメッセージ

Ipopt 3.12.12: ==> Warning: Treating 0 binary and 1000 integer variables as continous. ****************************************************************************** This program contains Ipopt, a library for large-scale nonlinear optimization. Ipopt is released as open source code under the Eclipse Public License (EPL). For more information visit http://projects.coin-or.org/Ipopt ****************************************************************************** This is Ipopt version 3.12.12, running with linear solver mumps. NOTE: Other linear solvers might be more efficient (see Ipopt documentation). Number of nonzeros in equality constraint Jacobian...: 1000 Number of nonzeros in inequality constraint Jacobian.: 540 Number of nonzeros in Lagrangian Hessian.............: 30300 Error in an AMPL evaluation. Run with "halt_on_ampl_error yes" to see details. Error evaluating objective gradient at user provided starting point. No scaling factor for objective function computed! Total number of variables............................: 1300 variables with only lower bounds: 0 variables with lower and upper bounds: 1300 variables with only upper bounds: 0 Total number of equality constraints.................: 100 Total number of inequality constraints...............: 270 inequality constraints with only lower bounds: 0 inequality constraints with lower and upper bounds: 0 inequality constraints with only upper bounds: 270 iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls 0 -4.4966040e+02 9.00e-01 5.01e+01 -1.0 0.00e+00 - 0.00e+00 0.00e+00 0 1 -9.8620678e+02 8.17e-01 9.22e+03 -1.0 1.07e-01 4.0 9.83e-01 9.25e-02f 1 2 -1.0260026e+03 8.10e-01 9.64e+05 -1.0 8.17e-02 8.0 8.25e-01 7.98e-03f 1 3 -1.0609083e+03 8.10e-01 4.52e+21 -1.0 8.10e-02 12.1 3.87e-01 8.83e-05f 1 WARNING: Problem in step computation; switching to emergency mode. 4r-1.0609083e+03 8.10e-01 1.00e+03 -0.1 0.00e+00 20.0 0.00e+00 0.00e+00R 1 5r-3.2534985e+03 4.76e-01 9.99e+02 -0.1 3.78e+02 - 7.97e-05 2.12e-03f 1 6 -3.2537319e+03 4.76e-01 8.46e+07 -1.0 8.46e-07 14.0 1.00e+00 1.00e+00h 1 7 -3.2888275e+03 4.76e-01 8.87e+08 -1.0 4.76e-02 13.5 4.54e-01 2.91e-04f 1 ERROR: Solver (ipopt) returned non-zero return code (-11) ERROR: See the solver log above for diagnostic information. --------------------------------------------------------------------------- ApplicationError Traceback (most recent call last) <ipython-input-49-e31fc9a31c36> in <module> 30 31 opt = SolverFactory("ipopt") ---> 32 result = opt.solve(model, tee=True) 33 model.display() 34 solver.options['print_level'] = 12 ~/opt/anaconda3/lib/python3.7/site-packages/pyomo/opt/base/solvers.py in solve(self, *args, **kwds) 594 logger.error("Solver log:\n" + str(_status.log)) 595 raise ApplicationError( --> 596 "Solver (%s) did not exit normally" % self.name) 597 solve_completion_time = time.time() 598 if self._report_timing: ApplicationError: Solver (ipopt) did not exit normally

該当のソースコード

python

1 2from pyomo.environ import * 3 4I=100 5J=30 6T=10 7 8model=ConcreteModel() 9model.Candidate=range(I) 10model.Item=range(J) 11model.Class=range(T) 12 13model.x=Var(model.Item,model.Class,bounds=(0.0,1.0)) 14model.y=Var(model.Candidate,model.Class,within=Binary) 15 16#目的関数 17model.obj=Objective( expr=sum( model.y[i,t]*u_ij[i,j]*log(model.x[j,t])+model.y[i,t]*(1-u_ij[i,j])*log(1-model.x[j,t]) for i in model.Candidate for j in model.Item for t in model.Class )) 18 19 20#制約条件1 21model.mono=ConstraintList() 22for j in model.Item: 23 for t in model.Class: 24 if t<=8: 25 model.mono.add( model.x[j,t] <= model.x[j,t+1]) 26 27#制約条件2 28model.single_y=ConstraintList() 29for i in model.Candidate: 30 model.single_y.add( sum( model.y[i,t] for t in model.Class ) == 1) 31 32opt = SolverFactory("ipopt") 33result = opt.solve(model, tee=True) 34model.display() 35solver.options['print_level'] = 12 36solver.options['output_file'] = "my_ipopt_log.txt"

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問