How to define the model of the electrical circuit?
-
יום רביעי 08 אוגוסט 2012 07:20
Dear all,
Below is the optimization model of an electrical circuit, the goal is to make the power loss minimized.
I use C# and SFS to define the model, which can be outputed as:
Model[
Parameters[
Sets[Integers[0, Infinity]],
nodes,
edges,
Index
],
Parameters[
Reals[-Infinity, Infinity],
p[nodes],
q[nodes],
r[edges],
x[edges],
g[Index, Index],
b[Index, Index]
],
Parameters[
Reals[0, Infinity],
vb[nodes],
v[nodes]
],
Parameters[
Booleans,
isSlack[nodes]
],
Parameters[
Reals[-884279719003555/281474976710656, 884279719003555/281474976710656],
theta[nodes]
],
Parameters[
Integers[0, Infinity],
startID[edges],
endID[edges]
],
Decisions[
Reals[0, 1000],
shuntAmount[nodes]
],
Constraints[
p_balance -> Foreach[
{iter1, nodes},
If[isSlack[iter1] == True, shuntAmount[iter1] == 0, -p[iter1] == v[iter1] * Sum[
{iter2, nodes},
v[iter2] * (g[iter1, iter2] * Cos[theta[iter1] - theta[iter2]] + b[iter1, iter2] * Sin[theta[iter1] - theta[iter2]])
]]
],
q_balance -> Foreach[
{iter3, nodes},
If[isSlack[iter3] == True | vb[iter3] > 3602879701896397/9007199254740992, shuntAmount[iter3] == 0, -q[iter3] + shuntAmount[iter3] == v[iter3] * Sum[
{iter4, nodes},
v[iter4] * (g[iter3, iter4] * Sin[theta[iter3] - theta[iter4]] - b[iter3, iter4] * Cos[theta[iter3] - theta[iter4]])
]]
],
slack_v -> Foreach[
{iter5, nodes},
If[isSlack[iter5] == True, v[iter5] == 1, True]
],
slack_theta -> Foreach[
{iter6, nodes},
If[isSlack[iter6] == True, theta[iter6] == 0, True]
],
v_offset -> Foreach[
{iter7, nodes},
Abs[v[iter7] - 1] < 3602879701896397/18014398509481984
]
],
Goals[
Minimize[
PLoss_and_Cost -> Annotation[Sum[
{iter8, edges},
((-(((2 * v[startID[iter8]]) * v[endID[iter8]]) * Cos[theta[startID[iter8]] - theta[endID[iter8]]]) + v[startID[iter8]] * v[startID[iter8]] + v[endID[iter8]] * v[endID[iter8]]) * r[iter8]) * (r[iter8] * r[iter8] + x[iter8] * x[iter8]) ^ -1
], "order", 0]
]
]
]It seems not correct since I always get all the decisions to be 0, while the equation constraints are always violated. It should be mentioned that the model can only be solved with HybridLocalSearchDirective() and set the TimeLimit property to be a finite value, say, 5000. If I change the solver to any other, the same error message will be thrown:
No solver could be found that can accept the model given the model type and directive(s)
Can anyone help me to find the error? Many many thanks!
Regards
כל התגובות
-
יום ראשון 19 אוגוסט 2012 09:02
From the description of your problem, it seems to be that
"theta[nodes]" are really variables (or to MSF Terminology:
Decisions) whose values will be determined when the solution
to the problem is found.
What you really want is that you want to fix (or specify) some
of the "theta[nodes]" to certain known values:
For example, theta[1] = 0.0;
In that case, you must add these specifications as "Equality
Constraints" to your problem.
The same seems to be the case with "vb[nodes]" and "v[nodes]"
The point is that the expression "Decisions" can be misleading
sometimes.
What seems to be happening in your problem is that you have to
specify certain values of the "theta[nodes]" in order to get a
solution.
The values of the remaining variables will be found by the
Solver when the problem is solved.
I hope that this helps.
Good luck with MSF!