« Previous « Start » Next »

5  A Simple Example

To compile the following code, in test.m.

    % ----------------------------------------------------------------
    function f = test

    probfile   = 'con_prob';
    probNumber = 10;
    ask        = [];
    Prob       = [];

    Prob   = probInit(probfile, probNumber, ask, Prob);
    Result = conSolve(Prob);

    f = Result.f_k;
    % ----------------------------------------------------------------

with a TOMLAB /SOL license (which means that QPOPT is chosen as the QP subsolver in conSolve), the profiler and a little trial-and-error will show that the following m-files are needed:

 BoundInit.m      LineSearch.m     SOLGet.m
 ComputeQR.m      LinearConstr.m   SOLSet.m
 CreateProbQP.m   NonlinConstr.m   StateDef.m
 DefPar.m         PrintResult.m    checkType.m
 GetSolver.m      ProbCheck.m      conProbSet.m
 LagMult.m        ProbDef.m        conSolve.m
 LineParamDef.m   ProbGate.m       conVarDef.m
 LineParamSet.m   ResultDef.m      con_H.m
 con_c.m          defblbu.m        nlp_dc.m
 con_d2c.m        endSolve.m       nlp_f.m
 con_dc.m         globalGet.m      nlp_g.m
 con_f.m          globalSave.m     optParamDef.m
 con_fm.m         iniSolve.m       optParamSet.m
 con_g.m          mFiles.m         probInit.m
 con_gm.m         nlp_H.m          qpProbSet.m
 con_prob.m       nlp_c.m          qpVarDef.m
 qp_Hess.m        test.m
 qp_f.m           tomSolve.m
 qp_fX.m          tomlabVersion.m
 qp_g.m           xnargin.m
 qp_gX.m          xprint.m
 qp_H.m           xprinte.m
 qp_prob.m        xxx_prob.m

and these dll's:

qpopt.dll      tomlablic.dll  tomsol.dll

The compile command to execute is:

  mcc -m test.m qpopt.dll tomsol.dll tomlablic.dll ...
         con_prob con_f con_g con_H con_c con_dc con_d2c qp_f qp_g

Notice how a number of m-files must be named here. If not, upon execution there will be errors like:

 ERROR: Reference to unknown function 'qp_f' from nargin in stand-alone mode.

Still, there may be warnings about missing functions, however this is not a problem if one has checked which m-files are needed for the application to work. An alternative is to compile all TOMLAB m-files, but thereby increasing both size and compile time.

The example should run fine:

>> ! test.exe

 ===== * * * =================================================================== * * *
 TOMLAB SOL - stand-alone test license
 Problem: con_prob - 10: Schittkowski 66. Eckhardt  f_k      0.518163274278335420
                                      User given f(x_*)      0.518163274099999960
                                          sum(|constr|)      0.000000000003534950
                                 f(x_k) + sum(|constr|)      0.518163274281870370
                                                 f(x_0)      0.579999999999999960

 Solver: conSolve.  EXIT=0.  INFORM=1.
 Schittkowski SQP algorithm, analytic Hessian
 Optimal solution found
 Iteration points are close

 FuncEv   66 GradEv   66 ConstrEv   66 Iter   43
 CPU time: 0.375000 sec. Elapsed time: 0.375000 sec.
 Starting vector x:
 x_0: 0.000000   1.050000   2.900000
 Optimal vector x:
 x_k: 0.184116   1.202155   3.327280
 User given stationary point x_* (1): - Minimum point
 x_*:   0.184126   1.202168   3.327322
 Lagrange multipliers v. Vector length 5:
 v_k:  0.000000e+000  0.000000e+000 0.000000e+000  6.654713e-001  2.000045e-001
 Gradient g_k:
 g_k: -8.000000e-001  0.000000e+000  2.000000e-001
 cErr -6.852297e-013 -2.849720e-012
 Projected gradient gPr:
 gPr: -1.006538e-006 -1.210015e-006 -4.026060e-006
    NonLLow 1 NonLLow 2
 v:  6.654706e-001  2.000040e-001

 === * * * ================================================== * * *

« Previous « Start » Next »