如何将字符串解析为Term(MSF)以定义约束? [英] How to parse a string to a Term (MSF) to define a constraint?
问题描述
大家好,我有问题,我帮忙了!
Hi guys, i have a problem and i new your help!
首先,我不是专家开发人员。我正在开发一个解决线性编程问题的软件解决方案,但是我尝试它是通用的,为此,从文本框到ArrayList捕获de Constraint,现在,我没有如何将它解析为Term
做出约束!
First of all, I'm noy an expert developer. I'm developing a software solution to solve linear programming problems, but y try to it works generic, for that, y capture de Constraint from a textboxes to an ArrayList, now, i don't have how to parse it to Term to make a Constraint!
请帮助我!!!
示例:
// Asuming that "vz" and "sa" decisions already exists
string myLimits = "0 <= vz <= 9000, 0 <= sa <= 6000";
string myConstraint = "0.3 * sa + 0.4 * vz >= 2000, 0.4 * sa + 0.2 * vz >= 1500, 0.2 * sa + 0.3 * vz >= 500";
// Now create the constraints
model.AddConstraints("limits",myLimits);
model.AddConstraints("production",myConstraints);
但是我有一个错误:"无法从字符串转换为Term"而
But I have an error: "Cannot convert from string to Term"
推荐答案
如果要将约束添加为字符串,则需要一次将它们添加到模型中。使用此方法:
If you want to add constraints as strings you will need to add them to the model one at a time. Use this method:
http:// msdn .microsoft.com / zh-CN / library / ff526477(v = vs.93 )
字符串必须是OML - 阅读文档或教程以获取更多信息。
The string needs to be OML - read the documentation or tutorials for more.
Nate
这篇关于如何将字符串解析为Term(MSF)以定义约束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!