# How to generate solution file?

**URL:** https://discourse.julialang.org/t/how-to-generate-solution-file/4266
**Category:** Optimization (Mathematical)
**Created:** [June 14, 2017, 10:19am UTC](https://discourse.julialang.org/t/how-to-generate-solution-file/4266 "2017-06-14T10:19:31Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![gopal2017](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gopal2017/32/31747_2.png) [@gopal2017](https://discourse.julialang.org/u/gopal2017)
#### Post date: [June 14, 2017, 10:19am UTC](https://discourse.julialang.org/t/how-to-generate-solution-file/4266/1 "2017-06-14T10:19:31Z")

</div>

Hello,  
I am using Cbc solver. I used the code mentioned below to generate .sol file at particular location:

m=Model(solver=CbcSolver(ResultFile=“E:/SolverFuncSolution.sol”)  
It is generating .sol file but it is not solution. Its mathematical model. What is the reason?

---

<div class="post-metadata">

### Author: ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)
#### Post date: [June 14, 2017, 10:54am UTC](https://discourse.julialang.org/t/how-to-generate-solution-file/4266/2 "2017-06-14T10:54:51Z")

</div>

Can you post the whole program?

---

<div class="post-metadata">

### Author: ![gopal2017](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gopal2017/32/31747_2.png) [@gopal2017](https://discourse.julialang.org/u/gopal2017)
#### Post date: [June 14, 2017, 4:29pm UTC](https://discourse.julialang.org/t/how-to-generate-solution-file/4266/3 "2017-06-14T16:29:48Z")

</div>

Sorry I can’t. I checked CbcSolver blog. It’s mentioned that .sol file generation provision has been eliminated. There must be some alternative approach.

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [June 14, 2017, 5:44pm UTC](https://discourse.julialang.org/t/how-to-generate-solution-file/4266/4 "2017-06-14T17:44:08Z")

</div>

Next time you ask a question on this forum, please make sure you add a minimum context. Your question is coming out of nowhere and the code is incomplete.

---

<div class="post-metadata">

### Author: ![gopal2017](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gopal2017/32/31747_2.png) [@gopal2017](https://discourse.julialang.org/u/gopal2017)
#### Post date: [June 15, 2017, 11:48am UTC](https://discourse.julialang.org/t/how-to-generate-solution-file/4266/5 "2017-06-15T11:48:45Z")

</div>

Hello,  
I do agree with you. Hope my explanation is quite clear. I just want to know the syntax for generating .sol file after solving a model with Cbc or Ipopt solver. For instance, we can write writeLP(m::Model,file::AbstractString) to generate .lp file for the model. What would be the right approach to generate solution file?

---

<div class="post-metadata">

### Author: ![gopal2017](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gopal2017/32/31747_2.png) [@gopal2017](https://discourse.julialang.org/u/gopal2017)
#### Post date: [June 16, 2017, 5:14pm UTC](https://discourse.julialang.org/t/how-to-generate-solution-file/4266/6 "2017-06-16T17:14:47Z")

</div>

Hello,  
Please check my code and it’s working.  
m=Model(solver=CbcSolver())  
filename=“Enter path of the file such as E:/filename”  
file=open(filename,“w”)  
write(file,“$m.sol”)

I would also request all of you to try the same  
writeLP(m,filename)

Check two files. It is applicable for any linear mathematical model.

---

<div class="post-metadata">

### Author: ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)
#### Post date: [June 17, 2017, 5:39am UTC](https://discourse.julialang.org/t/how-to-generate-solution-file/4266/7 "2017-06-17T05:39:30Z")

</div>

Your code is not a minimal working example: `sol` is not a field of `m`. Do you want the value of the objective function `getvalue(m.obj)` to be saved?

---

<div class="post-metadata">

### Author: ![tkelman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkelman/32/692_2.png) [@tkelman](https://discourse.julialang.org/u/tkelman)
#### Post date: [June 17, 2017, 9:25am UTC](https://discourse.julialang.org/t/how-to-generate-solution-file/4266/8 "2017-06-17T09:25:09Z")

</div>

If you want an AMPL format .sol file, you need to use the AmplNLWriter package.

---

<div class="post-metadata">

### Author: ![gopal2017](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gopal2017/32/31747_2.png) [@gopal2017](https://discourse.julialang.org/u/gopal2017)
#### Post date: [June 17, 2017, 9:33am UTC](https://discourse.julialang.org/t/how-to-generate-solution-file/4266/9 "2017-06-17T09:33:20Z")

</div>

Hello,  
I do appreciate your attempt. We know it. Our object is to  
generate entire solution file from a .lp file. It is a common feature of  
CPLEX. Is there any such option in Cbc/Ipopt solver? I appreciate your  
participation.

Thanks,

---

<div class="post-metadata">

### Author: ![tkelman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkelman/32/692_2.png) [@tkelman](https://discourse.julialang.org/u/tkelman)
#### Post date: [June 18, 2017, 8:24am UTC](https://discourse.julialang.org/t/how-to-generate-solution-file/4266/10 "2017-06-18T08:24:31Z")

</div>

Your question has nothing to do with Julia then.

The Ipopt AMPL executable can take a .nl file as input and outputs a .sol file. The Cbc executable does similar, I think it can also read .lp or .mps files but again that isn’t a Julia question.

---

<div class="post-metadata">

### Author: ![gopal2017](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gopal2017/32/31747_2.png) [@gopal2017](https://discourse.julialang.org/u/gopal2017)
#### Post date: [June 18, 2017, 3:20pm UTC](https://discourse.julialang.org/t/how-to-generate-solution-file/4266/11 "2017-06-18T15:20:26Z")

</div>

Hello Tony,  
Discussion should not be limited.Related topic  
should be discussed for development. If possible try to incorporate such  
issues as we are using Julia for different solvers. Solver packages should  
effectively implement Julia. Am I correct? Well, be careful about intruders  
with malcontent to your blog. I wish best to your development group.

Thanks and regards,
