Giter VIP home page Giter VIP logo

opti's Introduction

NOTICE: OPTI Toolbox is no longer under development and thus no further updates are expected.

OPTI Toolbox

If you are interested in optimization, use MATLAB + Windows and like free stuff, OPTI could be for you. See the OPTI Wiki for details on solving linear, nonlinear, continuous and discrete optimization problems using MATLAB!

Downloading OPTI

The best way to get OPTI is to clone the master branch from GitHub (this page!) using git. I like GitKraken which makes it easy to use git without the command line. Once you have git/GitKraken/some other git client, simply click Clone or download (above, green button) and copy the address of this repository, and clone it to your computer. This way each time I push updates to the master branch, you can simply pull them down without having to redownload the entire OPTI package again!

If you don't use git, and don't want to learn (remember its easy and you should use it!), simply click Clone or download and click Download ZIP and save OPTI somewhere you can find it.

Installing OPTI

Once you have cloned or downloaded OPTI to your PC, simply open MATLAB and navigate in MATLAB to the directory where you have placed OPTI (hopefully somewhere permanent). Right click on opti_Install.m and click Run. Follow the prompts (Yes 'Y' is the normal response to every question) to install OPTI - easy!

Using OPTI

The best way to start using OPTI is to have a look at the Examples on the OPTI Wiki. There are lots of problem and code examples (which all work) as well as helpful definitions. The Basic Usage page is a good place to start for all new users.

Troubleshooting + New Release Information

The OPTI Q&A Forum is where all OPTI related questions can be posted and someone will normally get back to you within a day or two! In addition, I announce new release of OPTI here, so subscribe if you want to be kept up to date.

License

OPTI is released under the 3-clause BSD license, as detailed here. It is free software, and is released as an open-source package. Please however be aware that many of the solvers within OPTI are licensed using different agreements to OPTI, thus ensure you are familiar with them before using OPTI in any commercial work, or generating products based on OPTI.

opti's People

Contributors

jonathancurrie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opti's Issues

Let user compile from source

Hi @jonathancurrie. Since this project is no longer supported, can you release all the codes and let community maintain it? I'm interested to make a fork that support mac and linux devices.

As mentioned in this issue #5, you only support windows. Can you share with us the source to build the mex file to support other OS?

Thank you.

Problem with installation of SCIP solver

Dear Mr. Currie,

I am encountering a problem with the installation of SCIP solver when I install the latest version of OPTI Toolbox v2.28.
As I see, there is a problem when the results of SCIP solver are tested.
I get the message "Reference to non-existent field 'PrimalBound'".
I also tried to run the script opti_SCIP_install.m, but the function opti_GetLibPath() is not found.
I have installed the latest SCIP suite 7.0.1 and I added the path in Matlab. I also added the path of the folders for the OPTI toolbox and the MEX files. Is there any file missing regarding the SCIP solver ?
Thank you very much for your help in advance.

Best regards,
Nikolaos Efkarpidis

missing ipopt_auxdata.m

If I understand correctly, the MEX interface in Ipopt 3.11.x and later removed support for options.auxdata and moved that functionality into the M-file ipopt_auxdata.m. I recently discovered that this file is missing from OPTI Toolbox, requiring users who need it to find it and install it separately from the Ipopt source distribution.

Could you please add it to OPTI Toolbox? In the Ipopt source distribution it is found in Ipopt/contrib/MatlabInterface/ipopt_auxdata.m.

FYI, I am the primary developer of MATPOWER, a power systems analysis and optimization package. MATPOWER includes support for using Ipopt as a solver, and I've been pointing Windows users to OPTI Toolbox as the easiest way to obtain a working Ipopt. And MATPOWER does require the auxdata support.

change exception handling in buildOpti test call

Hi, I would like to propose a change to the checkOpti subfunction in buildOpti.m

If the objective function contains an error in execution, checkOpti detects it on line 851.

catch ME
    error('OPTI detected an error running a test objective call. Please correct the error below and try again:\n\n%s\n',ME.message);
