• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python mmio.mmread函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中scipy.io.mmio.mmread函数的典型用法代码示例。如果您正苦于以下问题:Python mmread函数的具体用法?Python mmread怎么用?Python mmread使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了mmread函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_var_bounds

    def test_var_bounds(self):
        """ Test bounds on optimisation variables.
        """
        msg = self.case_name
        _, xmin, xmax = self.solver._var_bounds()

        mpxmin = mmread(join(DATA_DIR, self.case_name, "opf", "xmin_AC.mtx"))
        mpxmax = mmread(join(DATA_DIR, self.case_name, "opf", "xmax_AC.mtx"))

        self.assertTrue(mfeq1(xmin, mpxmin.flatten()), msg)
        self.assertTrue(mfeq1(xmax, mpxmax.flatten()), msg)
开发者ID:Waqquas,项目名称:pylon,代码行数:11,代码来源:opf_test.py


示例2: test_constraints

    def test_constraints(self):
        """ Test equality and inequality constraints.
        """
        AA, ll, uu = self.solver._linear_constraints(self.om)

        mpA = mmread(join(DATA_DIR, self.case_name, "opf", "A_DC.mtx"))
        mpl = mmread(join(DATA_DIR, self.case_name, "opf", "l_DC.mtx"))
        mpu = mmread(join(DATA_DIR, self.case_name, "opf", "u_DC.mtx"))

        self.assertTrue(mfeq2(AA, mpA.tocsr()), self.case_name)
        self.assertTrue(mfeq1(ll, mpl.flatten()), self.case_name)
        self.assertTrue(mfeq1(uu, mpu.flatten()), self.case_name)
开发者ID:Waqquas,项目名称:pylon,代码行数:12,代码来源:opf_test.py


示例3: testYbus

    def testYbus(self):
        """ Test bus and branch admittance matrices.
        """
        self.case.index_buses()
        Ybus, Yf, Yt = self.case.Y

        mpYbus = mmread(join(DATA_DIR, self.case_name, "Ybus.mtx")).tocsr()
        mpYf = mmread(join(DATA_DIR, self.case_name, "Yf.mtx")).tocsr()
        mpYt = mmread(join(DATA_DIR, self.case_name, "Yt.mtx")).tocsr()

        self.assertTrue(mfeq2(Ybus, mpYbus, diff=1e-12), self.case_name)
        self.assertTrue(mfeq2(Yf, mpYf, diff=1e-12), self.case_name)
        self.assertTrue(mfeq2(Yt, mpYt, diff=1e-12), self.case_name)
开发者ID:Waqquas,项目名称:pylon,代码行数:13,代码来源:case_test.py


示例4: testAy

    def testAy(self):
        """ Test basin constraints for piece-wise linear gen cost variables.
        """
        msg = self.case_name
        self.case.sort_generators() # ext2int
        _, _, gn = self.opf._remove_isolated(self.case)
        _, ycon = self.opf._pwl_gen_costs(gn, self.case.base_mva)

        if ycon is not None:
            Ay = mmread(join(DATA_DIR, self.case_name, "opf", "Ay_DC.mtx"))
            by = mmread(join(DATA_DIR, self.case_name, "opf", "by_DC.mtx"))

            self.assertTrue(mfeq2(ycon.A, Ay.tocsr()), msg)
            self.assertTrue(mfeq1(ycon.u, by.flatten()), msg)
开发者ID:Waqquas,项目名称:pylon,代码行数:14,代码来源:opf_test.py


示例5: testPg

    def testPg(self):
        """ Test active power variable.
        """
        msg = self.case_name
        self.case.sort_generators() # ext2int
        _, _, gn = self.opf._remove_isolated(self.case)
        Pg = self.opf._get_pgen_var(gn, self.case.base_mva)

        mpPg0 = mmread(join(DATA_DIR, self.case_name, "opf", "Pg0.mtx"))
        mpPmin = mmread(join(DATA_DIR, self.case_name, "opf", "Pmin.mtx"))
        mpPmax = mmread(join(DATA_DIR, self.case_name, "opf", "Pmax.mtx"))

        self.assertTrue(mfeq1(Pg.v0, mpPg0.flatten()), msg)
        self.assertTrue(mfeq1(Pg.vl, mpPmin.flatten()), msg)
        self.assertTrue(mfeq1(Pg.vu, mpPmax.flatten()), msg)
开发者ID:Waqquas,项目名称:pylon,代码行数:15,代码来源:opf_test.py


