### Welcome to the OpenSolver on-line help.

We hope that most of your questions will be answered on the Using OpenSolver page. However, if you still have a question, please post it below.

## Building Linear Programming models

Writing optimisation models that only use linear mathematical equations and inequalities is not easy. However, most of the time you want to build these “linear programming” models (and avoid non-linear models) because these are easier and more reliable to solve using packages such as OpenSolver. (OpenSolver uses CBC by default to solve these linear programmes.) Check out this Wiki page on linear programming.

The AIMMS folks have a great online chapter describing how to take non-linear requirements (local copy of pdf) and model them using linear programming. (Thanks to Stu Mitchell of PuLP fame for pointing out this resource.) The NEOS guide is also a great resource. If you still have a modelling question (e.g., how do I express this requirement using the rules for a linear program), please ask it on https://www.or-exchange.org/.

## Common Software Problems

Excel can have problems dealing with add-ons. Visit http://www.add-ins.com/how_to_repair_office.htm for a guide on fixing these.

### 1. OpenSolver not loading – July 2016 Office update (no error message)

In July 2016, MicroSoft released an update to Office 365 which prevents OpenSolver from loading unless the .zip file is “unblocked” before the files are extracted. (We expect this change to appear in other versions of Excel.) The symptoms are simply that OpenSolver does not appear in the Data tab; there is no error message shown. To fix this, delete your old OpenSolver files (but not the downloaded .zip file), right click the downloaded OpenSolver .zip file, choose Properties, and click the Unblock button which will show if the file is blocked. Once the file is unblock, close the properties dialog, and then un-zip the files and open up OpenSolver.xlam as usual.

### 2. Unable to find the external solver …

If OpenSolver reports this problem, then it could not find a solver file that comes with OpenSolver. Please check that you have extracted (i.e. un-zipped or uncompressed) all the files from the OpenSolver download.

### 3. The solver did not create a solution file.

If this error is reported, then it is likely that OpenSolver was unable to run the solver executable. This may happen if the OpenSolver files are in an ‘untrusted’ location, and so Windows will not let them be run. First check whether the solver is shown as found in the “About OpenSolver” form. If not, go to the folder identified in the “About OpenSolver” form and double click on this solver file. You should then see a command window open that gives the solver name and version information etc. If you don’t see this, then Windows should give you an error message to help you diagnose the problem. It may help to move the OpenSolver folder (and all the files it contains) into a location such as your Documents, or even into Program Files, and try again.

### 4. Solver crashes; OpenSolver reports no solution file

The files in the “Solver” folder provided with OpenSolver contain the actual solver code. These solvers are being continually upgraded as bugs are reported and fixed. If OpenSolver reports that no solution file was generated, then the solver may have crashed. This can happen on big problems when the solver runs out of memory, but also on smaller problems that happen to hit a solver bug. In such cases, you should check if a newer version of OpenSolver is available since we regularly update the solvers included with OpenSolver as they are released.

With CBC, a typical OpenSolver error for thois problem message might be: ‘The CBC solver did not complete, but aborted with the error code -1073741510’

If needed, you can download the latest version of CBC, Bonmin or Couenne from AMPL. Download the either the Windows or Mac version as appropriate. For Windows, get the 32-bit version if you have 32-bit Windows, or the 64-bit version otherwise. (The 64 bit version will solve much larger problems than the standard 32 bit version included in OpenSolver, so always choose this if possible. Right-clicking on Computer, and choosing Properties, will tell you if have a 32 or 64 bit system type.) Right click on the downloaded .zip file, choose Properties, and click the Unblock button if there is one. Then, open the .zip file, and drag the files into the right location in your OpenSolver Solvers folder (the win32, win64 or osx folder as appropriate), replacing the existing files. This may fix your problem.

**Report a CBC bug**

If after installing the latest version of CBC, CBC still crashes on you, then you may wish to report a bug. Please be sure to include the .lp file produced by OpenSolver; you can open this file using “View Last Model .lp File”. CBC bugs can be reported by either:

- The online CBC TRAC bug reporting system (which you will have to register for), or
- The CBC mail list