end

However, the code generates a new exception, and simply prints the string description of the original exception. The problem is that the description does not contain any information about where the original error was generated. For complicated objective functions, it can be difficult to locate which function call or line the original exception belongs to.

Therefore, I propose that checkOpti re-throw the original exception. A standard print or similar can be used to alert the user that OPTI detected an error. Something like:

catch ME
    fprintf('\nOPTI detected an error running a test objective call. Please correct the error below and try again:\n\n%s\n\n',ME.message);
    rethrow(ME);
end

This way, MATLAB will throw the original exception with all info (including functions and lines with hyperlinks).

'bonmin' option error

Hello, I find an error in the bonmin solver by using yalmip and Johan said that is maybe a error in the opti.

The matlab code is test_if.txt. It is an example of yalmip to model if-else.

OPTI version: v2.28
YALMIP version: '20180817'
Matlab version: r2018a
Error message:

Error using bonmin
*** Error using Bonmin Matlab interface: ***
You have specified a nonexistent BONMIN/IPOPT option
("pardiso_redo_symbolic_fact_only_if_inertia_wrong").

Error in callbonmin (line 126)
[xout,info] = bonmin(model.x0,funcs,options);
Error in solvesdp (line 350)
    eval(['output = ' solver.call '(interfacedata);']);
Error in optimize (line 31)
[varargout{1:nargout}] = solvesdp(varargin{:});
Error in test_if (line 34)
optimize(Model,Objective,options)

Reference to non-existent field

Hi,

I have just found a small problem in the function convNlopt regarding a non-existent field 'algorithm'. This occurs for the expression (line 77, line 91, line 105)
upper(nloptSolver(mprob.algorithm))
which has to be
upper(nloptSolver(mprob.options.algorithm))
instead.

Best regards,
Ronnie

SCIP solver request

could you help me with the SCIP Solver? or is it possiable to get a scip.mexw64 file for matlab? Thank you so much

How does IPOPT use other linear solvers such as ma97?

I found in the file that IPOPT can directly call ma97 and Pardiso, but I encountered a large-scale optimization problem that these two solvers cannot solve. Therefore, I would like to know how to correctly include ma97 related documents in my HSL related student certificates.
Thank you all!

filterSD returns initial guess if it hits time limit

Similar code as my previous issue, but different optimizer: I use filterSD, which works very well for this particular problem. If it converges, everything is output as expected. But if it hits the time limit, it just ouputs the initial guess as final result, which seems to be a bug.
Consider this example:

% Parameters
substr_0        = 6.21;
substr_in       = 3.171;
k_1             = 0.5;
f_1             = 43;
phi_1           = 0.5;
initialVolume   = 0;

daysTotal       = 7;
hoursTotal      = daysTotal*24;
%% Consumer schedule per hour
onOff = [0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 ...
    1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 ...
    1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 ...
    1 1 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
    1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0]';
% Initial value: Feeding only during "Consumer ON" time
substr_in_time = substr_in/12.*onOff;

%% Setup optimization problem
parameters = [substr_0, k_1, f_1, phi_1, initialVolume];
% Objective function: Standard deviation of storage volume
objFun = @(feedingVector) substr_Model(feedingVector, onOff, parameters);
% Bounds (lb <= x <= ub), i.e., decision variables can only range between 0 and 6.3
lowerBound = zeros(1, hoursTotal);
upperBound = 2*substr_in.*ones(1, hoursTotal);
% Possible solvers: FilterSD, Ipopt, fmincon (local)
optimOpts = optiset('solver', 'filterSD', 'display', 'iter', 'tolrfun', 1e-2, 'maxiter', 1e5,...
    'maxfeval', 1e5*daysTotal, 'maxtime', 90*daysTotal);
Opt = opti('fun', objFun, 'bounds', lowerBound, upperBound, 'x0', substr_in_time,...
    'options', optimOpts);

%% Solve optimization problem
tic; [feeding_Opt, fval] = solve(Opt); toc

