Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] add example to index.md #3820

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,37 @@ Welcome to the documentation for JuMP.

[JuMP](https://github.com/jump-dev/JuMP.jl) is a domain-specific modeling
language for [mathematical optimization](https://en.wikipedia.org/wiki/Mathematical_optimization)
embedded in [Julia](https://julialang.org/). It currently supports a number of
open-source and commercial solvers for a variety of problem classes, including
linear, mixed-integer, second-order conic, semidefinite, and nonlinear
programming.
embedded in [Julia](https://julialang.org/).

JuMP makes it easy to formulate and solve a range of problem classes, including
linear programs, integer programs, conic programs, semidefinite programs, and
constrained nonlinear programs. Here’s an example:

```julia
julia> using JuMP, Ipopt

julia> function solve_constrained_least_squares_regression(A::Matrix, b::Vector)
m, n = size(A)
model = Model(Ipopt.Optimizer)
set_silent(model)
@variable(model, x[1:n])
@variable(model, residuals[1:m])
@constraint(model, residuals == A * x - b)
@constraint(model, sum(x) == 1)
@objective(model, Min, sum(residuals.^2))
optimize!(model)
return value.(x)
end
solve_constrained_least_squares_regression (generic function with 1 method)

julia> A, b = rand(10, 3), rand(10);

julia> x = solve_constrained_least_squares_regression(A, b)
3-element Vector{Float64}:
0.4137624719002825
0.09707679853084578
0.48916072956887174
```

!!! tip
If you aren't sure if you should use JuMP, read [Should you use JuMP?](@ref).
Expand Down
Loading