Leapms + cplex solving mixed integer programming problem

Leapms + cplex solving mixed integer programming problem

O, Overview

CPleX is a mystery solver, I heard a long time wanted to use, but the direct use of some difficulties, especially in the entry difficult for beginners Leapms is a good channel.

There cplex in Leapms a command directly typing cplex + Enter to call Cplex solved. However, online download Leapms not have this feature. 

But it beat the deity, because leapms ms files can be exported and lp, but this generic model interfaces ah. Through this on the line chanting.

what? Where can I find Leapms? Baidu chant. . . . .

First, let Leapms MPS output file

1, a first model elsewhere copied leapms Traveling Salesman Problem Problem with Notepad TSP.leap saved as a file (point of view code to open the code below).

what? This model how to understand? See other article of this blog (https://www.cnblogs.com/leapms/p/10058798.html)

//The Traveling Salesman Problem

min sum{i=1,...,n;j=1,...,n;i<>j}x[i][j]D[i][j]

subject to
    sum{i=1,...,n;i<>j}x[i][j]=1 | j=2,...,n
    sum{j=1,...,n;i<>j}x[i][j]=1 | i=2,...,n
    
    u[1]=0
    u[j]>=u[i]+1-n(1-x[i][j])|i=1,...,n;j=2,...,n;i<>j
    u[i]<=n-1|i=1,...,n

where
    n is an integer
    Cd is a set
    D[i][j] is a number|i=1,...,n;j=1,...,n
    x[i][j] is a variable of binary|i=1,...,n;j=1,...,n;i<>j
    u[i] is a variable of nonnegative number|i=1,...,n

data_relation
    n=_$(Cd)/2
    D[i][j]=sqrt((Cd[2i-1]-Cd[2j-1])^2+(Cd[2i]-Cd[2j])^2) -> 
        | = I . 1 , ..., n-; J = . 1 , ..., n- 
Data 
    // coordinates of 52 cities 
    of Cd = {
 575  25  185  345  750  945  685  845  655  880  660.  25  230  525  1000  580 is  1175  650  1130.  1605  620.  1220.  580 is  1465  200 is  1530  . 5  845  680  725  370  145  665  415  635  510  875  560.  365  300 465 520 585 480 415 835 625 975 580 1215 245 1320 315 1250 400 660 180 410 250 420 555 575 665 1150 1160 700 580 685 595 685 610 770 610 795 645 720 635 760 650 475 960 95 260 875 920 700 500 555 815 830 485 1170 65 830 610 605 625 595 360 1340 725 1740 245 }

 

2, assuming that the D drive model stored in the \ TSP directory path name: D: \ TSP.

3, run leapms software.

Enter the command shp, change the working path.

Prompted for a path name, enter D \ TSP

  

4, enter the command leampms in load (see figure below where the red line is that you need to enter) transferred model .TSP.leap

 

  5, enter the command savemps

 

 At this time the model has been saved as a format mps. In the D: \ directory under the TSP should see a file called TSP.mps.

There are 2704 model shown above variables, 2756 constraints.

Second, start CPLEX solver

6, assuming your machine has been installed cplex, then open a DOS window and set the working directory to D: \ TSP, then start cplex with cplex command, the program advances to cplex the interactive environment.

what? Where can I find genuine CPLEX installation package? Bing international chant. . . . .

what? How to open Dos window? Ask degree of your mother. . .

 

 7, input in CPLEX environment read command, enter tsp.msp file name, then enter optimize cplex start solving.

 

 8, CPLEX start the solution, after completion solved. Use the display command to get the optimal objective function value.

 

 9, the display using display solution variables * Variables

 

 

Guess you like

Origin www.cnblogs.com/leapms/p/11846039.html