LCM

51 views
Skip to first unread message

Aliya Awais

unread,
Sep 5, 2013, 10:27:21 AM9/5/13
to am...@googlegroups.com
hi I want to compute  LCM(Least Common Multiple ) of two or three values in a
constraint . there's no build in function for that in AMPL . Can anyone help me how can I start  ?
--
Aliya Awais

Robert Fourer

unread,
Sep 5, 2013, 10:44:46 AM9/5/13
to am...@googlegroups.com

Can you give an example of the constraint that you want to write?  Be sure to indicate which symbols are parameters (data) and which are decision variables.

 

Bob Fourer

am...@googlegroups.com

 

 

From: am...@googlegroups.com [mailto:am...@googlegroups.com]

On Behalf Of Aliya Awais
Sent: Thursday, September 5, 2013 9:27 AM
To: am...@googlegroups.com
Subject: [AMPL 7425] LCM

Aliya Awais

unread,
Sep 9, 2013, 8:35:56 AM9/9/13
to am...@googlegroups.com
I wrote my own LCM function it seems to be working fine (calculating correct lcm ).  Issue with my problem is that it is nonlinear and I want integer values (i.e. integer nonlinear problem) minos seems to be failing in this scenario and  cplex  does not handle nonlinear problem.  can you please suggest me and correct me as well (new to Linear Programming ).
 
param price {size} default 0.0;
param length{size};
param width{size};
param r > 0;         
set size;

var Use {size} integer >= 0;
var U {size} integer >= 0;


 
subject to Width_Limit: 
  sum {i in size}  widths[i] * floor( U[i] )<= r;

 

subject to Length_Limit {i in size} :  
    Use[i]=  (U[i])*/lengths[i]) *lcm(floor(U[541])*lengths[541],floor(U[521])*lengths[521],floor(U[501])*lengths[501],floor(U[481])*lengths[481]);

 

 
 
 
 
 
 
 

 


--
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 http://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/groups/opt_out.



--
Aliya Awais

Robert Fourer

unread,
Sep 10, 2013, 12:36:15 PM9/10/13
to am...@googlegroups.com

There are solvers such as KNITRO, Bonmin, and Couenne that accept mixed-integer nonlinear problems.  You could try them, but I think you may find that they do not handle the lcm function successfully.  These solvers rely on "relaxations" of the problem in which some variables are allowed to take fractional values; so to fit the framework that these solvers require, you would need to extend lcm to a continuous function on fractional as well as integer values, which I doubt is possible.

 

Although your formulation may be mathematically correct, and it is certainly concise, it may not be in a form that lends itself to solution by current techniques.  You may need to rethink the formulation to get one that can be usefully solved, perhaps using a greater number of variables and (hopefully linear) constraints.  I can't be more definite than that since I'm not sure what application you are trying to model.

 

In any case it is not useful to write expressions like "floor(U[i])" where U[i] is already defined to be integer.  (For an integer variable U[i], floor(U[i]) = U[i].)

On Behalf Of Aliya Awais
Sent: Monday, September 9, 2013 7:36 AM
To: am...@googlegroups.com
Subject: Re: [AMPL 7431] LCM

Reply all
Reply to author
Forward
0 new messages