**Switch from CBC to Gurobi**

Since August 2014, OpenSolver has also supported solving models using the Gurobi solver. You can obtain a copy of this solver at no charge if you are at a university. Gurobi is faster and more stable than CBC, and comes highly recommended.

### 5. Repairing Excel

Sometimes it is useful (if all else fails) to repair your Office installation:

**Windows**

See these Microsoft Office 2010 and later instructions (or in Excel 2007, use Excel’s application menu, then Excel Options, then Resources, then “run Microsoft Office Diagnostics”). You might also want to look at http://support.microsoft.com/kb/166273, which talks about this.

**Mac**

Unfortunately there is no easy way to repair the Office 2011 installation. The best option is to follow these instructions to completely uninstall Office. You can then install Office again from scratch to get a clean version installed.

### 6. ‘Can’t find project or library’ : Missing Reference Errors

OpenSolver uses the “RefEdit” control, which we need but which can cause problems because of missing references caused by version changes. To check for missing references, using the VBA editor (which you access using Alt-F11), select OpenSolver (openSolver.xlam) in the Project window, choose Tools… References, and look for a “Missing:” line. If you see this, un-check that line, close the dialog, and choose File … Save OpenSolver.xlam to update the file. If this doesn’t help, try the above steps for repairing Excel.

**7. Error 70: Unable to delete the file: C:\Users\XXXXXX\AppData\Local\Temp\log1.tmp**

This errors happens if Excel crashes while OpenSolver is running, leaving log1.tmp open. Please restart your computer, which will close this file, and try again.

I’ve installed the Add-in and it seems to work fine.

But only with the CbC solver.

If I use a Coenn o Bonim or other solver, it says report me the following message.

Error -2147220504: Unable to access the Bonmin solver at “C:\Program Files\Microsoft Office\Office14\ADDINS\OpenSolver2.9.0_LinearWin\Solvers\win64\bonmin.exe”

I’ve installed the solver in the directory, so it can find the solver.

I dont’t undertstand why it cannot access the solver.

herein the complete log error.

22 feb 18 11:44:01 [OpenSolver.xlam] SolverCommon.SolveModel: Line 20

22 feb 18 11:44:01 [OpenSolver.xlam] OpenSolverAPI.RunOpenSolver: Line 11

Error -2147220504: Unable to access the Bonmin solver at “C:\Program Files\Microsoft Office\Office14\ADDINS\OpenSolver2.9.0_LinearWin\Solvers\win64\bonmin.exe”

Solver: Bonmin

OpenSolver version 2.9.0 (2017.11.10); Distribution=Advanced

Location: “C:\Program Files\Microsoft Office\Office14\ADDINS\OpenSolver2.9.0_LinearWin\OpenSolver.xlam”

Excel 14.0; build 7191; 64-bit; VBA7

Excel product code = {90140000-0011-0000-1000-0000000FF1CE}

Excel language: Italian

OS: Windows 6.1; 64-bit

Username: bugge

CBC v2.9.7 (64-bit) at “C:\Program Files\Microsoft Office\Office14\ADDINS\OpenSolver2.9.0_LinearWin\Solvers\win64\cbc.exe”

No Gurobi installation was detected. The value of %GUROBI_HOME% was not set.

Bonmin v (64-bit) at “C:\Program Files\Microsoft Office\Office14\ADDINS\OpenSolver2.9.0_LinearWin\Solvers\win64\bonmin.exe”

Couenne v (64-bit) at “C:\Program Files\Microsoft Office\Office14\ADDINS\OpenSolver2.9.0_LinearWin\Solvers\win64\couenne.exe”

Unable to find NOMAD (‘OpenSolverNomad.dll’). Folders searched:

C:\Program Files\Microsoft Office\Office14\ADDINS\OpenSolver2.9.0_LinearWin\Solvers\win64

can anybody help me?

thanks

Did you download the Advanced version? It does not look like it. You don’t need to add solvers yourself. Andrew

Hi,

