Or-tools: Passing solver parameters

Created on 5 Apr 2018  Â·  11Comments  Â·  Source: google/or-tools

Currently, SetSolverSpecificParametersAsString() does not work, at least in C# for SCIP. I have passed "limits/time = 60" to limit optimization time to 60 seconds or set "limits/totalnodes = 100" to limit the number of nodes, but none of them work successfully. There seems to be no other way to pass parameters also to other solvers, e.g., CPLEX, right now. Solving MIP problems usually requires to pass at least some solver tuning parameters to improve performance.

Help Needed

Most helpful comment

And what about any other command that it is not time_limit or relative_MIP_gap (via set SetSolverSpecificParametersAsString?)
I am particularly interested in CBC and SCIP.

All 11 comments

For time limits, you can use MpSolver.SetTimeLimit(int64 time_limit_in_ms).

Now I wonder why it does not work as the function is implemented. I will
have a look.
Laurent Perron | Operations Research | [email protected] | (33) 1 42 68 53
00

Le jeu. 5 avr. 2018 à 16:52, Pooya Rezaei notifications@github.com a
écrit :

Currently, SetSolverSpecificParametersAsString() does not work, at least
in C# for SCIP. I have passed "limits/time = 60" to limit optimization time
to 60 seconds or set "limits/totalnodes = 100" to limit the number of
nodes, but none of them work successfully. There seems to be no other way
to pass parameters also to other solvers, e.g., CPLEX, right now. Solving
MIP problems usually requires to pass at least some solver tuning
parameters to improve performance.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/google/or-tools/issues/644, or mute the thread
https://github.com/notifications/unsubscribe-auth/AKj17VJBt-NDEmaHmQRt0sc17F1zVRe0ks5tli-pgaJpZM4TImVC
.

Any update? I also want to know how to pass solver parameters. I'd really appreciate if someone can help me.

Hello, any update? I am trying to set GAP limit but unable to find a way to set it. Help is appreciated. Thank you

Relative MIP Gap is probably the only parameter that can be set directly using SetDoubleParam, and does not need to be passed as string. For other parameters, there is still no way.

namespace Google.OrTools.LinearSolver
{
    public class MPSolverParameters : IDisposable
    {
        public static readonly int RELATIVE_MIP_GAP;
        protected bool swigCMemOwn;

        public MPSolverParameters();

        ~MPSolverParameters();

        public static double kDefaultPrimalTolerance { get; }

        public virtual void Dispose();
        public double GetDoubleParam(int param);
        public void SetDoubleParam(int param, double value);
    }
}

Thanks for the feedback Pooya.
I am trying to do this in Python and cannot find any attribute ‘SetDoubleParam’ in the solver object.

Any thoughts?

Thanks

Here is my code snippet:

 solver = pywraplp.Solver('ScheduleBuilder',
pywraplp.Solver.CBC_MIXED_INTEGER_PROGRAMMING)
#solver.SetTimeLimit(4000)
 solver.SetDoubleParam(solver.RELATIVE_MIP_GAP, 0.02)
gap = solver.GetDoubleParam(solver.RELATIVE_MIP_GAP)
print("GAP param: %f" % gap)

From: Pooya Rezaei notifications@github.com
Reply-To: google/or-tools reply@reply.github.com
Date: Thursday, May 17, 2018 at 10:34 AM
To: google/or-tools or-tools@noreply.github.com
Cc: "Rao, Praveen" Praveen.Rao@charter.com, Comment comment@noreply.github.com
Subject: Re: [google/or-tools] Passing solver parameters (#644)

Relative MIP Gap is probably the only parameter that can be set directly using SetDoubleParam, and does not need to passed as string. For other parameters, there is still no way.

namespace Google.OrTools.LinearSolver
{
public class MPSolverParameters : IDisposable
{
public static readonly int RELATIVE_MIP_GAP;
protected bool swigCMemOwn;

public MPSolverParameters();



~MPSolverParameters();



public static double kDefaultPrimalTolerance { get; }



public virtual void Dispose();

public double GetDoubleParam(int param);

public void SetDoubleParam(int param, double value);

}

}

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com/google/or-tools/issues/644#issuecomment-389888040, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Akhke3wpn2GLn1vq1DbD_H7Uk9rYmF8Dks5tzYpMgaJpZM4TImVC.
E-MAIL CONFIDENTIALITY NOTICE:
The contents of this e-mail message and any attachments are intended solely for the addressee(s) and may contain confidential and/or legally privileged information. If you are not the intended recipient of this message or if this message has been addressed to you in error, please immediately alert the sender by reply e-mail and then delete this message and any attachments. If you are not the intended recipient, you are notified that any use, dissemination, distribution, copying, or storage of this message or any attachment is strictly prohibited.

It is not under Solver. It is under MPSolverParameters. You need to instantiate that object, set MIP Gap and then pass MPSolverParameters to the Solve() method.

I assume this is fixed.

See my answer here #603 for how to use SetSolverSpecificParametersAsString (with CPLEX, same concept might also apply to SCIP)

Any news on how to pass any solver parameters for SCIP solver? I mean not just time limit and relative MIP gap.

Relative mip gap can be set directly on the solver.

create a MPSolverParameters,
SetDoubleParam(MPSolverParameters.RELATIVE_MIP_GAP, value)

then pass to Solve(parameters)
Laurent Perron | Operations Research | [email protected] | (33) 1 42 68 53
00

Le ven. 10 mai 2019 à 05:36, rlloretb notifications@github.com a écrit :

Any news on how to pass any solver parameters for SCIP solver? I mean not
just time limit and relative MIP gap.

—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
https://github.com/google/or-tools/issues/644#issuecomment-491143880,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACUPL3LQFLJHJDT25XN4YF3PUTUUXANCNFSM4EZCMVBA
.

And what about any other command that it is not time_limit or relative_MIP_gap (via set SetSolverSpecificParametersAsString?)
I am particularly interested in CBC and SCIP.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jack-zalora picture jack-zalora  Â·  5Comments

bhack picture bhack  Â·  4Comments

mlk621 picture mlk621  Â·  3Comments

partumamet picture partumamet  Â·  4Comments

karomad picture karomad  Â·  3Comments