Giter Site home page Giter Site logo

Comments (4)

andrewning avatar andrewning commented on July 3, 2024

hmm. Do you have a minimal working example? We wouldn't be able to investigate without more information.

from snopt.jl.

ca0h avatar ca0h commented on July 3, 2024

Please see below. Thanks.

# workspace()
using Snopt

xl = [1;    1;       0;     1;    0;  85;  90;  3; 1.2; 145;  3;    85]
xu = [2000; 16000; 120; 5000; 2000; 93; 95; 12; 4.0; 162; 24000; 465000]
x0 = [1700; 16000; 100; 3000; 2000; 90; 94; 10;   2;  150; 18000; 200000]

function prob(x)
    # --- objective ---
    f = 5.04*x[1] + 0.035*x[2] + 10*x[3] + 3.36*x[5] - 0.063*x[4]*x[7]

    # --- gradient of obj ---
    dfdx = zeros(12)
    dfdx[1] = 5.04
    dfdx[2] = 0.035
    dfdx[3] = 10
    dfdx[4] = -0.063*x[7]
    dfdx[5] = 3.36
    dfdx[7] = -0.063*x[4]

    c = []
    dcdx = []

    fail = false

    return f, c, dfdx, dcdx, fail
end

options = Dict{String, Any}()
options["Derivative option"] = 1
options["Verify level"] = 1

xopt, fopt, info = snopt(prob, x0, xl, xu, options)
println(xopt)
println(info)

from snopt.jl.

andrewning avatar andrewning commented on July 3, 2024

The problem is x0. As you've defined it, it is an integer array. If you just change one of the values to a float (say 1700.0) then everything works. I didn't dig into exactly what the problem is, but my guess is that it is in passing data between fortran and julia and it's looking for a certain length field which is not what it expects (integer vs float).

from snopt.jl.

ca0h avatar ca0h commented on July 3, 2024

That works perfectly. Thanks a lot for you help!

from snopt.jl.

Related Issues (12)

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.