1
+ function [xsol , fval , exitflag , iterations ] = ...
2
+ clpOptimizer(mpsFullPath , algorithm , primalTol , ...
3
+ dualTol , maxIter , maxTime , displayLevel , objBias , ...
4
+ numPresolvePasses , factorFreq , numberRefinements , ...
5
+ primalObjLim , dualObjLim , numThreads , abcState )
6
+ % Filename: clpOptimizer.m
7
+ % Description: the function is a MATLAB code to solve LPs
8
+ % using CLP (via OPTI Toolbox)
9
+ % Authors: Ploskas, N., & Samaras, N.
10
+ %
11
+ % Syntax: [xsol, fval, exitflag, iterations] = ...
12
+ % clpOptimizer(mpsFullPath, algorithm, primalTol, ...
13
+ % dualTol, maxIter, maxTime, display, objBias, ...
14
+ % numPresolvePasses, factorFreq, numberRefinements, ...
15
+ % primalObjLim, dualObjLim, numThreads, abcState)
16
+ %
17
+ % Input:
18
+ % -- mpsFullPath: the full path of the MPS file
19
+ % -- algorithm: the CLP algorithm that will be used
20
+ % (optional, possible values: 'DualSimplex',
21
+ % 'PrimalSimplex', 'PrimalSimplexOrSprint',
22
+ % 'Barrier', 'BarrierNoCross', 'Automatic')
23
+ % -- primalTol: the primal tolerance (optional)
24
+ % -- dualTol: the dual tolerance (optional)
25
+ % -- maxIter: the maximum number of iterations
26
+ % -- (optional)
27
+ % -- maxTime: the maximum execution time in seconds
28
+ % -- (optional)
29
+ % -- displayLevel: the display level (optional,
30
+ % possible values: 0, 1 -> 100 increasing)
31
+ % -- objBias: the objective bias term (optional)
32
+ % -- numPresolvePasses: the number of presolver passes
33
+ % (optional)
34
+ % -- factorFreq: every factorFreq number of iterations,
35
+ % the basis inverse is re-computed from scratch
36
+ % (optional)
37
+ % -- numberRefinements: the number of iterative simplex
38
+ % refinements (optional)
39
+ % -- primalObjLim: the primal objective limit (optional)
40
+ % -- dualObjLim: the dual objective limit (optional)
41
+ % -- numThreads: the number of Cilk worker threads
42
+ % (optional, only with Aboca CLP build)
43
+ % -- abcState: Aboca's partition size (optional)
44
+ %
45
+ % Output:
46
+ % -- xsol: the solution found by the solver (size m x 1)
47
+ % -- fval: the value of the objective function at the
48
+ % solution xsol
49
+ % -- exitflag: the reason that the algorithm terminated
50
+ % (1: the solver converged to a solution x, 0: the
51
+ % number of iterations exceeded the maxIter option or
52
+ % time reached, -1: the LP problem is infeasible or
53
+ % unbounded)
54
+ % -- iterations: the number of iterations
55
+
56
+ % set user defined values to options
57
+ opts = optiset(' solver' , ' clp' );
58
+ if exist(' algorithm' )
59
+ opts.solverOpts.algorithm = algorithm ;
60
+ end
61
+ if exist(' primalTol' )
62
+ opts.solverOpts.primalTol = primalTol ;
63
+ opts.tolrfun = primalTol ;
64
+ end
65
+ if exist(' dualTol' )
66
+ opts.solverOpts.dualTol = dualTol ;
67
+ end
68
+ if exist(' maxIter' )
69
+ opts.maxiter = maxIter ;
70
+ else
71
+ opts.maxiter = 1000000 ;
72
+ end
73
+ if exist(' maxTime' )
74
+ opts.maxtime = maxTime ;
75
+ else
76
+ opts.maxtime = 1000000 ;
77
+ end
78
+ if exist(' displayLevel' )
79
+ opts.display = displayLevel ;
80
+ end
81
+ if exist(' objBias' )
82
+ opts.solverOpts.objbias = objBias ;
83
+ end
84
+ if exist(' numPresolvePasses' )
85
+ opts.solverOpts.numPresolvePasses = numPresolvePasses ;
86
+ end
87
+ if exist(' factorFreq' )
88
+ opts.solverOpts.factorFreq = factorFreq ;
89
+ end
90
+ if exist(' numberRefinements' )
91
+ opts.solverOpts.numberRefinements = numberRefinements ;
92
+ end
93
+ if exist(' primalObjLim' )
94
+ opts.solverOpts.primalObjLim = primalObjLim ;
95
+ end
96
+ if exist(' dualObjLim' )
97
+ opts.solverOpts.dualObjLim = dualObjLim ;
98
+ end
99
+ if exist(' numThreads' )
100
+ opts.solverOpts.numThreads = numThreads ;
101
+ end
102
+ if exist(' abcState' )
103
+ opts.solverOpts.abcState = abcState ;
104
+ end
105
+ % read the MPS file
106
+ prob = coinRead(mpsFullPath );
107
+ % call CLP solver
108
+ [xsol , fval , exitflag , info ] = opti_clp([], prob .f , ...
109
+ prob .A , prob .rl , prob .ru , prob .lb , prob .ub , opts );
110
+ iterations = info .Iterations ;
111
+ end
0 commit comments