MINLP, Opti toolbox and SCIP

258 views
Skip to first unread message

Chicoscience

unread,
Dec 2, 2014, 9:07:55 AM12/2/14
to opti-tool...@googlegroups.com
Hi,

I am trying to use Opti toolbox to solve a MINLP by using SCIP internally. I am defining my own objective function and providing it via the fun parameter, similarly to this:

fun = @(x) myFunction(x);
Opt = opti('fun', fun, 'nl', nonLinearCons, nonLinearRHS_L, nonLinearRHS_U, 'lin', A, rhs_l, rhs_u, 'bounds', lb, ub, 'xtype', varsType, 'ndec', numVariables, 'options', opts);

My function, internally, invokes other matlab functions for which I don't have the code, and thus cannot be modified, and these functions require double values. I proceed to solve the model, providing my initial guess:

[result, fval, exitflag, info] = solve(Opt, guess);

I put a disp(class(x(1))) command inside myFunction. I noticed that the first time that the solver calls myFunction(x), the class of object x is 'scipvar'. The 2nd time, the class is 'double'. Why is that the case? When the class is 'scipvar', I cannot invoke my objective function since it only takes double arguments (the function ends in error).

Is there a way to solve this, for example, to convert scipvar to double?

Thank you very much.

Jonathan Currie

unread,
Dec 2, 2014, 1:20:00 PM12/2/14
to opti-tool...@googlegroups.com

Hi,

 

The types of functions that can be solved using SCIP are limited to only those that support the following operators and functions:

 

>> methods(scipvar)

 

The first time OPTI-SCIP calls your function, it will be parsing it into an algebraic representation (using the scipvar data type), the second time it is verifying the parsed function against the supplied starting point (hence called as a double). There is no way around this, this is the way OPTI-SCIP must work.

 

Jonathan

--
You received this message because you are subscribed to the Google Groups "OPTI Toolbox Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opti-toolbox-fo...@googlegroups.com.
To post to this group, send email to opti-tool...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Chicoscience

unread,
Dec 2, 2014, 5:56:27 PM12/2/14
to opti-tool...@googlegroups.com
Dear Jonathan, thank you very much, that was very informative.

I am trying to rebuild the whole objective function to avoid using any function not included in methods(scipvar), and unfortunately so far I have been stopped by one little issue. For example, as part of my objective I need to calculate the mean of each column of a matrix. I created the following function:

function [m] = avg(x)
    num = size(x,1);

    %m = x(1,:);
    m = zeros(1,num);
    for (j = 1 : num)
        %m(j) = 0;
        for (i = 1 : num)
            m(j) = m(j) + x(i,j);
        end
        m(j) = m(j) / num;
    end
end

If I create m as a vector of zeros (m = zeros(1,num)), then I cannot do any operation on it since scipvar cannot be converted to double. If I do the workaround and create it as a vector of scipvar (m = x(1,:);), then I cannot set it to zero since a double cannot be assigned to a scipvar.

It is a long shot, but would you have any idea of how could I make this work? Or the best option would be to try and use another solver?

Thank you very much.

Jonathan Currie

unread,
Dec 3, 2014, 4:07:32 AM12/3/14
to opti-tool...@googlegroups.com

Hi,

 

Just don’t preallocate when using SCIP, i.e. no zeros(), ones(), etc. Then it should work. Alternatively if you have to, preallocate scipvar, which works in a similar way.

--

Chicoscience

unread,
Dec 3, 2014, 7:49:44 AM12/3/14
to opti-tool...@googlegroups.com
Dear Jonathan, thank you very much for your help.

I rebuilt my objective function using only accepted scipvar commands.

Best regards.
Reply all
Reply to author
Forward
0 new messages