# Copy nonlinear models

**URL:** <https://discourse.julialang.org/t/copy-nonlinear-models/2111>\
**Category:** Optimization (Mathematical)\
**Created:** [February 15, 2017, 4:12am UTC](https://discourse.julialang.org/t/copy-nonlinear-models/2111 "2017-02-15T04:12:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yankai\_Cao](https://avatars.discourse-cdn.com/v4/letter/y/4da419/32.png) [@Yankai\_Cao](https://discourse.julialang.org/u/Yankai_Cao)\
**Post date:** [February 15, 2017, 4:12am UTC](https://discourse.julialang.org/t/copy-nonlinear-models/2111/1 "2017-02-15T04:12:01Z")

</div>

Is there any function to copy a nonlinear model?

Also, I want to know how to combine two models, e.g., I want to combine the variables and constriants from two models into a new model and create a new objective using the sum of the objectives. I can copy the contraints using MathProgBase.constr\_expr(d,i) , but how to combine the two nonlinear objective?

---

<div class="post-metadata">

**Author:** ![miles.lubin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/miles.lubin/32/279_2.png) [@miles.lubin](https://discourse.julialang.org/u/miles.lubin)\
**Post date:** [February 15, 2017, 3:08pm UTC](https://discourse.julialang.org/t/copy-nonlinear-models/2111/2 "2017-02-15T15:08:33Z")

</div>

> [@Yankai\_Cao](#):
>
> Is there any function to copy a nonlinear model?

[No](https://github.com/JuliaOpt/JuMP.jl/blob/9bef25fe7b64492fc0343f5bd3737d02a92cef24/src/nlp.jl#L47). PRs are welcome.

> [@Yankai\_Cao](#):
>
> Also, I want to know how to combine two models, e.g., I want to combine the variables and constriants from two models into a new model and create a new objective using the sum of the objectives. I can copy the contraints using MathProgBase.constr\_expr(d,i) , but how to combine the two nonlinear objective?

You can accomplish this by using the [raw expression input](http://www.juliaopt.org/JuMP.jl/0.15/nlp.html#raw-expression-input) form.
