Using pyomo module in Matlab

4 visualizzazioni (ultimi 30 giorni)
Ileperff
Ileperff il 16 Mag 2022
Commentato: hossein jbn il 6 Set 2022
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 Commento
hossein jbn
hossein jbn il 6 Set 2022
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

Accedi per commentare.

Risposta accettata

Ileperff
Ileperff il 19 Mag 2022
I did'nt managed to solve this problem. But in case some faces the same issue, I avoided it by recreating RangeSet() on my own (which is quite easy) and then call it in Matlab:
def MyRangeSet(value):
array = []
for i in range(1, value+1):
array.append(i)
return array

Più risposte (0)

Categorie

Scopri di più su Get Started with MATLAB in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by