--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Dear
Sylvain,
unfortunately I still have
a problem with it, Maybe you can give me some hints to solve it. Let me mention
that I am quite new in AMPL. Thus, I don't know the programming style really
good.
The variables i and phi are calculated based on electrical conditions. I declared
slack_i and slack_phi as variables to be >=0 and entered the complementary
condition.
Within the program, I "calculated" the slack-variables as e.g.
slack_i = i-300 using a let-command. Of course, now I detected that this
approach has been wrong.
Nevertheless, it's seems not to be possible to define a variable as unsigned on
the one hand and calculating it at the other side. Am I'm wrong? If no, what's
the correct way to implement such an issue?
Best regards
Lothar
First of all: Thank's for your reply.
Unfortunatelly, I didn't get it. I tried the following code (the term
dealing with q and p represents the angle, mentioned before) :
subject to NB_ang_branch_12 {s in SCN, t in TME, (l,k,m) in BRANCH, b
in BUS: b==k}:
abs(branch_i_12[s,t,l,k,m,b]) > 300 ==> branch_q_12[s,t,l,k,m]^2
<= branch_p_12[s,t,l,k,m]^2 / 3;
This leads to the message: Sorry, knitro cannot handle logical constraints.
I also tried to put the "if" command in the conditional definition, but
AMPL blaims about the syntax
subject to NB_ang_branch_12 {s in SCN, t in TME, (l,k,m) in BRANCH, b
in BUS: if ((b==k) && (sqrt(branch_i_12[s,t,l,k,m,b]^2) >= 300))}:
branch_q_12[s,t,l,k,m]^2 <= branch_p_12[s,t,l,k,m]^2 / 3;
AMPL-Message:
syntax error
context: subject to NB_ang_branch_12 {s in SCN, t in TME, (l,k,m) in
BRANCH, b in BUS: if ((b==k) && (sqrt(branch_i_12[s,t,l,k,m,b]^2) >= >>>
300))} <<< :
Any hints?
Best regards
Lothar
Am Dienstag, 28. August 2018 22:23:26 UTC+2 schrieb
lothar...@googlemail.com:
On Fri, Aug 31, 2018 at 2:16 PM UTC, Ampl Modeling Language <am...@googlegroups.com> wrote:
Maybe, I've got it:
subject to NB_ang_branch_12 {s in SCN, t in TME, (l,k,m) in BRANCH, b
in BUS: b==k}:
branch_q_12[s,t,l,k,m]^2 <= (if (sqrt(branch_i_12[s,t,l,k,m,b]^2)
>= 3000) then branch_p_12[s,t,l,k,m]^2 / 3
else 1e20);
What do you think about this solution?
Best regards
Lothar
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.
Best regards
Lothar
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
Best regards
Lothar
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
On Wed, Aug 29, 2018 at 11:10 AM UTC, Ampl Modeling Language <am...@googlegroups.com> wrote:
Dear Lothar,
To complement Paras' answer, let me propose another approach using complementarity constraints
You could introduce new slack variables related to the angle phi and the current i and apply a complementarity condition on them:
i < 300 + slack_i
phi < 30 + slack_phi
0 < slack_i complements slack_phi >0
You may have a look at this link for more information on complementarity constraints.
Knitro can make use of such special structures in its internal algorithm, although it still does not provide a guarantee of convergence to a feasible local optimal solution on non-convex models.
Please let us know if this helps or not.
Kind regards,
Sylvain Mouret
Le mercredi 29 août 2018 03:13:31 UTC+2, AMPL Google Group a écrit :
On Wed, Aug 29, 2018 at 1:13 AM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
You can use AMPL if-then-else in your constraint as discussed in https://ampl.com/resources/logic-and-constraint-programming-extensions/ Conditional Operators section. However, if variable appears in the condition, then AMPL treats the constraint as a nonlinear constraint. Since you are using Knitro, it should be able to handle nonlinear problem. Alternatively, you can enforce your condition by using Mixed Integer Programming. The MIPs are harder to solve than the continuous optimization problem. Knitro can solve Mixed Integer Nonlinear Problem. You can do some research about "enforcing logical condition in optimization" or "enforcing logical condition in ampl".
--
Dr. Paras Tiwari
am...@googlegroups.com
On Tue, Aug 28, 2018 at 8:23 PM UTC, Ampl Modeling Language <am...@googlegroups.com> wrote:
Hello,
I am performing some grid calcualtions/optimizations (calculation of voltages, currents, power flow, ...) using AMPL which works fine in general. I have to use solver knitro.
Now, I have to take a special constraint into account which bases on two variables: For each single element, an grid angle (first variable: phi) has to be lower than a limit value IN CASE the current via this element is higher than another limit value (second variable: i).
The angle has to be lower 30° (phi < 30°) if the current value is higher 300 A (i > 300A). In case the current is lower, there is no need to check the angle. The angle as well as the current are variables, effected by other data used by the optimizer.
I know that parameter based conditions can be taken into account easily, but variables are forbidden in general. Thus: Is there a workaround?
So far, I tried several possibilities to put the condition in a mathematical description like
angle * ((atan((i-300)*5)+pi/2)/pi) <= 30; # i >= 0; here, "5" is used as a "gain-factor"
This leads to the result: Knitro 11.0.1: Current infeasible solution estimate cannot be improved.
Is there a better way to use a condition within a constaint?
Best regards
Lothar
On Wed, Jun 5, 2019 at 2:35 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
If you have any more questions about error messages from the Knitro solver, post the entire text of all messages from Knitro. That will show the Knitro version and possibly other useful information. Also, attach your files if that is possible.
--
Robert Fourer
am...@googlegroups.com
On Wed, Jun 5, 2019 at 2:31 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
That is right, you cannot use the > and < operators in defining constraints for an optimization problem. (Technically, the minimum or maximum is not well defined when these operators are used.)
The constraint "slack_i >= 0 complements slack_phi >= 0" says that the following conditions must hold:
slack_i >= 0,
slack_phi >= 0,
either slack_i = 0 or slack_phi = 0
What are the conditions on slack_i and slack_phi that you want in your problem?
--
Robert Fourer
am...@googlegroups.com
On Wed, Jun 5, 2019 at 1:58 PM UTC, Ampl Modeling Language <am...@googlegroups.com> wrote:
Unfortunately it seems not to be possible to use a single ">" instead of ">=". So it doesn't work.
Any ideas?
Best regards
Lothar
On Tue, Jun 4, 2019 at 9:42 PM UTC, Ampl Modeling Language <am...@googlegroups.com> wrote:
I think, I've got it:
So far, I am writing
slack_i >= 0 complements slack_phi >= 0;
I guess I simply have to write
slack_i > 0 complements slack_phi > 0;
Sylvain mentioned this in his reply, but I didn't recognized this detail. I will try it tomorrow in the office.
Best regards
Lothar