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

Python Mistral.Solver类代码示例

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

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



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

示例1: testOr_2

 def testOr_2(self):
     var1 = Variable(0, 2)
     dur1 = 1
     
     var2 = Variable(0, 4)
     dur2 = 2
     
     var3 = Variable(0, 6)
     dur3 = 3
     
     model = NativeModel()
     
     #model.add( NoOverlap( (var1, var2), (dur1, dur2) ) )
     #model.add( NoOverlap( (var1, var3), (dur1, dur3) ) )
     #model.add( NoOverlap( (var2, var3), (dur2, dur3) ) )
     
     ur = UnaryResource ( [ NoOverlap( (var1, var2), (dur1, dur2) ),
                                  NoOverlap( (var1, var3), (dur1, dur3) ),
                                  NoOverlap( (var2, var3), (dur2, dur3) ) ] )
     
     model.add( ur )
     
     solver = Solver(model)
     
     assert(solver.solve())
     
     assert ( (var1.get_value() + dur1 < var2.get_value ) or
         ( var2.get_value() + dur2 < var1.get_value  ) )
开发者ID:eomahony,项目名称:Numberjack,代码行数:28,代码来源:SolverTests.py


示例2: testSumConstant

 def testSumConstant(self):
      obj1 = Variable(list(range(0,6)))
      obj2 = Variable(list(range(0,8)))
      obj3 = Variable(list(range(0,11)))
 
      capacity = Variable(list(range(34,35)))
      volumes = [7, 5, 3]
 
      model = NativeModel()
 
      vol_sum = Sum(((obj1, obj2, obj3), volumes))
 
      model.add_variable((obj1, obj2, obj3, vol_sum, capacity))
 
      model.add_constraint(Leq((vol_sum, capacity)))
      
      solver = Solver(model)
     
      '''
      obj1.print_domain()
      obj2.print_domain()
      obj3.print_domain()
      vol_sum.print_domain()
      capacity.print_domain()
      '''
      
      assert( solver.solve() )
      
      '''
开发者ID:eomahony,项目名称:Numberjack,代码行数:29,代码来源:SolverTests.py


示例3: testMinusOverNativeModelOp

 def testMinusOverNativeModelOp(self):
     var1, var2 = (Variable(range(0,4)), Variable(range(0,4)))
     
     model = NativeModel()
     
     model << (var1 == var2 - 3)
     
     solver = Solver(model)
     assert(solver.solve())
开发者ID:AbdullahMohammad,项目名称:Numberjack,代码行数:9,代码来源:SolverTests.py


示例4: testTimesOver

 def testTimesOver(self):
     var1, var2 = (Variable(range(1,4)), Variable(range(0,4)))
     
     model = NativeModel()
     
     model.add_constraint(var1 == var2 * 2)
     
     solver = Solver(model)
     assert(solver.solve())
开发者ID:AbdullahMohammad,项目名称:Numberjack,代码行数:9,代码来源:SolverTests.py


示例5: testExactlyUNSAT_2

 def testExactlyUNSAT_2(self):
     model = NativeModel()
     var1, var2 = (Variable(0,5), Variable(0,5))
     
     model << (Exactly(((var1, var2), 2, 3)))
     
     solver = Solver(model)
     
     assert(not solver.solve())
开发者ID:eomahony,项目名称:Numberjack,代码行数:9,代码来源:SolverTests.py


示例6: testTimesOverNativeModelOp

 def testTimesOverNativeModelOp(self):
     var1, var2 = (Variable(list(range(1,4))), Variable(list(range(0,4))))
     
     model = NativeModel()
     
     model << (var1 == var2 * 2)
     
     solver = Solver(model)
     assert(solver.solve())
开发者ID:eomahony,项目名称:Numberjack,代码行数:9,代码来源:SolverTests.py


示例7: testAtLeastUNSAT_2

 def testAtLeastUNSAT_2(self):
     model = NativeModel()
     var1, var2 = (Variable(0,5), Variable(0,5))
     
     model << (AtLeast(([var1, var2], 0, 3)))
     
     solver = Solver(model)
     
     assert(not solver.solve())
开发者ID:eomahony,项目名称:Numberjack,代码行数:9,代码来源:SolverTests.py


示例8: testOperatorOVerloading

 def testOperatorOVerloading(self):
     var1 = Variable(list(range(0,4)))
     var2 = Variable(list(range(0,4)))
     
     model = NativeModel()
     model.add_constraint(var1 != var2)
                          
     solver = Solver(model)
     assert(solver.solve())
开发者ID:eomahony,项目名称:Numberjack,代码行数:9,代码来源:SolverTests.py


示例9: testAtMostUNSAT_2

 def testAtMostUNSAT_2(self):
     model = NativeModel()
     var1, var2 = (Variable(2,2), Variable(0,1))
     
     model << (AtMost(([var1, var2], 2, 2)))
     
     solver = Solver(model)
     
     assert(solver.solve())
开发者ID:eomahony,项目名称:Numberjack,代码行数:9,代码来源:SolverTests.py


示例10: testMinusOver

 def testMinusOver(self):
     var1, var2 = (Variable(list(range(0,4))), Variable(list(range(0,4))))
     
     model = NativeModel()
     
     model.add_constraint(var1 == var2 - 3)
     
     solver = Solver(model)
     assert(solver.solve())
开发者ID:eomahony,项目名称:Numberjack,代码行数:9,代码来源:SolverTests.py


示例11: testGTOver

 def testGTOver(self):
     var1, var2, var3 = (Variable(list(range(0,3))) for x in range(0,3))
     model = NativeModel()
     
     model.add_constraint(var1 < var2)
     model.add_constraint(var2 < var3)
     model.add_constraint(var1 < var3)
     
     solver = Solver(model)
     assert(solver.solve())
开发者ID:eomahony,项目名称:Numberjack,代码行数:10,代码来源:SolverTests.py


示例12: testEqualOver

 def testEqualOver(self):
     var1 = Variable([0])
     var2 = Variable(list(range(0,1)))
     
     model = NativeModel()
     
     model.add_constraint(var1 == var2)
     
     solver = Solver(model)
     assert(solver.solve())
开发者ID:eomahony,项目名称:Numberjack,代码行数:10,代码来源:SolverTests.py


示例13: testEqual

 def testEqual(self):
     var1 = Variable([0])
     var2 = Variable(list(range(0,1)))
     
     model = NativeModel()
     
     model.add_variable((var1, var2))
     
     solver = Solver(model)
     assert(solver.solve())
开发者ID:eomahony,项目名称:Numberjack,代码行数:10,代码来源:SolverTests.py


示例14: testMinus

 def testMinus(self):
     var1, var2 = (Variable(list(range(0,4))), Variable(list(range(0,4))))
     
     model = NativeModel()
     model.add_variable((var1, var2))
     
     model.add_constraint(Equal((var1, Minus(var2, 3))))
     
     solver = Solver(model)
     assert(solver.solve())
开发者ID:eomahony,项目名称:Numberjack,代码行数:10,代码来源:SolverTests.py


示例15: testExactlySAT_2

 def testExactlySAT_2(self):
     model = NativeModel()
     var1, var2 = (Variable(0,5), Variable(0,5))
     
     model << (Exactly(((var1, var2), 2, 1)))
     
     solver = Solver(model)
     
     assert(solver.solve())
     assert((var1.get_value() is 2 or var2.get_value() is 2))
开发者ID:eomahony,项目名称:Numberjack,代码行数:10,代码来源:SolverTests.py


示例16: testStupid_not_eqOver

 def testStupid_not_eqOver(self):
     var1 = Variable(list(range(0,3)))
     var2 = Variable(list(range(0,3)))
     
     model = NativeModel()
     model.add_constraint(var1 != var2)
         
     solver = Solver(model)
     
     assert(solver.solve())    
     assert(var1.get_value() != var2.get_value())
开发者ID:eomahony,项目名称:Numberjack,代码行数:11,代码来源:SolverTests.py


示例17: testAtLeastSAT

 def testAtLeastSAT(self):
     model = NativeModel()
     var1, var2 = (Variable(0,5), Variable(0,5))
     
     model << (AtLeast(([var1, var2], 2, 2)))
     
     solver = Solver(model)
     
     assert(solver.solve())
     assert(var1.get_value() is 2)
     assert(var2.get_value() is 2)
开发者ID:eomahony,项目名称:Numberjack,代码行数:11,代码来源:SolverTests.py


示例18: testNotUnsat

   def testNotUnsat(self):
       var1 = Variable(0, 1)
       var2 = Variable(2, 3)
 
       model = NativeModel()
       
       model << (Not(var1 != var2))
       
       solver = Solver(model)
       
       assert(not solver.solve())
开发者ID:eomahony,项目名称:Numberjack,代码行数:11,代码来源:SolverTests.py


示例19: testNegDomains

    def testNegDomains(self):
        var1 = Variable(-3, -1)
        var2 = Variable(-2, 0)
        
        model = NativeModel()

        model << (var1*2 <= var2)
        
        solver = Solver(model)
        
        assert(solver.solve())
开发者ID:eomahony,项目名称:Numberjack,代码行数:11,代码来源:SolverTests.py


示例20: testMaximization

 def testMaximization(self):
     model = NativeModel()
     
     var1, var2 = (Variable(0,4) for x in range(0,2))
     var3 = Variable(0,10)
     
     model << (var1 + var2 == var3)
     
     solver = Solver(model)
     
     assert( solver.maximise(var3) )
开发者ID:eomahony,项目名称:Numberjack,代码行数:11,代码来源:SolverTests.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.python_list函数代码示例发布时间:2022-05-24
下一篇:
Python MiscUtils.TestUtils类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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