I am trying to run a linear model with 14 variables xi (where 0=< xi =0 at the same time, meaning if x1>0 then x3=0 or if x3>0 then x1=0.

How can I add this criteria while using a linear model ?

Thank you for your help 🙂

Hi,

I am trying to run a linear model with 14 variables xi (where 0=< xi =0 at the same time, meaning if x1>0 then x3=0 or if x3>0 then x1=0.

Could someone help me please ? 🙂

Thank you

Add a binary variable and constraints that use it to control x1 and x3. Andrew

Hi Andrew,

Thank you for your answer.

I tried to add to the xi variables, yi variables (binary) with the following condition: sum of xi * yi = 1.

But, it does not work. I have the following message : No feasible Integer Solution. I don’t understand why the model tries to find an integer solution, do you ?

Many thanks

Leila

That is non linear. Avoid multiplying variables. Try xi + yi = 1 or similar.

Hi Andrew,

How can I add a binary variable which linearly depends on x1 ?

For example, the following function is not linear = if(x1>0;1;0)

Thank you

Leila

I’ve added more Help on this mathematical modelling (which is not easy – I teach entire university courses on this) on https://opensolver.org/help/ . Hope this helps, Andrew

Thank you very much Andrew.

I found a solution on the following course:

https://download.aimms.com/aimms/download/manuals/AIMMS3OM_IntegerProgrammingTricks.pdf

Leila

Pleased it worked. Modelling can be tricky! Andrew

Hello,

Which solver would you recommend when I want to maximize Y for the the following function?

Y=5*(x^3)+4*(x^2)+3*(x)+56

Thank you,

Alex

Think about what happens as x approaches infinity…

Sorry, x it’s constraint (e.g. 2<x<7)

The formula posted forms an example. The general form is:

Y=a*(x^3)+b*(x^2)+c*(x)+d

Hello. I need to put in relation couples of variables. This seems to make my model not-linear. Generally speaking how can I keep model linear in this case? thanks

Hello Andrew,

First let me convey congratulations for the fantastic OpenSolver tool, and thank you and the team for the dedication. I have successfully used OpenSolver both for prototyping and for end-user implementations with Excel.

I have a problem (*) where I am mostly interested to generate quickly a number of feasible solutions. Is there a CBC Solver option to stop once a feasible solution is found ? I use now the maxTime option of OpenSolver, but I have to set it at a conservative estimate to give enough time. This is a waste of time if we want a relatively high number of feasible solutions.

(*) We are working on a scheduling problem. Due to the nature of the scheduling constraints, it cannot readily be expressed as a linear problem. We have developed a dedicated heuristic (based on Ant Colony Optimization search) to obtain solutions, but the heuristic does not scale very well with the (high) number of tasks. We are looking for a method to exclude already tasks with a low probability of being retained in the solution. By relaxing some of the constraints we can formulate the problem as a shortest path problem. The idea is to generate a sufficiently high number of feasible paths (by changing every time a bit some of the parameters of the relaxed problem), and to exclude those tasks that never were included in any feasible path, before handing the problem to the ACO heuristic.

Thanks !

Guy

Guy: Thanks for the positive comments. To find CBC command line options, please launch cbc.exe from the command line, and use the help option (-h or -? from memory). I do a bit of work on scheduling algorithms, and I teach heuristics. Have you tried a simpler swapping algorithm? I always recommend these before anything complicated, with multiple restarts (perhaps using GRASP). Easy to code, and fast to run. I like your use of shortest path, but can’t you use a dedicated shortest path code? Be faster than an LP solver. Andrew

Hello Andrew,

thank you for the feedback and information.

Yes we considered Dijkstra’s shortest path algorithm, but there are some additional constraints, e.g. some high priority tasks have to be included mandatorily in the set of feasible paths. It was easier to use a “brute force” approach, model it as a linear problem with the additional constraints. The ACO code was provided by our R&D, it is part of their “toolbox”.

Thanks, Guy

I get indications my model is not linear but I am not able to understand why. Here is the mathematical representation: i=1 to 212, number of component; j=1 to 52, number of products; k=1 to 8, number of suppliers (for components and/or products); Supplier of component [i] = Sc[i], which is calculated as: vc[i][1]*1+vc[i][2]*2+vc[i][3]*3+ vc[i][4]*4+vc[i][5]*5+vc[i][6]*6+vc[i][7]*7+vc[i][8]*8 , where vc[i][k] is a variable boolean . Sc[i] is an integer number (1,2,3,4,5,6,7, or 8). Supplier of product [j] = Sp[i], calculated in the same way of Sc[i], but with sets of variable vp[j][k]. For each component [i] is calculated the total quantity which is required to be delivered from supplier Sc[i] to central warehouse. In case the supplier of product [j] where component [i] is required is the same of Sc[i] then the quantity transported is zero. This matter is modelized in this way: (1-((Sc[i]=Sp[j])+0)*Q[j]*c[i][j] , where Q[j] is total quantity of product [j] and c[i][j] is the unit quantity of component [i] used in product [j]. Total quantity of component [i] which needs a transportation is SUM((1-((Sc[i]=Sp[j])+0)*Q[j]*c[i][j])[j=1 to 52]. The overall quantity of components which require a transportation is: SUM(SUM((1-((Sc[i]=Sp[j])+0)*Q[j]*c[i][j])[j=1 to 52]) [i=1 to 212]. This final formula is recognized as not linear. How can I make it linear? Thanks in advance for any help.

Your Sc[i]=Sp[j] is an if which is non-linear.

I replaced Sc[i]=Sp[j] with another formula:

vc[i][1]*vp[j][1]+vc[i][2]*vp[j][2]+vc[i][3]*vp[j][3]+ vc[i][4]*vp[j][4]+vc[i][5]*vp[j][5]+vc[i][6]*vp[j][6]+vc[i][7]*vp[j][7]+vc[i][8]*vp[j][8]. Where vc and vp are boolean 0-1. It works, but the problem comes again from a sub-formula because vc[i][1..8] is calculated as:

vc [i][1] = SUMPRODUCT(vt[1][1]…vt[1][t] ; c[i][1]…c[i][t])

…

vc[i][8]= SUMPRODUCT(vt[8][1]…vt[8][t] ; c[i][1]…c[i][t])

Using these SUMPRODUCT() inside previous formula I get msg of non-linearity.

You are multiplying decision cells vc and vp; that is non-linear (even if OpenSolver does not notice it). Your answer will not be correct. You need to find a linear formulation. Andrew

Any suggestions about how to linearize this statement IF(A=B, 0, 100000)? I tried to search on OR-EXCHANGE and also on google but I found solution only in case of disegual (A>B, A<B) but not straight A=B. Thanks

If A=B only makes sense if they are integer variables. You need to use a new binary variable Z and add two constraints A >= B-9999Z and A <= B+9999Z. Andrew

Thank you Andrew. It seems that does not work:

For example A=B (=5 )

if Z=1, 5 >= 5 – 9999*1 (=-9994) is true, 5= 5 – 9999*0 (=5) is true, 5= B-9999Z and A <= B+9999(1-Z) but is the same

To be clearer: if A=B with suggested constraints both values of Z (0 or 1) satisfy both contraints. In case of A>B or A

B and A<B are trueHi Team Opensolver,

I am having a bit of trouble with the opensolver at the moment which I think could be down to some installation problems however after deleting the Opensolver files and redownloading them the problem persists. I am trying to solve an extremely trivial optimization problem in order to test the capability of the solver before applying it to my problem.

The problem is easily solved with Excel in-built solver but cannot seem to be solved by the Opensolver citing an error message saying that my constraint does no appear to be linear before giving the same nonsensical values for the objective and variable cells. From the aboutsolver menu it says that Opensolver is correctly installed in my documents folder. I have also shown the optimization process while solving and found this line a bit strange “Empty problem – 0 rows, 0 columns and 0 elements

Optimal – objective value 1918.8333”.

Have you any idea how to solve this issue or where I have went wrong? It seems to me that the spreadsheet is not communicating properly with the solver but I have no idea what to do about this. Thanks very much.

Sorry it is not working. Is the .lp file showing a correct model? I assume your model is linear? Andrew