if then grammar problem

25 de afișări
Accesați primul mesaj necitit

Liu Fan

necitită,
3 iul. 2022, 15:51:5903.07.2022
– AMPL Modeling Language
Dear  Robert :
I want to write such a constraint. Sum up parts of a variable > = 2.
for example: 
var over_route{s in square};
var sum_over_route;
subject to  constraint  {s in square}:
if over_route[s]>=2 then sum_over_route=sum over_route[s];
How should I express in ampl. Look forward to your reply. Best wishes.

AMPL Google Group

necitită,
4 iul. 2022, 03:29:4204.07.2022
– AMPL Modeling Language
If you have the experimental "x-gurobi" solver in your AMPL folder, it will recognize the constraint as you have written it. Otherwise, you will need to transform it into a form that current AMPL-solver interfaces can accept. To get more help, indicate which solvers you have available and would like to use; probably, you will need to use a MIP solver like the regular Gurobi or CPLEX or Xpress.

I am not sure that your constraint can be satisfied, however. For example, if "A" and "B" are in set square, and over_route["A"] equals 2 and over_route["B"] equals 3, then your constraint says that sum_over_route = 2 and also sum_over_route = 3, which is impossible. So you should check this before trying to formulate the constraint for AMPL.


--
Robert Fourer
am...@googlegroups.com
{#HS:1938761515-110808#}

Liu Fan

necitită,
4 iul. 2022, 15:36:1304.07.2022
– AMPL Modeling Language
Dear  Robert :
Thank you for the information.
I have the experimental "x-gurobi" solver in my AMPL folder, however,   When I use this solver to solve the model, 
the error prompts :
x-Gurobi 9.5.1: Error: MIPFlatConverter: MP2MIP: IfThen with variable then/else arguments not implemented
Error at _cmdno 4 executing "solve" command
(file C:\Users\Administrator\Desktop\new_paper\min_overly_route.run, line 35, offset 1423):
can't open C:\Users\Administrator\AppData\Local\Temp\at10304.sol


I may not be clear about my problem, I want to find variables greater than or equal to 2 and sum them up. Therefore if "A" and "B" and "C" are in set square, and over_route["A"] equals 2 and over_route["B"] equals 3 and over_route["C"] equals 1, then the result I want is 2 + 3 = 5. Excluding variables less than 2 in summation.

I want to use a MIP solver like the regular Gurobi or CPLEX or Xpress, I can also use NLP solver such as BONMIN or minos etc.

Look forward to your reply.
Best wishes.

AMPL Google Group

necitită,
5 iul. 2022, 16:55:2705.07.2022
– AMPL Modeling Language
Can you post a copy of min_overly_route.run and any related model and data files? Then we will be able to investigate the x-gurobi error.

Concerning the restriction that you want to model,
  • I want to find variables greater than or equal to 2 and sum them up. Therefore if "A" and "B" and "C" are in set square, and over_route["A"] equals 2 and over_route["B"] equals 3 and over_route["C"] equals 1, then the result I want is 2 + 3 = 5 (excluding variables less than 2 in summation).
I think there should be a way to model it as linear constraints that a MIP solver can handle, but it requires some tricks. Since this is basically a formulation question (not specifically an AMPL question), a good place to ask it would be Operations Research Stack Exchange. I have seen many formulation questions there.


--
Robert Fourer
am...@googlegroups.com
{#HS:1938761515-110808#}
On Mon, Jul 4, 2022 at 7:36 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Dear Robert :

Thank you for the information.
I have the experimental "x-gurobi" solver in my AMPL folder, however, When I use this solver to solve the model,
the error prompts :
x-Gurobi 9.5.1: Error: MIPFlatConverter: MP2MIP: IfThen with variable then/else arguments not implemented
Error at _cmdno 4 executing "solve" command
(file C:\Users\Administrator\Desktop\new_paper\min_overly_route.run, line 35, offset 1423):
can't open C:\Users\Administrator\AppData\Local\Temp\at10304.sol

I may not be clear about my problem, I want to find variables greater than or equal to 2 and sum them up. Therefore if "A" and "B" and "C" are in set square, and over_route["A"] equals 2 and over_route["B"] equals 3 and over_route["C"] equals 1, then the result I want is 2 + 3 = 5. Excluding variables less than 2 in summation.

I want to use a MIP solver like the regular Gurobi or CPLEX or Xpress, I can also use NLP solver such as BONMIN or minos etc.

Look forward to your reply.
Best wishes.
On Mon, Jul 4, 2022 at 7:29 AM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
If you have the experimental "x-gurobi" solver in your AMPL folder, it will recognize the constraint as you have written it. Otherwise, you will need to transform it into a form that current AMPL-solver interfaces can accept. To get more help, indicate which solvers you have available and would like to use; probably, you will need to use a MIP solver like the regular Gurobi or CPLEX or Xpress.

I am not sure that your constraint can be satisfied, however. For example, if "A" and "B" are in set square, and over_route["A"] equals 2 and over_route["B"] equals 3, then your constraint says that sum_over_route = 2 and also sum_over_route = 3, which is impossible. So you should check this before trying to formulate the constraint for AMPL.


--
Robert Fourer
am...@googlegroups.com
Răspundeți tuturor
Răspundeți autorului
Redirecționați
0 mesaje noi