%% Calculate model with optimal values
substr_Model(feeding_Opt, onOff, parameters)

%% Plot results
figure();
plot(1:hoursTotal, interm1, '-o', 'DisplayName', 'Interm production');
hold on; grid on
stairs(0:hoursTotal-1, 5*onOff, '-', 'DisplayName', 'Consumption schedule');
plot(1:hoursTotal, storageVolume/10, '-^', 'MarkerSize', 4,...
    'DisplayName', 'Storage volume [1e-1*m^3]');
stairs(0:hoursTotal-1, feeding_Opt, 'DisplayName', 'Feeding schedule');
xtickVector = 0:12:hoursTotal;
xticks(xtickVector);
xticklabels(xtickVector/24);
xlabel('Time (days)');
legend('Location', 'Best');
set(gca, 'FontSize', 18);
hold off

function storageStd = substr_Model(substr_feeding, onOff, parameters)
    hoursTotal      = length(substr_feeding);
    substr_0        = parameters(1);
    k_1             = parameters(2);
    f_1             = parameters(3);
    phi_1           = parameters(4);
    initialVolume   = parameters(5);

    % Simple for-loop with feeding as vector per hour
    substr = zeros(hoursTotal, 1);
    substr(1) = (substr_0 + substr_feeding(1))*exp(-k_1/24);
    for hour = 2:hoursTotal
       substr(hour) = (substr(hour-1) + substr_feeding(hour))*exp(-k_1/24);
    end
    % Calculate resulting interm1 production and storage volume
    interm1 = phi_1*f_1*substr/24;
    interm1ConsumptionRate = 11.24509;
    storageVolume = initialVolume + cumsum(interm1 - onOff*interm1ConsumptionRate);
    assignin('base', 'substr', substr);
    assignin('base', 'interm1', interm1);
    assignin('base', 'storageVolume', storageVolume);
    storageStd = std(storageVolume);
end

Now, set 'maxtime', to 1*daysTotal, and it hits time limit after about 600 iterations. But if you do isequal(substr_in_time, feeding_Opt), it returns True, which should not be the case.
Can you reproduce this? How can this be avoided/fixed?

Using multisolve()

hi jonathan

I know that you have included a description for using a multi start solver with opti here : https://www.inverseproblem.co.nz/OPTI/index.php/Advanced/MultiSolve

However, using the option (with MATLAB) returns an error saying the command/function does not exist. I have checked your class definitions and its methods and did find the multisolve() method there. So, my question is, why is it still not working?

I have been using opti for quite sometime with some other solver for nlps (nlopt, nomad, scip and baron). I would very like to test this one out as well and see the difference in the solutions.

Thank you

fmincon gives different results if called without OPTI

First, I really enjoy OPTI and use it frequently. Very nice package!
Recently, I ran into an issue. It seems that fmincon gives different results, depending on the calling syntax. Consider this example with OPTI:

% Feeding optimization over time, with algebraic model

% Parameters
substr_0        = 6.21;
substr_in       = 3.171;
k_1             = 0.5;
f_1             = 43;
phi_1           = 0.5;
initialVolume   = 0;

daysTotal       = 7;
hoursTotal      = daysTotal*24;
%% Consumer schedule per hour
onOff = [0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 ...
    1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 ...
    1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 ...
    1 1 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
    1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0]';
% Initial value: Feeding only during "Consumer ON" time
substr_in_time = substr_in/12.*onOff;

%% Setup optimization problem
parameters = [substr_0, k_1, f_1, phi_1, initialVolume];
% Objective function: Standard deviation of storage volume
objFun = @(feedingVector) substr_Model(feedingVector, onOff, parameters);
% Bounds (lb <= x <= ub), i.e., decision variables can only range between 0 and 6.3
lowerBound = zeros(1, hoursTotal);
upperBound = 2*substr_in.*ones(1, hoursTotal);
% Possible solvers: FilterSD, Ipopt, fmincon (local)
optimOpts = optiset('solver', 'matlab', 'display', 'iter', 'tolrfun', 1e-2, 'maxiter', 1e5,...
    'maxfeval', 1e5*daysTotal, 'maxtime', 180*daysTotal);
