How to schedule AMPL/CPLEX run at some time and report CPU time?

213 views
Skip to first unread message

kevin

unread,
Oct 12, 2006, 1:27:49 AM10/12/06
to AMPL Modeling Language
Hi all,

I am using AMPL/CPLEX to solve a number of MIP problems. I need to
remotely run AMPL/CPLEX through network. The AMPL/CPLEX is currently
installed on a Pentium-based desktop PC (with Windows XP as the
operating system). I can only use that computer remotely.

My problems are:

1) I want to schedule AMPL/CPLEX to run at nights. I also want
AMPL/CPLEX run all these problems one by one and ouput the results to
some files so I can access later. How to do these?
2) During the run, I want AMPL/CPLEX to report the CPU time and best
bound (if CPLEX cannot find the optimal solution in fixed time) for the
problem. How to report CPU time and best bound?
3) For some big problems, AMPL/CPLEX may not find the optimal solution,
so I want to terminate AMPL/CPLEX after 1 hour, for example, and report
the best solution found so far. How to do this?

Since I am a novice, I don't know if there are some scripts or other
methods to do these. Can I do these by invoking AMPL/CPLEX from C/C++?

Hope someone can help me out.

Thanks,

Kevin

Steven Harrod

unread,
Oct 12, 2006, 1:15:29 PM10/12/06
to am...@googlegroups.com
You can use scheduling tools in Windows to start a program or process.
Once the process starts, everything else can be done in ampl. Refer to
the AMPL reference book. You can create a run file in ampl that calls
other models or data in other files. You just need some tool in Windows
to initiate the run file. I think products like PCAnywhere have the
ability to create macros and run them on a schedule. -Steven

--
Steven Harrod
Applied Arts Ltd.
Lexington, KY
859 225 1572

bwmoore22

unread,
Oct 12, 2006, 5:39:30 PM10/12/06
to AMPL Modeling Language
For scheduling, look up the Windows "at" command. If you are more
comfortable with Unix/Linux, you might install Cygwin (www.cygwin.com)
on your Windows machine and use the Unix "crontab" file to
automatically schedule some things to run off-shift.

For remote Access, PC-Anywhere is an alternative, or you can use the
"Remote Desktop" capability that is built into Windows XP. I generally
get better response time through Remote Desktop, but it does not have
some of the file transfer capabilities that PC Anywhere has. If you
are more familiar with Unix/Linux, Cygwin has an secure shell (SSH)
client and server, which would probably have faster response for an
AMPL command line if the network is slow.

If you don't care about (in)security, TELNET is an installable option
on Windows, though it generally is not installed becuase of it's
security issues.

For saving output look up the redirection capabilities in AMPL display
and printf commands (> and >>). You can probably also redirect the
console output from you "at" or "crontab" job to a file.

Steven Harrod

unread,
Oct 12, 2006, 7:50:03 PM10/12/06
to am...@googlegroups.com
The primary advantage of PCAnywhere is it is very robust when the
connection is poor. It was developed years ago when the standard
connection was a telephone dial up, and it is very tolerant of lossy
routers and high latency connections. PCAnywhere will recover well from
dropped packets. -Steven

--

Robert Fourer

unread,
Oct 14, 2006, 12:07:15 PM10/14/06
to am...@googlegroups.com, kevin

> From: am...@googlegroups.com [mailto:am...@googlegroups.com]
> On Behalf Of kevin
> Sent: Thursday, October 12, 2006 12:28 AM
> To: AMPL Modeling Language
> Subject: [AMPL 635] How to schedule AMPL/CPLEX run at some
> time and report CPU time?


>
> I am using AMPL/CPLEX to solve a number of MIP problems. I need to
> remotely run AMPL/CPLEX through network. The AMPL/CPLEX is currently
> installed on a Pentium-based desktop PC (with Windows XP as the
> operating system). I can only use that computer remotely.
>
> My problems are:
>
> 1) I want to schedule AMPL/CPLEX to run at nights. I also want
> AMPL/CPLEX run all these problems one by one and ouput the results to
> some files so I can access later. How to do these?

See other postings to this group on schedulng AMPL/CPLEX runs. You can use
the display, print, or printf commands to write results to a file, by adding
a ">" followed by the file's name at the end of the command. You can even
use string expressions to create a different file for each run; see "String
expressions in AMPL commands" at www.ampl.com/NEW/strings.html or on pp.
273-274 of the AMPL book.

> 2) During the run, I want AMPL/CPLEX to report the CPU time and best
> bound (if CPLEX cannot find the optimal solution in fixed time) for the
> problem. How to report CPU time and best bound?
>
> 3) For some big problems, AMPL/CPLEX may not find the optimal solution,
> so I want to terminate AMPL/CPLEX after 1 hour, for example, and report
> the best solution found so far. How to do this?

Much of what you want to do is covered by CPLEX directives; see the attached
"README" file for details. Also I posted an explanation of "best bound"
directives to this newsgroup earlier; it's copied below.

-- -- -- -- -- -- --

To get the best bound as determined by CPLEX's branch-and-bound
procedure at the point where it terminated, first specify the
directive "bestbound" before solving:

model multmip2.mod;
data multmip2.dat;
option solver cplex101;
option cplex_options 'bestbound nodelim 12';
solve;

Then look for the following in the results:

CPLEX 10.1.0: node limit with integer solution; objective 233150
186 MIP simplex iterations
12 branch-and-bound nodes
absmipgap = 3084.01, relmipgap = 0.0132276


suffix bestbound OUT;
ampl: display Total_Cost, Total_Cost.bestbound;
Total_Cost = 233150
Total_Cost.bestbound = 230065.9941520491

Total_Cost (the objective function in this case) gives the best
integer-feasible solution found so far, and Total_Cost.bestbound
gives the best bound found so far. To also be able to check for
the case where no integer-feasible solution has been found, add
a directive to request the "absolute MIP gap":

ampl: model multmip2.mod;
data multmip2.dat;
option solver cplex101;
option cplex_options 'return_mipgap 2 bestbound nodelim 3';
solve;

CPLEX 10.1.0: return_mipgap 2
bestbound
nodelim 3
CPLEX 10.1.0: node limit with no integer solution.
112 MIP simplex iterations
3 branch-and-bound nodes; no basis.

suffix bestbound OUT;
suffix absmipgap OUT;
ampl: display Total_Cost, Total_Cost.bestbound, Total_Cost.absmipgap;
Total_Cost = 0
Total_Cost.bestbound = 230022.96296296298
Total_Cost.absmipgap = Infinity

An infinite value for Total_Cost.absmipgap indicates that no
integer-feasible solution was found.

Bob Fourer
4...@ampl.com


README.txt
Reply all
Reply to author
Forward
0 new messages