Giter Site home page Giter Site logo

snopt.jl's Introduction

Snopt.jl

Julia interface to SNOPT v7 (must obtain a licensed copy of SNOPT separately).

This package is a basic wrapper to the Fortran functions. It follows the snopt functions, but with some conveniences in auto-populating sparsity patterns, vector lengths, making names the appropriate size, etc.

As an alternative to using this package directly you may be interested in SNOW.jl. SNOW provides a more convenient and unified interface to multiple optimizers (currently snopt and ipopt) as well as multiple differentiation packages (forwarddiff, reversediff, finitediff, sparsedifftools, etc.). Since we mainly use this package through SNOW.jl, documentation is prioritized over there, but for those interested in direct use there are detailed docstrings for each function, and multiple examples in the example folder.

To Install

  1. Checkout the repo for development:
(v1.0) pkg> dev https://github.com/byuflowlab/Snopt.jl.git
  1. Copy your SNOPT source files into ~/.julia/dev/Snopt/deps/src.

  2. You will need to make a couple of changes to subroutine sn02lib.f. Function snSet, snSeti, and snSetr require the following changes:

    character*(*) buffer => character buffer*72 (snSet)

    character*(*) buffer => character buffer*55 (snSeti and snSetr)

    lenbuf = len(buffer) => lenbuf = len_trim(buffer) (snSeti and snSetr)

    The first two change the argument from a variable length string to one with a known length (which are the max lengths according to snopt docs). I had problems trying to pass variable length strings from Julia. I believe this can be done with pointers and allocatable strings, but that requires changes on the Fortran side anyway (and the changes would be more extensive). You must then always pass in a string of the correct length from Julia, so I pad the options with spaces in Julia, but this is transparent to the user. The latter change computes the length without the whitespace at the end so that the messages printed in the files don't contain the extra padding.

  3. sn27lu.f, sn27lu77.f, and sn27lu90.f contain duplicate symbols. You'll need to keep only one file. I deleted the latter two files. If you are building with SNOPT v7.7 and do not define any user functions, you will also need to delete snopth.f.

  4. Compile the fortran code.

(v1.0) pkg> build Snopt

Note for ARM architectures (e.g., new macs)

The ARM architecture does not yet support closures for C callbacks (see JuliaLang/julia#27174). A temporary workaround is in the "arm" branch.

Run tests

(v1.0) pkg> test Snopt

To Use

using Snopt

See examples in tests.

snopt.jl's People

Contributors

andrewning avatar dingraha avatar jaredthomas68 avatar moore54 avatar rymanderson avatar taylormcd avatar

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.