Using pyomo module in Matlab
4 ビュー (過去 30 日間)
古いコメントを表示
Hi everyone,
I'm currtly working on a project involving pyomo in matlab. I've managed to use other python modules in matlab (numpy for example), in different ways without any problem. It seems I've also succeed in creating a pyomo ConcreteModel from matlab. However, I can't get RangeSet() to work. I'll explain what I've tired and I hope someone can see what I've done wrong.
Fisrt with line command:
mod = py.importlib.import_module('pyomo');
py.RangeSet() % Option 1
py.pyomo.RangeSet() % Option 2
py.mod.RangeSet() % Option 3
None of this is working, each time I get the same error 'Unable to resolve the name py.RangeSet.'
Second I've try calling a pyhton file (testRangeFile.py):
mod = py.importlib.import_module('pyomo');
test = py.importlib.import_module('testRangeFile');
test.testRange(2)
test.testRangeFile.testRange(2)
My pyhton fuction for testing being:
def testRange(value):
from pyomo.environ import pyomo % also tried importing outside def
return pyomo.RangeSet(value)
In that case the error is 'Unrecognized method, property, or field 'testRange' for class 'py.module'.'
I don't know what else to try, and I can't figure out why this is not working when the other modules/functions are. If someone as an explanation so I uderstand best how this works it would help a lot.
Thanks for reading :)
PS: I'm using 2020b
1 件のコメント
hossein jbn
2022 年 9 月 6 日
Hi my friend
i would like to add pyomo in matlab but i don't know how i can do it. please guide me. to contact me you can send an email to Hossein.jobran77@gmail.com.
thanks a lot
採用された回答
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!