Setting Integrality tolerance in CPLEX and forcing decision variables to take rounded values - optimization

I am currently trying to solve a linear program in CPLEX that has three decision variables, one which is binary and the other two are continuous.
The problem I have is that instead of giving results for the continuous variables like '10' or '0' it sets them to '9.99999' and '0.000001'.
So with a bit of googling I found out that there is a parameter in CPLEX called Integrality tolerance that helps achieving this goal. The problem is, nowhere have I found how I can actually set this parameter in OPL, but instead only with using different APIs. The thing is I'm only using CPLEX to solve my model.
Can anyone guide me on this?

have you tried in OPL
execute
{
cplex.epint=0.0001;
}
?
And in the IDE you can use

Related

force early exit in SCIP branch-and-bound

When using custom branching or node selection rules in SCIPopt, is it possible to force an immediate exit of the branch-and-bound search once a certain known solution is found? I want to say that a specific node is the solution that I want to take, and the B&B procedure should then exit immediately.
I looked at the callback return options for custom branching (https://www.scipopt.org/doc/html/BRANCH.php) and node selection. I don't see an obvious way to return an "exit now". Alternative ways I'm considering: globally fix all the variables or update the global lower bound to match my chosen solution.
Do you want to declare that solution to be optimal somehow? (or do you even know that it is?)
If that is not so important then you could simply callinterruptSolve. Other options would be to set, e.g., the gaplimit to what your gap currently is after finding that solution (using setRealParam)
Edit: So unless you can somehow prove to SCIP that your solution is indeed optimal all your possible options to do this will be somewhat hacky. At that point you might as well force the global lowerbound to match your found solution. Since I don't know how you know that your found solution is optimal I can't really help much more.

Default hyperparameter values in Neuraxle

Implementing pipeline components in Neuraxle, i wonder if it is possible and/or advisable to have default values for hyperparameters. Looking at code and documentation, my guess is that it is not supported, but i cannot find any mention of it in the docs. I notice here that hyperparameters are set before the setup phase, which makes me suspect setting defaults in code is not "possible".
It would be nice with default values, as it would allow much more hyperparameter options without explicitly defining them when training. It would also allow adding hyperparameters without breaking existing training code. A downside with defaults is increased complexity and perhaps issues with reproducibility if defaults change.
Any insight here would be appreciated.
If I understand your question well, it is entirely possible to have default value for a hyperparameter. You can do so using by using your step class constructor function. To do so, your parameter simply needs to have a corresponding FixedHyperparameter instance entry in the hyperparameter space.
e.g.
class MyStep(BaseStep):
def __init__(self, default_hyperparam_value):
BaseStep.__init__(self, hyperparams = {"my_hyperparam_name":default_hyperparam_value},
hyperparams_space={"my_hyperparam_name":FixedHyperparameter(default_hyperparam_value)})
Alternatively, you could exclude it entirely from the hyperparameter dictionaries and simply set it as a step attribute. They are, of course, many other way of achieving similar behaviour.
Let me know if I've misunderstood your question, I'll be glad to provide any further needed insight :)

How do I add KKT conditions, dual feasibility constraints into the primal model using Pyomo or Julia?

I've to model certain bilevel problems. The approach is to delete the second level problems by replacing them with their KKT conditions or replacing them with their optimality conditions, such as strong duality ...
I wish to do this automatically without calculating these conditions myself and hardcoding them back to the primal. I have two main issues I would like to have your assistance about:
How do I add the dual of certain constraints to the objective function?
Are there any ways for me to do what I want, and if not, where can I start to write them so that eventually they get the primal model and return a model with primal, dual constraints, and strong duality or KKT conditions? I guess getting the constraints and manually form the dual problem could be the right approach.
I really appreciate any help you can provide, no matter whether this would be in Julia or Pyomo.
For Pyomo consult the packages pyomo.bilevel (link) and pyomo.mpec (link). I usually prefer to reformulate by hand just so I know what is happening (and use a tool to confirm I did it correctly).

Storing feasible solutions in terms of original variables

I want to store a feasible solution from an event handler that catches the SCIP_EVENTTYPE_BESTSOLFOUND event, and later I would like to give this solution as an heuristic solution to another SCIP instance that is optimizing the same problem but with different parameter settings (this could be in a subsequent optimization or in parallel).
My problem is that the solution I get from using SCIPgetBestSol() will be in terms of the transformed problem, which can be different from the transformed problem in the second SCIP instance.
Would turning presolve off (using SCIPsetPresolving()) be enough for ensuring that SCIP is always referring to the original variables within callback functions?
Is there a particular way that you would recomend for doing this?
Thanks!
Make sure that your event handler can access the array of original variables (SCIPget(N)OrigVars() does the trick). You can always query solution values of original variables, even from transformed solutions, using SCIPgetSolVal(), and store the values in a solution created via SCIPcreateOrigSol().
In order to feed this solution into a different SCIP instance, you have to get the mapping between variables of the primary and secondary SCIP instance right. Create a new solution for the secondary SCIP instance, and set the solution value of a variable to the value of its (pre-)image variable in the primary SCIP.

Modelica Iteration Problems

I am very new to Modelica and mainly have one big problem:
If I use comparisons like e.g. greater as threshold, I don't get the simulation to finish from time to time. The thing is, this doesn't happen always. But if it does, I get the following error message:
"Fix point iteration did not converge at time : xxx"
I already fixed this problem from once with using a hysteresis instead of the "hard" comparison. Do I really have to do this in every case I'll need it? Or does somebody have another idea or solution?
Thanks in advance!
You could encapsulate the hysteresis comparison inside a function and use that everywhere.