示例6: testVa

    def testVa(self):
        """ Test voltage angle variable.
        """
        msg = self.case_name
        bs, _, _ = self.opf._remove_isolated(self.case)
        _, refs = self.opf._ref_check(self.case)
        Va = self.opf._get_voltage_angle_var(refs, bs)

        mpVa0 = mmread(join(DATA_DIR, self.case_name, "opf", "Va0.mtx"))
        mpVal = mmread(join(DATA_DIR, self.case_name, "opf", "Val.mtx"))
        mpVau = mmread(join(DATA_DIR, self.case_name, "opf", "Vau.mtx"))

        self.assertTrue(mfeq1(Va.v0, mpVa0.flatten()), msg)
        self.assertTrue(mfeq1(Va.vl, mpVal.flatten()), msg)
        self.assertTrue(mfeq1(Va.vu, mpVau.flatten()), msg)
开发者ID:Waqquas,项目名称:pylon,代码行数:15,代码来源:opf_test.py


示例7: test_dSbus_dV

    def test_dSbus_dV(self):
        """ Test partial derivative of power injection w.r.t. voltage.
        """
        mpYbus = mmread(join(DATA_DIR, self.case_name, "Ybus.mtx")).tocsr()
        mpV0 = mmread(join(DATA_DIR, self.case_name, "V0.mtx")).flatten()

        dSbus_dVm, dSbus_dVa = self.case.dSbus_dV(mpYbus, mpV0)

        mp_dSbus_dVm = mmread(join(DATA_DIR, self.case_name, "dSbus_dVm0.mtx"))
        mp_dSbus_dVa = mmread(join(DATA_DIR, self.case_name, "dSbus_dVa0.mtx"))

        self.assertTrue(mfeq2(dSbus_dVm, mp_dSbus_dVm.tocsr(), 1e-12),
                        self.case_name)
        self.assertTrue(mfeq2(dSbus_dVa, mp_dSbus_dVa.tocsr(), 1e-12),
                        self.case_name)
开发者ID:Waqquas,项目名称:pylon,代码行数:15,代码来源:case_test.py


示例8: testVLConstPF

    def testVLConstPF(self):
        """ Test dispatchable load, constant power factor constraints.
        """
        msg = self.case_name
        _, _, gn = self.opf._remove_isolated(self.case)
        vl = self.opf._const_pf_constraints(gn, self.case.base_mva)

        if vl.A.shape[0] != 0:
            Avl = mmread(join(DATA_DIR, self.case_name, "opf", "Avl.mtx"))
            self.assertTrue(mfeq2(vl.A, Avl.tocsr()), msg)

        lvl = mmread(join(DATA_DIR, self.case_name, "opf", "lang.mtx"))
        self.assertTrue(mfeq1(vl.l, lvl.flatten()), msg)

        uvl = mmread(join(DATA_DIR, self.case_name, "opf", "uang.mtx"))
        self.assertTrue(mfeq1(vl.u, uvl.flatten()), msg)
开发者ID:Waqquas,项目名称:pylon,代码行数:16,代码来源:opf_test.py


示例9: testPfPt

    def testPfPt(self):
        """ Test branch flow limit constraints.
        """
        msg = self.case_name
        _, ln, _ = self.opf._remove_isolated(self.case)
        _, Bf, _, Pfinj = self.case.Bdc
        Pf, Pt = self.opf._branch_flow_dc(ln, Bf, Pfinj, self.case.base_mva)

        lpf = mmread(join(DATA_DIR, self.case_name, "opf", "lpf.mtx"))
        upf = mmread(join(DATA_DIR, self.case_name, "opf", "upf.mtx"))
        upt = mmread(join(DATA_DIR, self.case_name, "opf", "upt.mtx"))

        self.assertTrue(mfeq1(Pf.l, lpf.flatten()), msg)
        self.assertTrue(mfeq1(Pf.u, upf.flatten()), msg)
        self.assertTrue(mfeq1(Pt.l, lpf.flatten()), msg)
        self.assertTrue(mfeq1(Pt.u, upt.flatten()), msg)
开发者ID:Waqquas,项目名称:pylon,代码行数:16,代码来源:opf_test.py


示例10: testPmis

    def testPmis(self):
        """ Test active power mismatch constraints.
        """
        msg = self.case_name
        case = self.case
        case.sort_generators() # ext2int
        B, _, Pbusinj, _ = case.Bdc
        bs, _, gn = self.opf._remove_isolated(case)
        Pmis = self.opf._power_mismatch_dc(bs, gn, B, Pbusinj, case.base_mva)

        mpAmis = mmread(join(DATA_DIR, self.case_name, "opf", "Amis.mtx"))
        mpbmis = mmread(join(DATA_DIR, self.case_name, "opf", "bmis.mtx"))

        self.assertTrue(mfeq2(Pmis.A, mpAmis.tocsr(), 1e-12), msg)
        self.assertTrue(mfeq1(Pmis.l, mpbmis.flatten()), msg)
        self.assertTrue(mfeq1(Pmis.u, mpbmis.flatten()), msg)
