Microsoft Solver Foundation for semi-integer

耗尽温柔 提交于 2019-12-06 03:53:56

You can do this with Solver Foundation but there is no equivalent for the "sec" keyword. Instead you can add a dummy 0-1 decision for each semi-integer variable. For your original example involving "V", here's how you could do it in OML:

Model[
  Decisions[
    Integers[0, 1],
    VPositive
  ],
  Decisions[
    Reals,
    V
  ],
  Constraints[
    constraint -> 10 * VPositive<= V <= 20 * VPositive
  ]
]

If you are using the Solver Foundation API then you would add the analagous decisions, constraints, goals using the object model. The way to specify the type of a decision is using a Domain, provided in the ctor.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!