# Reading lots of variables and passing them to JuMP model's variables and constraints automatically

**URL:** <https://discourse.julialang.org/t/reading-lots-of-variables-and-passing-them-to-jump-models-variables-and-constraints-automatically/10301>\
**Category:** General Usage\
**Tags:** jump\
**Created:** [April 12, 2018, 12:19pm UTC](https://discourse.julialang.org/t/reading-lots-of-variables-and-passing-them-to-jump-models-variables-and-constraints-automatically/10301 "2018-04-12T12:19:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jakub](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@jakub](https://discourse.julialang.org/u/jakub)\
**Post date:** [April 12, 2018, 12:19pm UTC](https://discourse.julialang.org/t/reading-lots-of-variables-and-passing-them-to-jump-models-variables-and-constraints-automatically/10301/1 "2018-04-12T12:19:29Z")

</div>

Hi!

Let’s say that I have a dataframe (created from CSV) that looks like this but has a hundreds of variables:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/0/6/0682cf4a37cd12b20db25b810322793badb5ea91.png)

And I want to create a set of variables and equations for JuMP in a way that model that look like that (assuming that upperbound for y1=5 and for y2=2):

![image](https://global.discourse-cdn.com/julialang/original/3X/1/d/1d909690bd524a2891387d9ad2ade678b3076f74.png)

Is there a good way to do this? I’ve been reading about converting string to variable name/metaprogramming etc. but that doesn’t seem to be correct answer for this.

Thank you,  
Jakub

---

<div class="post-metadata">

**Author:** ![abulak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abulak/32/28314_2.png) [@abulak](https://discourse.julialang.org/u/abulak)\
**Post date:** [April 13, 2018, 7:52am UTC](https://discourse.julialang.org/t/reading-lots-of-variables-and-passing-them-to-jump-models-variables-and-constraints-automatically/10301/2 "2018-04-13T07:52:49Z")

</div>

I don’t know of anything ready for this, seems too specific; You’d have to write Your own solution, creating jump `expression` from e.g. an `Array` obtained by `readdlm`  
see [Expressions and Constraints — JuMP -- Julia for Mathematical Optimization 0.18 documentation](http://www.juliaopt.org/JuMP.jl/0.18/refexpr.html) how to do it;

One thing to watch is that constraints are only (linearly) simplified when model is build, so You may or may not have to do that manually if memory is important (it shouldn’t happen with hundreds of variables though)
