Pyomo解算器中的持久性Unicode解码错误

时间:2020-01-04 18:21:52

标签: pyomo ipopt

我正在尝试通过pyomo建模语言解决Ipopt的优化问题。为了变得精通,我正在研究Jeffrey Kantor在https://jckantor.github.io/ND-Pyomo-Cookbook/

上提供的示例

通常,这些示例都能很好地工作,但是在尝试使用有限差分转换工厂的每个实例中,都会出现错误:

    ---------------------------------------------------------------------------
UnicodeDecodeError                        Traceback (most recent call last)
~/opt/anaconda3/lib/python3.7/site-packages/pyomo/opt/plugins/sol.py in __call__(self, filename, res, soln, suffixes)
     46             with open(filename,"r") as f:
---> 47                 return self._load(f, res, soln, suffixes)
     48         except ValueError as e:

~/opt/anaconda3/lib/python3.7/site-packages/pyomo/opt/plugins/sol.py in _load(self, fin, res, soln, suffixes)
     61         msg = ""
---> 62         line = fin.readline()
     63         if line.strip() == "":

~/opt/anaconda3/lib/python3.7/codecs.py in decode(self, input, final)
    321         data = self.buffer + input
--> 322         (result, consumed) = self._buffer_decode(data, self.errors, final)
    323         # keep undecoded input until the next call

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8e in position 75: invalid start byte

During handling of the above exception, another exception occurred:

    UnicodeDecodeError                        Traceback (most recent call last)
    ~/workspace/Specter/Opt/Car/Car.py in <module>
        101 discretizer.apply_to(m,nfe=30,wrt=m.t)
        102 opt = SolverFactory('ipopt')
    --> 103 opt.solve(m)

    ~/opt/anaconda3/lib/python3.7/site-packages/pyomo/opt/base/solvers.py in solve(self, *args, **kwds)
        603                 print("      %6.2f seconds required for solver" % (solve_completion_time - presolve_completion_time))
        604 
    --> 605             result = self._postsolve()
        606             result._smap_id = self._smap_id
        607             result._smap = None

    ~/opt/anaconda3/lib/python3.7/site-packages/pyomo/opt/solver/shellcmd.py in _postsolve(self)
        268 
        269         if self._results_format is not None:
    --> 270             results = self.process_output(self._rc)
        271             #
        272             # If keepfiles is true, then we pop the

    ~/opt/anaconda3/lib/python3.7/site-packages/pyomo/solvers/plugins/solvers/IPOPT.py in process_output(self, rc)
        190     def process_output(self, rc):
        191         if os.path.exists(self._results_file):
    --> 192             return super(IPOPT, self).process_output(rc)
        193         else:
        194             res = SolverResults()

    ~/opt/anaconda3/lib/python3.7/site-packages/pyomo/opt/solver/shellcmd.py in process_output(self, rc)
        348                 results = self._results_reader(self._results_file,
        349                                                res=results,
    --> 350                                                suffixes=self._suffixes)
        351             results_reader_completion_time = time.time()
        352             if self._report_timing is True:

    ~/opt/anaconda3/lib/python3.7/site-packages/pyomo/opt/plugins/sol.py in __call__(self, filename, res, soln, suffixes)
         48         except ValueError as e:
         49             with open(filename,"r") as f:
    ---> 50                 fdata = f.read()
         51             raise ValueError(
         52                 "Error reading '%s': %s.\n"

    ~/opt/anaconda3/lib/python3.7/codecs.py in decode(self, input, final)
        320         # decode input (taking the buffer into account)
        321         data = self.buffer + input
    --> 322         (result, consumed) = self._buffer_decode(data, self.errors, final)
        323         # keep undecoded input until the next call
        324         self.buffer = data[consumed:]

    UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8e in position 75: invalid start byte 

在我努力完成的两个示例中,我也遇到类似的错误:

,但是前面的示例:Batch Reactor可以正常工作。

这似乎深埋在ipomo的pyomo界面中。谁能提供有关如何进行调试的见识?

谢谢! 约翰尼

0 个答案:

没有答案