Opt = opti('fun', objFun, 'bounds', lowerBound, upperBound, 'x0', substr_in_time,...
    'options', optimOpts);

%% Solve optimization problem
tic; [feeding_Opt, fval] = solve(Opt); toc

%% Calculate model with optimal values
substr_Model(feeding_Opt, onOff, parameters)

%% Plot results
figure();
plot(1:hoursTotal, interm1, '-o', 'DisplayName', 'Interm production');
hold on; grid on
stairs(0:hoursTotal-1, 5*onOff, '-', 'DisplayName', 'Consumption schedule');
plot(1:hoursTotal, storageVolume/10, '-^', 'MarkerSize', 4,...
    'DisplayName', 'Storage volume [1e-1*m^3]');
stairs(0:hoursTotal-1, feeding_Opt, 'DisplayName', 'Feeding schedule');
xtickVector = 0:12:hoursTotal;
xticks(xtickVector);
xticklabels(xtickVector/24);
xlabel('Time (days)');
legend('Location', 'Best');
set(gca, 'FontSize', 18);
hold off

function storageStd = substr_Model(substr_feeding, onOff, parameters)
    hoursTotal      = length(substr_feeding);
    substr_0        = parameters(1);
    k_1             = parameters(2);
    f_1             = parameters(3);
    phi_1           = parameters(4);
    initialVolume   = parameters(5);

    % Simple for-loop with feeding as vector per hour
    substr = zeros(hoursTotal, 1);
    substr(1) = (substr_0 + substr_feeding(1))*exp(-k_1/24);
    for hour = 2:hoursTotal
       substr(hour) = (substr(hour-1) + substr_feeding(hour))*exp(-k_1/24);
    end
    % Calculate resulting interm1 production and storage volume
    interm1 = phi_1*f_1*substr/24;
    interm1ConsumptionRate = 11.24509;
    storageVolume = initialVolume + cumsum(interm1 - onOff*interm1ConsumptionRate);
    assignin('base', 'substr', substr);
    assignin('base', 'interm1', interm1);
    assignin('base', 'storageVolume', storageVolume);
    storageStd = std(storageVolume);
end

Objective function value is 15.9630, taking 181 iterations and only 182 function calls.
Now the second one, which calls fmincon directly (replace lines 30-36):

optimOpts = optimoptions('fmincon', 'Display', 'iter', 'FunctionTolerance', 1e-2,...
    'MaxIterations', 1e5, 'MaxFunctionEvaluations', 1e5*daysTotal);

%% Solve optimization problem
tic; [feeding_Opt, fval] = fmincon(objFun, substr_in_time, [], [], [], [],...
    lowerBound, upperBound, [], optimOpts); toc

Now, fval = 15.3764, taking 244 iterations and 41419 function calls. So I actually get a better result without OPTI, although it's the same solver under the hood.
Can you reproduce this? What could be the reason? I am on Matlab R2018a btw.

Installation for Linux

opti_Install


INSTALLING OPTI TOOLBOX ver 2.27

  • Checking MATLAB version and operating system...
    Error using opti_Install>matlabVerCheck (line 214)
    OPTI Toolbox is compiled only for Windows systems - sorry!

Error in opti_Install (line 38)
matlabVerCheck();

It's nowhere mentioned in the README that it's just for Window.

Any chance that I can also install that under Linux?

And if not it might be very, very nice to tell that the "victim" before he/she embarks on it trying to install it under Linux.

SCIP v8.1.0 and license change

OPTI Toolbox v2.29 installs an old version of SCIP. The latest version of SCIP is v8.1.0: https://scipopt.org/
In addition, as of Nov. 4, 2022, the SCIP license changed to Apache 2.0 License, so that no license is required for commercial use.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.