开发者ID:Waqquas,项目名称:pylon,代码行数:16,代码来源:opf_test.py


示例11: check_read

 def check_read(self, example, a, info):
     f = open(self.fn, 'w')
     f.write(example)
     f.close()
     assert_equal(mminfo(self.fn), info)
     b = mmread(self.fn).todense()
     assert_array_almost_equal(a, b)
开发者ID:Kitchi,项目名称:scipy,代码行数:7,代码来源:test_mmio.py


示例12: test_simple_rectangular

 def test_simple_rectangular(self):
     a = [[1, 2, 3], [4, 5, 6]]
     fn = self.fn
     mmwrite(fn, a)
     assert_equal(mminfo(fn), (2, 3, 6, "array", "integer", "general"))
     b = mmread(fn)
     assert_array_almost_equal(a, b)
开发者ID:hainm,项目名称:scipy,代码行数:7,代码来源:test_mmio.py


示例13: test_simple_rectangular

 def test_simple_rectangular(self):
     a = [[1,2,3],[4,5,6]]
     fn = mktemp()
     mmwrite(fn,a)
     assert_equal(mminfo(fn),(2,3,6,'array','integer','general'))
     b = mmread(fn)
     assert_array_almost_equal(a,b)
开发者ID:AndreI11,项目名称:SatStressGui,代码行数:7,代码来源:test_mmio.py


示例14: test_simple_rectangular_real

 def test_simple_rectangular_real(self):
     a = [[1, 2], [3.5, 4], [5, 6]]
     fn = self.fn
     mmwrite(fn, a)
     assert_equal(mminfo(fn), (3, 2, 6, "array", "real", "general"))
     b = mmread(fn)
     assert_array_almost_equal(a, b)
开发者ID:hainm,项目名称:scipy,代码行数:7,代码来源:test_mmio.py


示例15: test_simple_hermitian

 def test_simple_hermitian(self):
     a = [[1,2+3j],[2-3j,4]]
     fn = mktemp()
     mmwrite(fn,a)
     assert_equal(mminfo(fn),(2,2,4,'array','complex','hermitian'))
     b = mmread(fn)
     assert_array_almost_equal(a,b)
开发者ID:AndreI11,项目名称:SatStressGui,代码行数:7,代码来源:test_mmio.py


示例16: test_simple_skew_symmetric

 def test_simple_skew_symmetric(self):
     a = [[1,2],[-2,4]]
     fn = mktemp()
     mmwrite(fn,a)
     assert_equal(mminfo(fn),(2,2,4,'array','integer','skew-symmetric'))
     b = mmread(fn)
     assert_array_almost_equal(a,b)
开发者ID:AndreI11,项目名称:SatStressGui,代码行数:7,代码来源:test_mmio.py


示例17: test_simple_skew_symmetric_float

 def test_simple_skew_symmetric_float(self):
     a = array([[1,2],[-2.0,4]],'f')
     fn = mktemp()
     mmwrite(fn,a)
     assert_equal(mminfo(fn),(2,2,4,'array','real','skew-symmetric'))
     b = mmread(fn)
     assert_array_almost_equal(a,b)
开发者ID:AndreI11,项目名称:SatStressGui,代码行数:7,代码来源:test_mmio.py


示例18: test_simple_rectangular_real

 def test_simple_rectangular_real(self):
     a = [[1,2],[3.5,4],[5,6]]
     fn = mktemp()
     mmwrite(fn,a)
     assert_equal(mminfo(fn),(3,2,6,'array','real','general'))
     b = mmread(fn)
     assert_array_almost_equal(a,b)
开发者ID:AndreI11,项目名称:SatStressGui,代码行数:7,代码来源:test_mmio.py


示例19: test_simple_complex

 def test_simple_complex(self):
     a = [[1,2],[3,4j]]
     fn = mktemp()
     mmwrite(fn,a)
     assert_equal(mminfo(fn),(2,2,4,'array','complex','general'))
     b = mmread(fn)
     assert_array_almost_equal(a,b)
开发者ID:AndreI11,项目名称:SatStressGui,代码行数:7,代码来源:test_mmio.py


示例20: test_simple_real

 def test_simple_real(self):
     a = [[1,2],[3,4.0]]
     fn = self.fn
     mmwrite(fn,a)
     assert_equal(mminfo(fn),(2,2,4,'array','real','general'))
     b = mmread(fn)
     assert_array_almost_equal(a,b)
开发者ID:hitej,项目名称:meta-core,代码行数:7,代码来源:test_mmio.py



注:本文中的scipy.io.mmio.mmread函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mmio.mmwrite函数代码示例发布时间:2022-05-27
下一篇:
Python mmio.mminfo函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap